14 \n#include
"VuoGlslProjection.glsl"
17 uniform mat4 modelviewMatrix;
18 attribute vec3 position;
19 attribute vec3 normal;
20 attribute vec2 textureCoordinate;
21 attribute vec4 vertexColor;
22 uniform
bool hasVertexColors;
25 varying vec3 geometryPosition;
26 varying vec3 geometryNormal;
27 varying vec2 geometryTextureCoordinate;
28 varying vec4 geometryVertexColor;
32 geometryPosition = (cameraMatrixInverse * modelviewMatrix * vec4(position, 1.)).xyz;
33 geometryNormal = (cameraMatrixInverse * modelviewMatrix * vec4(normal, 0.)).xyz;
34 geometryTextureCoordinate = textureCoordinate;
35 geometryVertexColor = hasVertexColors ? vertexColor : vec4(1.);
36 gl_Position = VuoGlsl_projectPosition(modelviewMatrix * vec4(position, 1.));
50 varying vec2 fragmentTextureCoordinate;
62 vec3 color0 = vec3(1 -fragmentTextureCoordinate.x, fragmentTextureCoordinate.y, 1 ) * (gl_FrontFacing ? 1 : .25);
63 vec3 color1 = vec3(0.75-fragmentTextureCoordinate.x, fragmentTextureCoordinate.y-0.25, 0.75) * (gl_FrontFacing ? 1 : .25);
65 vec2 filterWidth = fwidth(fragmentTextureCoordinate) * frequency;
67 vec2 checkPos =
fract(fragmentTextureCoordinate * frequency);
68 vec2 p =
smoothstep(vec2(0.5), filterWidth + vec2(0.5), checkPos) +
69 (1 -
smoothstep(vec2(0), filterWidth, checkPos));
71 gl_FragColor = vec4(
mix(color0, color1, p.x*p.y + (1-p.x)*(1-p.y)), 1);
77 varying vec3 fragmentPosition;
78 varying vec3 fragmentNormal;
79 varying vec2 fragmentTextureCoordinate;
80 varying vec4 fragmentVertexColor;
92 fragmentTextureCoordinate;
97 vec3 color0 = vec3(1 -fragmentTextureCoordinate.x, fragmentTextureCoordinate.y, 1);
98 vec3 color1 = vec3(0.75-fragmentTextureCoordinate.x, fragmentTextureCoordinate.y-0.25, 0.75);
100 vec2 filterWidth = fwidth(fragmentTextureCoordinate) * frequency;
102 vec2 checkPos =
fract(fragmentTextureCoordinate * frequency);
105 vec2 p =
smoothstep(vec2(0.5), filterWidth + vec2(0.5), checkPos) +
106 (1 -
smoothstep(vec2(0), filterWidth, checkPos+0.00001));
108 gl_FragColor = vec4(
mix(color0, color1, p.x*p.y + (1-p.x)*(1-p.y)), 1);
136 static dispatch_once_t once = 0;
138 dispatch_once(&once, ^{
153 return defaultShader;
169 \n#include
"VuoGlslAlpha.glsl"
172 uniform sampler2D texture;
177 varying vec2 fragmentTextureCoordinate;
178 varying vec4 fragmentVertexColor;
187 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate) * fragmentVertexColor;
189 VuoGlsl_discardInvisible(color.a);
190 gl_FragColor = color;
195 \n#include
"VuoGlslAlpha.glsl"
198 uniform sampler2D texture;
203 varying vec3 fragmentPosition;
204 varying vec2 fragmentTextureCoordinate;
205 varying vec4 fragmentVertexColor;
216 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate) * fragmentVertexColor;
218 VuoGlsl_discardInvisible(color.a);
219 gl_FragColor = color;
253 \n#include
"VuoGlslAlpha.glsl"
256 uniform sampler2D texture;
259 varying vec2 fragmentTextureCoordinate;
263 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate);
264 VuoGlsl_discardInvisible(color.a);
265 gl_FragColor = color;
270 \n#include
"VuoGlslAlpha.glsl"
273 uniform sampler2D texture;
276 varying vec2 fragmentTextureCoordinate;
280 vec4 color = VuoGlsl_sample(texture, vec2(fragmentTextureCoordinate.x, 1. - fragmentTextureCoordinate.y));
281 VuoGlsl_discardInvisible(color.a);
282 gl_FragColor = color;
308 \n#include
"VuoGlslAlpha.glsl"
311 uniform sampler2DRect texture;
312 uniform vec2 textureSize;
314 varying vec2 fragmentTextureCoordinate;
318 vec4 color = VuoGlsl_sampleRect(texture, fragmentTextureCoordinate*textureSize);
320 VuoGlsl_discardInvisible(color.a);
321 gl_FragColor = color;
349 \n#include
"VuoGlslAlpha.glsl"
352 uniform sampler2DRect texture;
353 uniform vec2 textureSize;
354 varying vec2 fragmentTextureCoordinate;
358 vec4 color = VuoGlsl_sampleRect(texture, fragmentTextureCoordinate*textureSize);
359 VuoGlsl_discardInvisible(color.a);
360 gl_FragColor = color;
365 \n#include
"VuoGlslAlpha.glsl"
368 uniform sampler2DRect texture;
369 uniform vec2 textureSize;
370 varying vec2 fragmentTextureCoordinate;
374 vec4 color = VuoGlsl_sampleRect(texture, vec2(fragmentTextureCoordinate.x, 1. - fragmentTextureCoordinate.y) * textureSize);
375 VuoGlsl_discardInvisible(color.a);
376 gl_FragColor = color;
398 \n#include
"VuoGlslProjection.glsl"
401 uniform mat4 modelviewMatrix;
402 attribute vec3 position;
403 attribute vec4 vertexColor;
404 uniform
bool hasVertexColors;
407 varying vec3 fragmentPosition;
408 varying vec3 fragmentNormal;
409 varying vec2 fragmentTextureCoordinate;
410 varying vec4 fragmentVertexColor;
414 gl_Position = VuoGlsl_projectPosition(modelviewMatrix * vec4(position, 1.));
415 fragmentVertexColor = hasVertexColors ? vertexColor : vec4(1.);
427 varying vec4 fragmentVertexColor;
431 gl_FragColor = color * fragmentVertexColor;
440 varying vec3 fragmentPosition;
441 varying vec3 fragmentNormal;
442 varying vec2 fragmentTextureCoordinate;
443 varying vec4 fragmentVertexColor;
449 fragmentTextureCoordinate;
451 gl_FragColor = color * fragmentVertexColor;
487 uniform
float sharpness;
488 varying vec2 fragmentTextureCoordinate;
492 float dist = distance(fragmentTextureCoordinate, vec2(0.5,0.5));
493 float delta = fwidth(dist);
494 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness/2 - delta, 1 - sharpness/2 + delta, dist*2));
499 shader->objectScale = 0.5;
523 const char *fragmentShaderSource =
"#version 120 \n\
524 varying vec2 fragmentTextureCoordinate;\
526 uniform vec4 lineColor;\
527 uniform float thickness;\
528 const int CHECK_VERTICES = 6;\
529 const vec2 CHECK[CHECK_VERTICES] = vec2[] (\
538 bool doLineSegmentsIntersect(vec2 p0, vec2 p1, vec2 p2, vec2 p3)\
543 s = (-s1.y * (p0.x - p2.x) + s1.x * (p0.y - p2.y)) / (-s2.x * s1.y + s1.x * s2.y);\
544 t = ( s2.x * (p0.y - p2.y) - s2.y * (p0.x - p2.x)) / (-s2.x * s1.y + s1.x * s2.y);\
546 return (s >= 0 && s <= 1 && t >= 0 && t <= 1);\
549 float drawLine(vec2 p1, vec2 p2)\
551 vec2 uv = fragmentTextureCoordinate;\
552 float a = abs(distance(p1, uv));\
553 float b = abs(distance(p2, uv));\
554 float c = abs(distance(p1, p2));\
555 if( a >= c || b >= c) return 0.;\
556 float p = (a + b + c) * .5;\
557 float h = 2. / c * sqrt(p * (p-a) * (p-b) * (p-c));\
558 return mix(1, 0, smoothstep(0.5 * thickness, 1.5 * thickness, h));\
561 bool isPointInPolygon(vec2 point)\
563 vec2 rayStart = vec2(0, .5);\
564 bool inPoly = false;\
566 for(int i = 0; i < CHECK_VERTICES; i += 1)\
568 if(doLineSegmentsIntersect(rayStart, point, CHECK[i], CHECK[i == (CHECK_VERTICES-1) ? 0 : i+1]) )\
578 for(int i = 0; i < CHECK_VERTICES; i++)\
579 line = max(drawLine(CHECK[i], CHECK[i < CHECK_VERTICES-1 ? i+1 : 0]), line);\
580 gl_FragColor = mix(isPointInPolygon(fragmentTextureCoordinate) ? color : vec4(0), lineColor, line);\
585 shader->objectScale = 1;
609 uniform
float sharpness;
610 uniform
float roundness;
611 uniform
float aspect;
612 varying vec2 fragmentTextureCoordinate;
616 float roundness2 = max(1. - sharpness, roundness);
617 roundness2 = min(aspect, roundness2);
618 float diameter = roundness2 / 2.;
619 diameter = max(diameter, 0.001);
620 float radius = diameter / 2.;
621 vec2 r = vec2(radius/aspect, radius);
623 vec2 cornerCircleCenter = vec2(0.,0.);
624 if (fragmentTextureCoordinate.x > 0.75 - r.x)
626 if (fragmentTextureCoordinate.y > 0.75 - r.y)
628 cornerCircleCenter = vec2(0.75, 0.75) + vec2(-r.x, -r.y);
629 else if (fragmentTextureCoordinate.y < 0.25 + r.y)
631 cornerCircleCenter = vec2(0.75, 0.25) + vec2(-r.x, r.y);
633 else if (fragmentTextureCoordinate.x < 0.25 + r.x)
635 if (fragmentTextureCoordinate.y > 0.75 - r.y)
637 cornerCircleCenter = vec2(0.25, 0.75) + vec2( r.x, -r.y);
638 else if (fragmentTextureCoordinate.y < 0.25 + radius)
640 cornerCircleCenter = vec2(0.25, 0.25) + vec2( r.x, r.y);
644 if (cornerCircleCenter.x > 0.)
645 dist = distance((fragmentTextureCoordinate - cornerCircleCenter) * vec2(aspect, 1.) + cornerCircleCenter, cornerCircleCenter) / diameter;
648 float f = 1. - (1. - sharpness) * (1. - sharpness);
651 float n = (fragmentTextureCoordinate.x - 0.5) * f;
653 if (fragmentTextureCoordinate.y < 0.5 + n)
655 if (fragmentTextureCoordinate.y > 0.5 - n)
657 dist = (fragmentTextureCoordinate.x - (0.75 - r.x)) * aspect;
660 dist = (0.25 + r.y) - fragmentTextureCoordinate.y;
664 if (fragmentTextureCoordinate.y > 0.5 - n)
666 dist = fragmentTextureCoordinate.y - (0.75 - r.y);
669 dist = ((0.25 + r.x) - fragmentTextureCoordinate.x) * aspect;
676 float delta = fwidth(fragmentTextureCoordinate.y);
680 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness / 2. - delta, 1. - sharpness / 2. + delta, dist));
685 shader->objectScale = 0.5;
717 uniform vec4 backgroundColor;
718 uniform vec4 activeColor;
719 uniform
float sharpness;
720 uniform
float roundness;
721 uniform
float aspect;
722 uniform
float progress;
723 uniform
bool isHorizontal;
724 varying vec2 fragmentTextureCoordinate;
728 float roundness2 = max(1. - sharpness, roundness);
729 roundness2 = min(aspect, roundness2);
730 float diameter = roundness2 / 2.;
731 diameter = max(diameter, 0.001);
732 float radius = diameter / 2.;
733 vec2 r = vec2(radius/aspect, radius);
735 vec2 cornerCircleCenter = vec2(0.,0.);
736 if (fragmentTextureCoordinate.x > 0.75 - r.x)
738 if (fragmentTextureCoordinate.y > 0.75 - r.y)
740 cornerCircleCenter = vec2(0.75, 0.75) + vec2(-r.x, -r.y);
741 else if (fragmentTextureCoordinate.y < 0.25 + r.y)
743 cornerCircleCenter = vec2(0.75, 0.25) + vec2(-r.x, r.y);
745 else if (fragmentTextureCoordinate.x < 0.25 + r.x)
747 if (fragmentTextureCoordinate.y > 0.75 - r.y)
749 cornerCircleCenter = vec2(0.25, 0.75) + vec2( r.x, -r.y);
750 else if (fragmentTextureCoordinate.y < 0.25 + radius)
752 cornerCircleCenter = vec2(0.25, 0.25) + vec2( r.x, r.y);
756 if (cornerCircleCenter.x > 0.)
757 dist = distance((fragmentTextureCoordinate - cornerCircleCenter) * vec2(aspect, 1.) + cornerCircleCenter, cornerCircleCenter) / diameter;
760 float f = 1. - (1. - sharpness) * (1. - sharpness);
763 float n = (fragmentTextureCoordinate.x - 0.5) * f;
765 if (fragmentTextureCoordinate.y < 0.5 + n)
767 if (fragmentTextureCoordinate.y > 0.5 - n)
769 dist = (fragmentTextureCoordinate.x - (0.75 - r.x)) * aspect;
772 dist = (0.25 + r.y) - fragmentTextureCoordinate.y;
776 if (fragmentTextureCoordinate.y > 0.5 - n)
778 dist = fragmentTextureCoordinate.y - (0.75 - r.y);
781 dist = ((0.25 + r.x) - fragmentTextureCoordinate.x) * aspect;
787 float delta = fwidth(dist) / 2.;
793 float val = (isHorizontal ? fragmentTextureCoordinate.x : fragmentTextureCoordinate.y);
794 val = (
clamp(val, .25, .75) - .25) / .5;
795 vec4 color = val < progress ? activeColor : backgroundColor;
796 gl_FragColor =
mix(color, vec4(0.),
smoothstep(sharpness / 2. - delta, 1. - sharpness / 2. + delta, dist));
801 shader->objectScale = 0.5;
825 \n#include
"VuoGlslProjection.glsl"
828 uniform mat4 modelviewMatrix;
829 attribute vec3 position;
830 attribute vec3 normal;
831 attribute vec4 vertexColor;
832 uniform
bool hasVertexColors;
835 varying vec3 fragmentPosition;
836 varying vec3 fragmentNormal;
837 varying vec2 fragmentTextureCoordinate;
838 varying vec4 fragmentVertexColor;
842 fragmentTextureCoordinate;
844 fragmentPosition = (modelviewMatrix * vec4(position, 1.)).xyz;
845 fragmentNormal = (modelviewMatrix * vec4(normal, 0.)).xyz;
846 fragmentVertexColor = hasVertexColors ? vertexColor : vec4(1.);
847 gl_Position = VuoGlsl_projectPosition(fragmentPosition);
855 \n#include
"lighting.glsl"
858 uniform vec4 diffuseColor;
859 uniform vec4 specularColor;
860 uniform
float specularPower;
863 varying vec3 fragmentNormal;
864 varying vec2 fragmentTextureCoordinate;
865 varying vec4 fragmentVertexColor;
872 gl_FragColor = diffuseColor;
874 fragmentTextureCoordinate;
876 vec3 ambientContribution = vec3(0.);
877 vec3 diffuseContribution = vec3(0.);
878 vec3 specularContribution = vec3(0.);
880 calculateLighting(specularPower, fragmentNormal, ambientContribution, diffuseContribution, specularContribution);
882 ambientContribution *= diffuseColor.rgb * fragmentVertexColor.rgb;
883 diffuseContribution *= diffuseColor.rgb * fragmentVertexColor.rgb;
884 specularContribution *= specularColor.rgb * specularColor.a;
885 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, diffuseColor.a * fragmentVertexColor.a);
909 \n#include
"VuoGlslProjection.glsl"
912 uniform mat4 modelviewMatrix;
913 attribute vec3 position;
914 attribute vec3 normal;
915 attribute vec2 textureCoordinate;
916 attribute vec4 vertexColor;
917 uniform
bool hasVertexColors;
920 varying vec3 fragmentPosition;
921 varying vec3 fragmentNormal;
922 varying vec2 fragmentTextureCoordinate;
923 varying vec4 fragmentVertexColor;
927 fragmentPosition = (modelviewMatrix * vec4(position, 1.)).xyz;
928 fragmentNormal = normalize(vec3(modelviewMatrix * vec4(normal, 0.)));
929 fragmentTextureCoordinate = textureCoordinate;
930 fragmentVertexColor = hasVertexColors ? vertexColor : vec4(1.);
931 gl_Position = VuoGlsl_projectPosition(fragmentPosition);
939 \n#include
"VuoGlslProjection.glsl"
942 uniform mat4 modelviewMatrix;
943 attribute vec3 position;
944 attribute vec3 normal;
945 attribute vec2 textureCoordinate;
946 attribute vec4 vertexColor;
947 uniform
bool hasVertexColors;
950 varying vec3 geometryPosition;
951 varying vec3 geometryNormal;
952 varying vec2 geometryTextureCoordinate;
953 varying vec4 geometryVertexColor;
957 geometryPosition = (modelviewMatrix * vec4(position, 1.)).xyz;
958 geometryNormal = normalize((modelviewMatrix * vec4(normal, 0.)).xyz);
959 geometryTextureCoordinate = textureCoordinate;
960 geometryVertexColor = hasVertexColors ? vertexColor : vec4(1.);
961 gl_Position = VuoGlsl_projectPosition(geometryPosition);
984 \n#include
"VuoGlslAlpha.glsl"
985 \n#include
"lighting.glsl"
988 varying vec3 fragmentNormal;
989 varying vec2 fragmentTextureCoordinate;
990 varying vec4 fragmentVertexColor;
993 uniform sampler2D texture;
995 uniform vec4 specularColor;
996 uniform
float specularPower;
1003 gl_FragColor = specularColor;
1005 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate) * fragmentVertexColor;
1007 VuoGlsl_discardInvisible(color.a);
1009 vec3 ambientContribution = vec3(0.);
1010 vec3 diffuseContribution = vec3(0.);
1011 vec3 specularContribution = vec3(0.);
1013 calculateLighting(specularPower, fragmentNormal, ambientContribution, diffuseContribution, specularContribution);
1015 ambientContribution *= color.rgb;
1016 diffuseContribution *= color.rgb;
1017 specularContribution *= specularColor.rgb * specularColor.a;
1018 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, color.a);
1052 if (!image || !specularImage || !normalImage)
1055 const char *pointGeometryShaderSource =
VUOSHADER_GLSL_SOURCE(120, \n#include
"trianglePoint.glsl");
1059 \n#include
"VuoGlslTangent.glsl"
1061 uniform mat4 modelviewMatrix;
1064 varying in vec3 geometryPosition[3];
1065 varying in vec3 geometryNormal[3];
1066 varying in vec2 geometryTextureCoordinate[3];
1067 varying in vec4 geometryVertexColor[3];
1070 varying out vec3 fragmentPosition;
1071 varying out vec2 fragmentTextureCoordinate;
1072 varying out vec4 fragmentVertexColor;
1073 varying out mat3 vertexPlaneToWorld;
1077 VuoGlslTangent_In ti;
1078 for (
int i = 0; i < 3; ++i)
1080 ti.position[i] = geometryPosition[i];
1081 ti.normal[i] = geometryNormal[i];
1082 ti.textureCoordinate[i] = geometryTextureCoordinate[i];
1084 VuoGlslTangent_Out to;
1085 VuoGlsl_calculateTangent(ti, to);
1087 for (
int i = 0; i < 3; ++i)
1089 gl_Position = gl_PositionIn[i];
1090 fragmentPosition = geometryPosition[i];
1091 fragmentTextureCoordinate = geometryTextureCoordinate[i];
1092 fragmentVertexColor = geometryVertexColor[i];
1094 vertexPlaneToWorld[0] = normalize(vec3(modelviewMatrix * vec4(to.tangent[i], 0.)));
1095 vertexPlaneToWorld[1] = normalize(vec3(modelviewMatrix * -vec4(to.bitangent[i], 0.)));
1096 vertexPlaneToWorld[2] = normalize(vec3(modelviewMatrix * vec4(geometryNormal[i], 0.)));
1105 \n#include
"VuoGlslAlpha.glsl"
1106 \n#include
"lighting.glsl"
1109 varying vec2 fragmentTextureCoordinate;
1110 varying vec4 fragmentVertexColor;
1111 varying mat3 vertexPlaneToWorld;
1114 uniform sampler2D texture;
1115 uniform
float alpha;
1116 uniform sampler2D specularImage;
1117 uniform sampler2D normalImage;
1125 gl_FragColor = blah;
1127 vec4 color = VuoGlsl_sample(texture, fragmentTextureCoordinate);
1129 VuoGlsl_discardInvisible(color.a);
1131 vec3 ambientContribution = vec3(0.);
1132 vec3 diffuseContribution = vec3(0.);
1133 vec3 specularContribution = vec3(0.);
1135 vec4 specularColor = texture2D(specularImage, fragmentTextureCoordinate);
1136 float specularPower = 1./(1.0001-specularColor.a);
1138 vec4 normalColor = texture2D(normalImage, fragmentTextureCoordinate);
1139 vec3 normal = normalize(vec3(
1140 2. * normalColor.r - 1.,
1141 2. * normalColor.g - 1.,
1145 vec3 normalDirection = vertexPlaneToWorld * normal;
1147 calculateLighting(specularPower, normalDirection, ambientContribution, diffuseContribution, specularContribution);
1149 ambientContribution *= color.rgb * fragmentVertexColor.rgb;
1150 diffuseContribution *= color.rgb * fragmentVertexColor.rgb;
1151 specularContribution *= specularColor.rgb * specularColor.a;
1152 gl_FragColor = vec4(ambientContribution + diffuseContribution + specularContribution, color.a * fragmentVertexColor.a);
1183 \n#include
"VuoGlslAlpha.glsl"
1184 \n#include
"VuoGlslRandom.glsl"
1186 uniform
float inputColorCount;
1187 uniform
float stripColorCount;
1188 uniform sampler2D gradientStrip;
1191 uniform
float aspect;
1192 uniform
float noiseAmount;
1194 varying vec2 fragmentTextureCoordinate;
1196 float distSqr(vec2 a, vec2 b)
1198 return (b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y);
1203 vec2 nearest_point_on_line(vec2 v, vec2 w, vec2 p)
1206 float l2 = distSqr(v, w);
1207 if (l2 == 0.0)
return p;
1211 float t = dot(p - v, w - v) / l2;
1212 vec2 projection = v + t * (w - v);
1218 vec2 tcAspect = fragmentTextureCoordinate;
1220 tcAspect.y *= aspect;
1223 vec2 pol = nearest_point_on_line(start, end, tcAspect);
1224 float x = dot(pol-start, end-start) > 0 ? distance(start, pol)/ distance(start, end) : 0;
1227 x *= inputColorCount - 1.;
1229 x /= inputColorCount - 1.;
1231 float gradientWidth = (1./stripColorCount)/2.;
1232 x = x * (1-gradientWidth*2) + gradientWidth;
1234 vec4 color = VuoGlsl_sample(gradientStrip, vec2(
clamp(x , gradientWidth, 1.-gradientWidth), .5));
1235 VuoGlsl_discardInvisible(color.a);
1237 color.rgb += (VuoGlsl_random2D3D(fragmentTextureCoordinate) - 0.5) * noiseAmount;
1239 gl_FragColor = color;
1260 int gradientExpansion = 16;
1262 GLenum format = GL_BGRA;
1271 int stripColorCount = (inputColorCount - 1) * gradientExpansion + 1;
1273 unsigned char *pixels = (
unsigned char*)malloc(stripColorCount * bpp);
1276 for (
int i = 0; i < stripColorCount; ++i)
1290 if (
step >= gradientExpansion)
1325 \n#include
"VuoGlslAlpha.glsl"
1326 \n#include
"VuoGlslRandom.glsl"
1328 uniform
float inputColorCount;
1329 uniform
float stripColorCount;
1330 uniform sampler2D gradientStrip;
1331 uniform vec2 center;
1333 uniform
float radius;
1334 uniform
float noiseAmount;
1336 varying vec2 fragmentTextureCoordinate;
1340 vec2 scaledTexCoord = fragmentTextureCoordinate*scale;
1341 float x = distance(center*scale, scaledTexCoord)/radius;
1344 x *= inputColorCount - 1.;
1346 x /= inputColorCount - 1.;
1348 float gradientWidth = (1./stripColorCount)/2.;
1349 x = x * (1-gradientWidth*2) + gradientWidth;
1351 vec4 color = VuoGlsl_sample(gradientStrip, vec2(
clamp(x , gradientWidth, 1.-gradientWidth), .5));
1352 VuoGlsl_discardInvisible(color.a);
1354 color.rgb += (VuoGlsl_random2D3D(fragmentTextureCoordinate) - 0.5) * noiseAmount;
1356 gl_FragColor = color;
1388 \n#include
"VuoGlslProjection.glsl"
1391 uniform mat4 modelviewMatrix;
1392 attribute vec3 position;
1393 attribute vec3 normal;
1394 attribute vec2 textureCoordinate;
1395 attribute vec4 vertexColor;
1396 uniform
bool hasVertexColors;
1399 varying vec3 geometryPosition;
1400 varying vec3 geometryNormal;
1401 varying vec2 geometryTextureCoordinate;
1402 varying vec4 geometryVertexColor;
1406 geometryPosition = (modelviewMatrix * vec4(position, 1.)).xyz;
1407 geometryNormal = (modelviewMatrix * vec4(normal, 0.)).xyz;
1408 geometryTextureCoordinate = textureCoordinate;
1409 geometryVertexColor = hasVertexColors ? vertexColor : vec4(1.);
1410 gl_Position = VuoGlsl_projectPosition(geometryPosition);
1414 const char *pointGeometryShaderSource =
VUOSHADER_GLSL_SOURCE(120, \n#include
"trianglePoint.glsl");
1418 \n#include
"VuoGlslAlpha.glsl"
1419 \n#include
"noise3D.glsl"
1422 uniform sampler2D colorBuffer;
1423 uniform vec2 viewportSize;
1427 uniform
float aspectRatio;
1428 uniform vec2 noisePosition;
1429 uniform
float noiseTime;
1430 uniform
float noiseAmount;
1431 uniform
float noiseScale;
1432 uniform
float chromaticAberration;
1433 uniform
int iterations;
1435 uniform
float roughness;
1436 uniform
float spacing;
1439 varying vec2 fragmentTextureCoordinate;
1440 varying vec4 fragmentVertexColor;
1444 vec2 viewportTextureCoordinate = gl_FragCoord.xy/viewportSize;
1446 vec4 accumulatedColor = vec4(0.);
1447 for (
int i = 0; i < iterations; ++i)
1451 vec3 noiseCoordinate = vec3(fragmentTextureCoordinate.x - .5 - noisePosition.x +
float(i), (fragmentTextureCoordinate.y - .5 - noisePosition.y) / aspectRatio, noiseTime);
1452 noiseCoordinate.xy *= noiseScale;
1453 vec2 noiseOffset = snoise3D2DFractal(noiseCoordinate, levels, roughness, spacing);
1456 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. - chromaticAberration/3.)) * vec4(1.,0.,0.,1./3.);
1459 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount) * vec4(0.,1.,0.,1./3.);
1462 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. + chromaticAberration/3.)) * vec4(0.,0.,1.,1./3.);
1465 vec4 c = accumulatedColor / float(iterations);
1467 c *= color * fragmentVertexColor;
1468 c.rgb =
clamp(c.rgb, 0., 1.);
1475 \n#include
"VuoGlslAlpha.glsl"
1476 \n#include
"noise3D.glsl"
1479 uniform sampler2D colorBuffer;
1480 uniform vec2 viewportSize;
1484 uniform
float aspectRatio;
1485 uniform vec2 noisePosition;
1486 uniform
float noiseTime;
1487 uniform
float noiseAmount;
1488 uniform
float noiseScale;
1489 uniform
float chromaticAberration;
1490 uniform
int iterations;
1492 uniform
float roughness;
1493 uniform
float spacing;
1496 varying vec3 fragmentPosition;
1497 varying vec2 fragmentTextureCoordinate;
1504 gl_FragColor = color;
1508 vec2 viewportTextureCoordinate = gl_FragCoord.xy/viewportSize;
1510 vec4 accumulatedColor = vec4(0.);
1511 for (
int i = 0; i < iterations; ++i)
1515 vec3 noiseCoordinate = vec3(fragmentTextureCoordinate.x - .5 - noisePosition.x +
float(i), (fragmentTextureCoordinate.y - .5 - noisePosition.y) / aspectRatio, noiseTime);
1516 noiseCoordinate.xy *= noiseScale;
1517 vec2 noiseOffset = snoise3D2DFractal(noiseCoordinate, levels, roughness, spacing);
1520 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. - chromaticAberration/3.)) * vec4(1.,0.,0.,1./3.);
1523 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount) * vec4(0.,1.,0.,1./3.);
1526 accumulatedColor += VuoGlsl_sample(colorBuffer, viewportTextureCoordinate + noiseOffset * noiseAmount * (1. + chromaticAberration/3.)) * vec4(0.,0.,1.,1./3.);
1529 vec4 c = accumulatedColor / float(iterations);
1532 c.rgb =
clamp(c.rgb, 0., 1.);
1539 s->isTransparent =
true;
1557 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)
1561 (noisePosition.y+1)/2 * aspectRatio});