14 \n#include
"VuoGlslProjection.glsl"
17 uniform mat4 modelviewMatrix;
18 attribute vec4 position;
19 attribute vec4 textureCoordinate;
22 varying vec4 positionForGeometry;
23 varying vec4 textureCoordinateForGeometry;
27 positionForGeometry = cameraMatrixInverse * modelviewMatrix * position;
28 textureCoordinateForGeometry = textureCoordinate;
29 gl_Position = VuoGlsl_projectPosition(modelviewMatrix * position);
43 varying vec4 fragmentTextureCoordinate;
55 vec3 color0 = vec3(1 -fragmentTextureCoordinate.x, fragmentTextureCoordinate.y, 1 ) * (gl_FrontFacing ? 1 : .25);
56 vec3 color1 = vec3(0.75-fragmentTextureCoordinate.x, fragmentTextureCoordinate.y-0.25, 0.75) * (gl_FrontFacing ? 1 : .25);
58 vec2 filterWidth = fwidth(fragmentTextureCoordinate.xy) * frequency;
60 vec2 checkPos =
fract(fragmentTextureCoordinate.xy * frequency);
61 vec2 p =
smoothstep(vec2(0.5), filterWidth + vec2(0.5), checkPos) +
62 (1 -
smoothstep(vec2(0), filterWidth, checkPos));
64 gl_FragColor = vec4(
mix(color0, color1, p.x*p.y + (1-p.x)*(1-p.y)), 1);
70 varying vec4 fragmentTextureCoordinate;
71 varying vec4 vertexPosition;
72 varying mat3 vertexPlaneToWorld;
87 vec3 color0 = vec3(1 -fragmentTextureCoordinate.x, fragmentTextureCoordinate.y, 1);
88 vec3 color1 = vec3(0.75-fragmentTextureCoordinate.x, fragmentTextureCoordinate.y-0.25, 0.75);
90 vec2 filterWidth = fwidth(fragmentTextureCoordinate.xy) * frequency;
92 vec2 checkPos =
fract(fragmentTextureCoordinate.xy * frequency);
95 vec2 p =
smoothstep(vec2(0.5), filterWidth + vec2(0.5), checkPos) +
96 (1 -
smoothstep(vec2(0), filterWidth, checkPos+0.00001));
98 gl_FragColor = vec4(
mix(color0, color1, p.x*p.y + (1-p.x)*(1-p.y)), 1);
126 static dispatch_once_t once = 0;
128 dispatch_once(&once, ^{
143 return defaultShader;
159 \n#include
"VuoGlslAlpha.glsl"
162 uniform sampler2D texture;
167 varying vec4 fragmentTextureCoordinate;
176 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate.xy);
178 VuoGlsl_discardInvisible(color.a);
179 gl_FragColor = color;
184 \n#include
"VuoGlslAlpha.glsl"
187 uniform sampler2D texture;
192 varying vec4 vertexPosition;
193 varying mat3 vertexPlaneToWorld;
194 varying vec4 fragmentTextureCoordinate;
206 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate.xy);
208 VuoGlsl_discardInvisible(color.a);
209 gl_FragColor = color;
243 \n#include
"VuoGlslAlpha.glsl"
246 uniform sampler2D texture;
249 varying vec4 fragmentTextureCoordinate;
253 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate.xy);
254 VuoGlsl_discardInvisible(color.a);
255 gl_FragColor = color;
260 \n#include
"VuoGlslAlpha.glsl"
263 uniform sampler2D texture;
266 varying vec4 fragmentTextureCoordinate;
270 vec4 color = VuoGlsl_sample(texture, vec2(fragmentTextureCoordinate.x, 1. - fragmentTextureCoordinate.y));
271 VuoGlsl_discardInvisible(color.a);
272 gl_FragColor = color;
298 \n#include
"VuoGlslAlpha.glsl"
301 uniform sampler2DRect texture;
302 uniform vec2 textureSize;
304 varying vec4 fragmentTextureCoordinate;
308 vec4 color = VuoGlsl_sampleRect(texture, fragmentTextureCoordinate.xy*textureSize);
310 VuoGlsl_discardInvisible(color.a);
311 gl_FragColor = color;
339 \n#include
"VuoGlslAlpha.glsl"
342 uniform sampler2DRect texture;
343 uniform vec2 textureSize;
344 varying vec4 fragmentTextureCoordinate;
348 vec4 color = VuoGlsl_sampleRect(texture, fragmentTextureCoordinate.xy*textureSize);
349 VuoGlsl_discardInvisible(color.a);
350 gl_FragColor = color;
355 \n#include
"VuoGlslAlpha.glsl"
358 uniform sampler2DRect texture;
359 uniform vec2 textureSize;
360 varying vec4 fragmentTextureCoordinate;
364 vec4 color = VuoGlsl_sampleRect(texture, vec2(fragmentTextureCoordinate.x, 1. - fragmentTextureCoordinate.y) * textureSize);
365 VuoGlsl_discardInvisible(color.a);
366 gl_FragColor = color;
388 \n#include
"VuoGlslProjection.glsl"
391 uniform mat4 modelviewMatrix;
392 attribute vec4 position;
396 gl_Position = VuoGlsl_projectPosition(modelviewMatrix * position);
409 gl_FragColor = color;
418 varying vec4 vertexPosition;
419 varying mat3 vertexPlaneToWorld;
420 varying vec4 fragmentTextureCoordinate;
426 fragmentTextureCoordinate;
428 gl_FragColor = color;
464 uniform
float sharpness;
465 varying vec4 fragmentTextureCoordinate;
469 float dist = distance(fragmentTextureCoordinate.xy, vec2(0.5,0.5));
470 float delta = fwidth(dist);
471 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness/2 - delta, 1 - sharpness/2 + delta, dist*2));
476 shader->objectScale = 0.5;
500 const char *fragmentShaderSource =
"#version 120 \n\
501 varying vec4 fragmentTextureCoordinate;\
503 uniform vec4 lineColor;\
504 uniform float thickness;\
505 const int CHECK_VERTICES = 6;\
506 const vec2 CHECK[CHECK_VERTICES] = vec2[] (\
515 bool doLineSegmentsIntersect(vec2 p0, vec2 p1, vec2 p2, vec2 p3)\
520 s = (-s1.y * (p0.x - p2.x) + s1.x * (p0.y - p2.y)) / (-s2.x * s1.y + s1.x * s2.y);\
521 t = ( s2.x * (p0.y - p2.y) - s2.y * (p0.x - p2.x)) / (-s2.x * s1.y + s1.x * s2.y);\
523 return (s >= 0 && s <= 1 && t >= 0 && t <= 1);\
526 float drawLine(vec2 p1, vec2 p2)\
528 vec2 uv = fragmentTextureCoordinate.xy;\
529 float a = abs(distance(p1, uv));\
530 float b = abs(distance(p2, uv));\
531 float c = abs(distance(p1, p2));\
532 if( a >= c || b >= c) return 0.;\
533 float p = (a + b + c) * .5;\
534 float h = 2. / c * sqrt(p * (p-a) * (p-b) * (p-c));\
535 return mix(1, 0, smoothstep(0.5 * thickness, 1.5 * thickness, h));\
538 bool isPointInPolygon(vec2 point)\
540 vec2 rayStart = vec2(0, .5);\
541 bool inPoly = false;\
543 for(int i = 0; i < CHECK_VERTICES; i += 1)\
545 if(doLineSegmentsIntersect(rayStart, point, CHECK[i], CHECK[i == (CHECK_VERTICES-1) ? 0 : i+1]) )\
555 for(int i = 0; i < CHECK_VERTICES; i++)\
556 line = max(drawLine(CHECK[i], CHECK[i < CHECK_VERTICES-1 ? i+1 : 0]), line);\
557 gl_FragColor = mix(isPointInPolygon(fragmentTextureCoordinate.xy) ? color : vec4(0), lineColor, line);\
586 uniform
float sharpness;
587 uniform
float roundness;
588 uniform
float aspect;
589 varying vec4 fragmentTextureCoordinate;
593 float roundness2 = max(1. - sharpness, roundness);
594 roundness2 = min(aspect, roundness2);
595 float diameter = roundness2 / 2.;
596 diameter = max(diameter, 0.001);
597 float radius = diameter / 2.;
598 vec2 r = vec2(radius/aspect, radius);
600 vec2 cornerCircleCenter = vec2(0.,0.);
601 if (fragmentTextureCoordinate.x > 0.75 - r.x)
603 if (fragmentTextureCoordinate.y > 0.75 - r.y)
605 cornerCircleCenter = vec2(0.75, 0.75) + vec2(-r.x, -r.y);
606 else if (fragmentTextureCoordinate.y < 0.25 + r.y)
608 cornerCircleCenter = vec2(0.75, 0.25) + vec2(-r.x, r.y);
610 else if (fragmentTextureCoordinate.x < 0.25 + r.x)
612 if (fragmentTextureCoordinate.y > 0.75 - r.y)
614 cornerCircleCenter = vec2(0.25, 0.75) + vec2( r.x, -r.y);
615 else if (fragmentTextureCoordinate.y < 0.25 + radius)
617 cornerCircleCenter = vec2(0.25, 0.25) + vec2( r.x, r.y);
621 if (cornerCircleCenter.x > 0.)
622 dist = distance((fragmentTextureCoordinate.xy - cornerCircleCenter) * vec2(aspect, 1.) + cornerCircleCenter, cornerCircleCenter) / diameter;
625 float f = 1. - (1. - sharpness) * (1. - sharpness);
628 float n = (fragmentTextureCoordinate.x - 0.5) * f;
630 if (fragmentTextureCoordinate.y < 0.5 + n)
632 if (fragmentTextureCoordinate.y > 0.5 - n)
634 dist = (fragmentTextureCoordinate.x - (0.75 - r.x)) * aspect;
637 dist = (0.25 + r.y) - fragmentTextureCoordinate.y;
641 if (fragmentTextureCoordinate.y > 0.5 - n)
643 dist = fragmentTextureCoordinate.y - (0.75 - r.y);
646 dist = ((0.25 + r.x) - fragmentTextureCoordinate.x) * aspect;
653 float delta = fwidth(fragmentTextureCoordinate.y);
657 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness / 2. - delta, 1. - sharpness / 2. + delta, dist));
662 shader->objectScale = 0.5;
694 uniform vec4 backgroundColor;
695 uniform vec4 activeColor;
696 uniform
float sharpness;
697 uniform
float roundness;
698 uniform
float aspect;
699 uniform
float progress;
700 uniform
bool isHorizontal;
701 varying vec4 fragmentTextureCoordinate;
705 float roundness2 = max(1. - sharpness, roundness);
706 roundness2 = min(aspect, roundness2);
707 float diameter = roundness2 / 2.;
708 diameter = max(diameter, 0.001);
709 float radius = diameter / 2.;
710 vec2 r = vec2(radius/aspect, radius);
712 vec2 cornerCircleCenter = vec2(0.,0.);
713 if (fragmentTextureCoordinate.x > 0.75 - r.x)
715 if (fragmentTextureCoordinate.y > 0.75 - r.y)
717 cornerCircleCenter = vec2(0.75, 0.75) + vec2(-r.x, -r.y);
718 else if (fragmentTextureCoordinate.y < 0.25 + r.y)
720 cornerCircleCenter = vec2(0.75, 0.25) + vec2(-r.x, r.y);
722 else if (fragmentTextureCoordinate.x < 0.25 + r.x)
724 if (fragmentTextureCoordinate.y > 0.75 - r.y)
726 cornerCircleCenter = vec2(0.25, 0.75) + vec2( r.x, -r.y);
727 else if (fragmentTextureCoordinate.y < 0.25 + radius)
729 cornerCircleCenter = vec2(0.25, 0.25) + vec2( r.x, r.y);
733 if (cornerCircleCenter.x > 0.)
734 dist = distance((fragmentTextureCoordinate.xy - cornerCircleCenter) * vec2(aspect, 1.) + cornerCircleCenter, cornerCircleCenter) / diameter;
737 float f = 1. - (1. - sharpness) * (1. - sharpness);
740 float n = (fragmentTextureCoordinate.x - 0.5) * f;
742 if (fragmentTextureCoordinate.y < 0.5 + n)
744 if (fragmentTextureCoordinate.y > 0.5 - n)
746 dist = (fragmentTextureCoordinate.x - (0.75 - r.x)) * aspect;
749 dist = (0.25 + r.y) - fragmentTextureCoordinate.y;
753 if (fragmentTextureCoordinate.y > 0.5 - n)
755 dist = fragmentTextureCoordinate.y - (0.75 - r.y);
758 dist = ((0.25 + r.x) - fragmentTextureCoordinate.x) * aspect;
764 float delta = fwidth(dist) / 2.;
770 float val = (isHorizontal ? fragmentTextureCoordinate.x : fragmentTextureCoordinate.y);
771 val = (
clamp(val, .25, .75) - .25) / .5;
772 vec4 color = val < progress ? activeColor : backgroundColor;
773 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness / 2. - delta, 1. - sharpness / 2. + delta, dist));
778 shader->objectScale = 0.5;
802 \n#include
"VuoGlslProjection.glsl"
805 uniform mat4 modelviewMatrix;
806 attribute vec4 position;
807 attribute vec4 normal;
808 attribute vec4 tangent;
809 attribute vec4 bitangent;
812 varying vec4 vertexPosition;
813 varying mat3 vertexPlaneToWorld;
814 varying vec4 fragmentTextureCoordinate;
818 fragmentTextureCoordinate;
820 vertexPosition = modelviewMatrix * position;
822 vertexPlaneToWorld[0] = normalize(vec3(modelviewMatrix * vec4(tangent.xyz, 0.)));
823 vertexPlaneToWorld[1] = normalize(vec3(modelviewMatrix * -vec4(bitangent.xyz, 0.)));
824 vertexPlaneToWorld[2] = normalize(vec3(modelviewMatrix * vec4(normal.xyz, 0.)));
826 gl_Position = VuoGlsl_projectPosition(vertexPosition);
834 \n#include
"lighting.glsl"
837 uniform vec4 diffuseColor;
838 uniform vec4 specularColor;
839 uniform
float specularPower;
842 varying vec4 fragmentTextureCoordinate;
849 gl_FragColor = diffuseColor;
851 fragmentTextureCoordinate;
853 vec3 ambientContribution = vec3(0.);
854 vec3 diffuseContribution = vec3(0.);
855 vec3 specularContribution = vec3(0.);
857 calculateLighting(specularPower, vec3(0,0,1), ambientContribution, diffuseContribution, specularContribution);
859 ambientContribution *= diffuseColor.rgb;
860 diffuseContribution *= diffuseColor.rgb;
861 specularContribution *= specularColor.rgb * specularColor.a;
862 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, diffuseColor.a);
887 \n#include
"VuoGlslProjection.glsl"
890 uniform mat4 modelviewMatrix;
891 attribute vec4 position;
892 attribute vec4 normal;
893 attribute vec4 tangent;
894 attribute vec4 bitangent;
895 attribute vec4 textureCoordinate;
898 varying vec4 vertexPosition;
899 varying vec4 fragmentTextureCoordinate;
900 varying mat3 vertexPlaneToWorld;
904 vertexPosition = modelviewMatrix * position;
906 fragmentTextureCoordinate = textureCoordinate;
908 vertexPlaneToWorld[0] = normalize(vec3(modelviewMatrix * vec4(tangent.xyz,0.)));
909 vertexPlaneToWorld[1] = normalize(vec3(modelviewMatrix * -vec4(bitangent.xyz,0.)));
910 vertexPlaneToWorld[2] = normalize(vec3(modelviewMatrix * vec4(normal.xyz,0.)));
912 gl_Position = VuoGlsl_projectPosition(vertexPosition);
921 \n#include
"VuoGlslProjection.glsl"
924 uniform mat4 modelviewMatrix;
925 attribute vec4 position;
926 attribute vec4 normal;
927 attribute vec4 tangent;
928 attribute vec4 bitangent;
929 attribute vec4 textureCoordinate;
932 varying vec4 positionForGeometry;
933 varying vec4 textureCoordinateForGeometry;
937 positionForGeometry = modelviewMatrix * position;
938 textureCoordinateForGeometry = textureCoordinate;
939 gl_Position = VuoGlsl_projectPosition(positionForGeometry);
962 \n#include
"VuoGlslAlpha.glsl"
963 \n#include
"lighting.glsl"
966 varying vec4 fragmentTextureCoordinate;
969 uniform sampler2D texture;
971 uniform vec4 specularColor;
972 uniform
float specularPower;
979 gl_FragColor = specularColor;
981 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate.xy);
983 VuoGlsl_discardInvisible(color.a);
985 vec3 ambientContribution = vec3(0.);
986 vec3 diffuseContribution = vec3(0.);
987 vec3 specularContribution = vec3(0.);
989 calculateLighting(specularPower, vec3(0,0,1), ambientContribution, diffuseContribution, specularContribution);
991 ambientContribution *= color.rgb;
992 diffuseContribution *= color.rgb;
993 specularContribution *= specularColor.rgb * specularColor.a;
994 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, color.a);
1028 if (!image || !specularImage || !normalImage)
1031 const char *pointGeometryShaderSource =
VUOSHADER_GLSL_SOURCE(120, \n#include
"trianglePoint.glsl");
1035 \n#include
"VuoGlslAlpha.glsl"
1036 \n#include
"lighting.glsl"
1039 varying vec4 fragmentTextureCoordinate;
1042 uniform sampler2D texture;
1043 uniform
float alpha;
1044 uniform sampler2D specularImage;
1045 uniform sampler2D normalImage;
1053 gl_FragColor = blah;
1055 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate.xy);
1057 VuoGlsl_discardInvisible(color.a);
1059 vec3 ambientContribution = vec3(0.);
1060 vec3 diffuseContribution = vec3(0.);
1061 vec3 specularContribution = vec3(0.);
1063 vec4 specularColor = texture2D(specularImage, fragmentTextureCoordinate.xy);
1064 float specularPower = 1./(1.0001-specularColor.a);
1066 vec4 normalColor = texture2D(normalImage, fragmentTextureCoordinate.xy);
1067 vec3 normal = normalize(vec3(
1068 2. * normalColor.r - 1.,
1069 2. * normalColor.g - 1.,
1073 calculateLighting(specularPower, normal, ambientContribution, diffuseContribution, specularContribution);
1075 ambientContribution *= color.rgb;
1076 diffuseContribution *= color.rgb;
1077 specularContribution *= specularColor.rgb * specularColor.a;
1078 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, color.a);
1109 \n#include
"VuoGlslAlpha.glsl"
1110 \n#include
"VuoGlslRandom.glsl"
1112 uniform
float inputColorCount;
1113 uniform
float stripColorCount;
1114 uniform sampler2D gradientStrip;
1117 uniform
float aspect;
1118 uniform
float noiseAmount;
1120 varying vec4 fragmentTextureCoordinate;
1122 float distSqr(vec2 a, vec2 b)
1124 return (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y);
1129 vec2 nearest_point_on_line(vec2 v, vec2 w, vec2 p)
1132 float l2 = distSqr(v, w);
1133 if (l2 == 0.0)
return p;
1137 float t =
dot(p - v, w - v) / l2;
1138 vec2 projection = v + t * (w - v);
1144 vec2 tcAspect = fragmentTextureCoordinate.xy;
1146 tcAspect.y *= aspect;
1149 vec2 pol = nearest_point_on_line(start, end, tcAspect);
1150 float x =
dot(pol-start, end-start) > 0 ? distance(start, pol)/ distance(start, end) : 0;
1153 x *= inputColorCount - 1.;
1155 x /= inputColorCount - 1.;
1157 float gradientWidth = (1./stripColorCount)/2.;
1158 x = x * (1-gradientWidth*2) + gradientWidth;
1160 vec4 color = VuoGlsl_sample(gradientStrip, vec2(
clamp(x , gradientWidth, 1.-gradientWidth), .5));
1161 VuoGlsl_discardInvisible(color.a);
1163 color.rgb += (VuoGlsl_random2D3D(fragmentTextureCoordinate.xy) - 0.5) * noiseAmount;
1165 gl_FragColor = color;
1186 int gradientExpansion = 16;
1188 GLenum format = GL_BGRA;
1197 int stripColorCount = (inputColorCount - 1) * gradientExpansion + 1;
1199 unsigned char *pixels = (
unsigned char*)malloc(stripColorCount * bpp);
1202 for (
int i = 0; i < stripColorCount; ++i)
1216 if (
step >= gradientExpansion)
1251 \n#include
"VuoGlslAlpha.glsl"
1252 \n#include
"VuoGlslRandom.glsl"
1254 uniform
float inputColorCount;
1255 uniform
float stripColorCount;
1256 uniform sampler2D gradientStrip;
1257 uniform vec2 center;
1259 uniform
float radius;
1260 uniform
float noiseAmount;
1262 varying vec4 fragmentTextureCoordinate;
1266 vec2 scaledTexCoord = fragmentTextureCoordinate.xy*scale;
1267 float x = distance(center*scale, scaledTexCoord)/radius;
1270 x *= inputColorCount - 1.;
1272 x /= inputColorCount - 1.;
1274 float gradientWidth = (1./stripColorCount)/2.;
1275 x = x * (1-gradientWidth*2) + gradientWidth;
1277 vec4 color = VuoGlsl_sample(gradientStrip, vec2(
clamp(x , gradientWidth, 1.-gradientWidth), .5));
1278 VuoGlsl_discardInvisible(color.a);
1280 color.rgb += (VuoGlsl_random2D3D(fragmentTextureCoordinate.xy) - 0.5) * noiseAmount;
1282 gl_FragColor = color;
1314 \n#include
"VuoGlslProjection.glsl"
1317 uniform mat4 modelviewMatrix;
1318 attribute vec4 position;
1319 attribute vec4 normal;
1320 attribute vec4 textureCoordinate;
1323 varying vec4 positionForGeometry;
1324 varying vec4 textureCoordinateForGeometry;
1328 positionForGeometry = modelviewMatrix * position;
1329 textureCoordinateForGeometry = textureCoordinate;
1330 gl_Position = VuoGlsl_projectPosition(positionForGeometry);
1334 const char *pointGeometryShaderSource =
VUOSHADER_GLSL_SOURCE(120, \n#include
"trianglePoint.glsl");
1338 \n#include
"VuoGlslAlpha.glsl"
1339 \n#include
"noise3D.glsl"
1342 uniform sampler2D colorBuffer;
1343 uniform vec2 viewportSize;
1347 uniform
float aspectRatio;
1348 uniform vec2 noisePosition;
1349 uniform
float noiseTime;
1350 uniform
float noiseAmount;
1351 uniform
float noiseScale;
1352 uniform
float chromaticAberration;
1353 uniform
int iterations;
1355 uniform
float roughness;
1356 uniform
float spacing;
1359 varying vec4 fragmentTextureCoordinate;
1363 vec2 viewportTextureCoordinate = gl_FragCoord.xy/viewportSize;
1365 vec4 accumulatedColor = vec4(0.);
1366 for (
int i = 0; i < iterations; ++i)
1370 vec3 noiseCoordinate = vec3(fragmentTextureCoordinate.x - .5 - noisePosition.x +
float(i), (fragmentTextureCoordinate.y - .5 - noisePosition.y) / aspectRatio, noiseTime);
1371 noiseCoordinate.xy *= noiseScale;
1372 vec2 noiseOffset = snoise3D2DFractal(noiseCoordinate, levels, roughness, spacing);
1375 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. - chromaticAberration/3.)) * vec4(1.,0.,0.,1./3.);
1378 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount) * vec4(0.,1.,0.,1./3.);
1381 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. + chromaticAberration/3.)) * vec4(0.,0.,1.,1./3.);
1384 vec4 c = accumulatedColor / float(iterations);
1387 c.rgb =
clamp(c.rgb, 0., 1.);
1394 \n#include
"VuoGlslAlpha.glsl"
1395 \n#include
"noise3D.glsl"
1398 uniform sampler2D colorBuffer;
1399 uniform vec2 viewportSize;
1403 uniform
float aspectRatio;
1404 uniform vec2 noisePosition;
1405 uniform
float noiseTime;
1406 uniform
float noiseAmount;
1407 uniform
float noiseScale;
1408 uniform
float chromaticAberration;
1409 uniform
int iterations;
1411 uniform
float roughness;
1412 uniform
float spacing;
1415 varying vec4 vertexPosition;
1416 varying mat3 vertexPlaneToWorld;
1417 varying vec4 fragmentTextureCoordinate;
1424 gl_FragColor = color;
1429 vec2 viewportTextureCoordinate = gl_FragCoord.xy/viewportSize;
1431 vec4 accumulatedColor = vec4(0.);
1432 for (
int i = 0; i < iterations; ++i)
1436 vec3 noiseCoordinate = vec3(fragmentTextureCoordinate.x - .5 - noisePosition.x +
float(i), (fragmentTextureCoordinate.y - .5 - noisePosition.y) / aspectRatio, noiseTime);
1437 noiseCoordinate.xy *= noiseScale
1438 vec2 noiseOffset = snoise3D2DFractal(noiseCoordinate, levels, roughness, spacing);
1441 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. - chromaticAberration/3.)) * vec4(1.,0.,0.,1./3.);
1444 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount) * vec4(0.,1.,0.,1./3.);
1447 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. + chromaticAberration/3.)) * vec4(0.,0.,1.,1./3.);
1450 vec4 c = accumulatedColor / float(iterations);
1453 c.rgb =
clamp(c.rgb, 0., 1.);
1460 s->isTransparent =
true;
1478 void VuoShader_setFrostedGlassShaderValues(
VuoShader shader,
VuoColor color,
VuoReal brightness, VuoPoint2d noisePosition,
VuoReal noiseTime,
VuoReal noiseAmount,
VuoReal noiseScale,
VuoReal chromaticAberration,
VuoInteger levels,
VuoReal roughness,
VuoReal spacing,
VuoInteger iterations,
float aspectRatio)
1482 (noisePosition.y+1)/2 * aspectRatio});