4 // - implement texture1D, texture2D, texture3D, textureCube,
5 // - implement shadow1D, shadow2D,
6 // - implement noise1, noise2, noise3, noise4,
10 // From Shader Spec, ver. 1.10, rev. 59
13 const int gl_MaxLights = 8;
14 const int gl_MaxClipPlanes = 6;
15 const int gl_MaxTextureUnits = 8;
16 const int gl_MaxTextureCoords = 8;
17 const int gl_MaxVertexAttribs = 16;
18 const int gl_MaxVertexUniformComponents = 512;
19 const int gl_MaxVaryingFloats = 32;
20 const int gl_MaxVertexTextureImageUnits = 0;
21 const int gl_MaxCombinedTextureImageUnits = 2;
22 const int gl_MaxTextureImageUnits = 2;
23 const int gl_MaxFragmentUniformComponents = 64;
24 const int gl_MaxDrawBuffers = 1;
26 uniform mat4 gl_ModelViewMatrix;
27 uniform mat4 gl_ProjectionMatrix;
28 uniform mat4 gl_ModelViewProjectionMatrix;
29 uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
31 uniform mat3 gl_NormalMatrix;
33 uniform mat4 gl_ModelViewMatrixInverse;
34 uniform mat4 gl_ProjectionMatrixInverse;
35 uniform mat4 gl_ModelViewProjectionMatrixInverse;
36 uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];
38 uniform mat4 gl_ModelViewMatrixTranspose;
39 uniform mat4 gl_ProjectionMatrixTranspose;
40 uniform mat4 gl_ModelViewProjectionMatrixTranspose;
41 uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];
43 uniform mat4 gl_ModelViewMatrixInverseTranspose;
44 uniform mat4 gl_ProjectionMatrixInverseTranspose;
45 uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;
46 uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];
48 uniform float gl_NormalScale;
50 struct gl_DepthRangeParameters {
56 uniform gl_DepthRangeParameters gl_DepthRange;
58 uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
60 struct gl_PointParameters {
64 float fadeThresholdSize;
65 float distanceConstantAttenuation;
66 float distanceLinearAttenuation;
67 float distanceQuadraticAttenuation;
70 uniform gl_PointParameters gl_Point;
72 struct gl_MaterialParameters {
80 uniform gl_MaterialParameters gl_FrontMaterial;
81 uniform gl_MaterialParameters gl_BackMaterial;
83 struct gl_LightSourceParameters {
93 float constantAttenuation;
94 float linearAttenuation;
95 float quadraticAttenuation;
98 uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
100 struct gl_LightModelParameters {
104 uniform gl_LightModelParameters gl_LightModel;
106 struct gl_LightModelProducts {
110 uniform gl_LightModelProducts gl_FrontLightModelProduct;
111 uniform gl_LightModelProducts gl_BackLightModelProduct;
113 struct gl_LightProducts {
119 uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
120 uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
122 uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];
123 uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
124 uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
125 uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
126 uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
127 uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
128 uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
129 uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
130 uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
132 struct gl_FogParameters {
140 uniform gl_FogParameters gl_Fog;
143 // 8.1 Angle and Trigonometry Functions
146 float radians (float deg) {
147 return 3.141593 * deg / 180.0;
150 vec2 radians (vec2 deg) {
151 return vec2 (3.141593) * deg / vec2 (180.0);
154 vec3 radians (vec3 deg) {
155 return vec3 (3.141593) * deg / vec3 (180.0);
158 vec4 radians (vec4 deg) {
159 return vec4 (3.141593) * deg / vec4 (180.0);
162 float degrees (float rad) {
163 return 180.0 * rad / 3.141593;
166 vec2 degrees (vec2 rad) {
167 return vec2 (180.0) * rad / vec2 (3.141593);
170 vec3 degrees (vec3 rad) {
171 return vec3 (180.0) * rad / vec3 (3.141593);
174 vec4 degrees (vec4 rad) {
175 return vec4 (180.0) * rad / vec4 (3.141593);
178 float sin (float angle) {
180 __asm float_sine x, angle;
184 vec2 sin (vec2 angle) {
191 vec3 sin (vec3 angle) {
199 vec4 sin (vec4 angle) {
208 float cos (float angle) {
209 return sin (angle + 1.5708);
212 vec2 cos (vec2 angle) {
219 vec3 cos (vec3 angle) {
227 vec4 cos (vec4 angle) {
236 float tan (float angle) {
237 return sin (angle) / cos (angle);
240 vec2 tan (vec2 angle) {
247 vec3 tan (vec3 angle) {
255 vec4 tan (vec4 angle) {
264 float asin (float x) {
266 __asm float_arcsine y, x;
294 float acos (float x) {
295 return 1.5708 - asin (x);
322 float atan (float y_over_x) {
324 __asm float_arctan z, y_over_x;
328 vec2 atan (vec2 y_over_x) {
330 u.x = atan (y_over_x.x);
331 u.y = atan (y_over_x.y);
335 vec3 atan (vec3 y_over_x) {
337 u.x = atan (y_over_x.x);
338 u.y = atan (y_over_x.y);
339 u.z = atan (y_over_x.z);
343 vec4 atan (vec4 y_over_x) {
345 u.x = atan (y_over_x.x);
346 u.y = atan (y_over_x.y);
347 u.z = atan (y_over_x.z);
348 u.w = atan (y_over_x.w);
352 float atan (float y, float x) {
364 vec2 atan (vec2 u, vec2 v) {
366 t.x = atan (u.x, v.x);
367 t.y = atan (u.y, v.y);
371 vec3 atan (vec3 u, vec3 v) {
373 t.x = atan (u.x, v.x);
374 t.y = atan (u.y, v.y);
375 t.z = atan (u.z, v.z);
379 vec4 atan (vec4 u, vec4 v) {
381 t.x = atan (u.x, v.x);
382 t.y = atan (u.y, v.y);
383 t.z = atan (u.z, v.z);
384 t.w = atan (u.w, v.w);
389 // 8.2 Exponential Functions
392 float pow (float x, float y) {
394 __asm float_power p, x, y;
398 vec2 pow (vec2 v, vec2 u) {
400 t.x = pow (v.x, u.x);
401 t.y = pow (v.y, u.y);
405 vec3 pow (vec3 v, vec3 u) {
407 t.x = pow (v.x, u.x);
408 t.y = pow (v.y, u.y);
409 t.z = pow (v.z, u.z);
413 vec4 pow (vec4 v, vec4 u) {
415 t.x = pow (v.x, u.x);
416 t.y = pow (v.y, u.y);
417 t.z = pow (v.z, u.z);
418 t.w = pow (v.w, u.w);
422 float exp (float x) {
423 return pow (2.71828183, x);
427 return pow (vec2 (2.71828183), v);
431 return pow (vec3 (2.71828183), v);
435 return pow (vec4 (2.71828183), v);
438 float log2 (float x) {
440 __asm float_log2 y, x;
468 float log (float x) {
469 return log2 (x) / log2 (2.71828183);
473 return log2 (v) / log2 (vec2 (2.71828183));
477 return log2 (v) / log2 (vec3 (2.71828183));
481 return log2 (v) / log2 (vec4 (2.71828183));
484 float exp2 (float x) {
489 return pow (vec2 (2.0), v);
493 return pow (vec3 (2.0), v);
497 return pow (vec4 (2.0), v);
500 float sqrt (float x) {
505 return pow (v, vec2 (0.5));
509 return pow (v, vec3 (0.5));
513 return pow (v, vec4 (0.5));
516 float inversesqrt (float x) {
517 return 1.0 / sqrt (x);
520 vec2 inversesqrt (vec2 v) {
521 return vec2 (1.0) / sqrt (v);
524 vec3 inversesqrt (vec3 v) {
525 return vec3 (1.0) / sqrt (v);
528 vec4 inversesqrt (vec4 v) {
529 return vec4 (1.0) / sqrt (v);
533 // 8.3 Common Functions
536 float abs (float x) {
537 return x >= 0.0 ? x : -x;
564 float sign (float x) {
565 return x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0;
592 float floor (float x) {
594 __asm float_floor y, x;
598 vec2 floor (vec2 v) {
605 vec3 floor (vec3 v) {
613 vec4 floor (vec4 v) {
622 float ceil (float x) {
624 __asm float_ceil y, x;
652 float fract (float x) {
653 return x - floor (x);
656 vec2 fract (vec2 v) {
657 return v - floor (v);
660 vec3 fract (vec3 v) {
661 return v - floor (v);
664 vec4 fract (vec4 v) {
665 return v - floor (v);
668 float mod (float x, float y) {
669 return x - y * floor (x / y);
672 vec2 mod (vec2 v, float u) {
673 return v - u * floor (v / u);
676 vec3 mod (vec3 v, float u) {
677 return v - u * floor (v / u);
680 vec4 mod (vec4 v, float u) {
681 return v - u * floor (v / u);
684 vec2 mod (vec2 v, vec2 u) {
685 return v - u * floor (v / u);
688 vec3 mod (vec3 v, vec3 u) {
689 return v - u * floor (v / u);
692 vec4 mod (vec4 v, vec4 u) {
693 return v - u * floor (v / u);
696 float min (float x, float y) {
697 return x < y ? x : y;
700 vec2 min (vec2 v, vec2 u) {
702 t.x = min (v.x, u.x);
703 t.y = min (v.y, u.y);
707 vec3 min (vec3 v, vec3 u) {
709 t.x = min (v.x, u.x);
710 t.y = min (v.y, u.y);
711 t.z = min (v.z, u.z);
715 vec4 min (vec4 v, vec4 u) {
717 t.x = min (v.x, u.x);
718 t.y = min (v.y, u.y);
719 t.z = min (v.z, u.z);
720 t.w = min (v.w, u.w);
724 vec2 min (vec2 v, float y) {
725 return min (v, vec2 (y));
728 vec3 min (vec3 v, float y) {
729 return min (v, vec3 (y));
732 vec4 min (vec4 v, float y) {
733 return min (v, vec4 (y));
736 float max (float x, float y) {
737 return x < y ? y : x;
740 vec2 max (vec2 v, vec2 u) {
742 t.x = max (v.x, u.x);
743 t.y = max (v.y, u.y);
747 vec3 max (vec3 v, vec3 u) {
749 t.x = max (v.x, u.x);
750 t.y = max (v.y, u.y);
751 t.z = max (v.z, u.z);
755 vec4 max (vec4 v, vec4 u) {
757 t.x = max (v.x, u.x);
758 t.y = max (v.y, u.y);
759 t.z = max (v.z, u.z);
760 t.w = max (v.w, u.w);
764 vec2 max (vec2 v, float y) {
765 return max (v, vec2 (y));
768 vec3 max (vec3 v, float y) {
769 return max (v, vec3 (y));
772 vec4 max (vec4 v, float y) {
773 return max (v, vec4 (y));
776 float clamp (float x, float minVal, float maxVal) {
777 return min (max (x, minVal), maxVal);
780 vec2 clamp (vec2 x, float minVal, float maxVal) {
781 return min (max (x, minVal), maxVal);
784 vec3 clamp (vec3 x, float minVal, float maxVal) {
785 return min (max (x, minVal), maxVal);
788 vec4 clamp (vec4 x, float minVal, float maxVal) {
789 return min (max (x, minVal), maxVal);
792 vec2 clamp (vec2 x, vec2 minVal, vec2 maxVal) {
793 return min (max (x, minVal), maxVal);
796 vec3 clamp (vec3 x, vec3 minVal, vec3 maxVal) {
797 return min (max (x, minVal), maxVal);
800 vec4 clamp (vec4 x, vec4 minVal, vec4 maxVal) {
801 return min (max (x, minVal), maxVal);
804 float mix (float x, float y, float a) {
805 return x * (1.0 - a) + y * a;
808 vec2 mix (vec2 x, vec2 y, float a) {
809 return x * (1.0 - a) + y * a;
812 vec3 mix (vec3 x, vec3 y, float a) {
813 return x * (1.0 - a) + y * a;
816 vec4 mix (vec4 x, vec4 y, float a) {
817 return x * (1.0 - a) + y * a;
820 vec2 mix (vec2 x, vec2 y, vec2 a) {
821 return x * (1.0 - a) + y * a;
824 vec3 mix (vec3 x, vec3 y, vec3 a) {
825 return x * (1.0 - a) + y * a;
828 vec4 mix (vec4 x, vec4 y, vec4 a) {
829 return x * (1.0 - a) + y * a;
832 float step (float edge, float x) {
833 return x < edge ? 0.0 : 1.0;
836 vec2 step (vec2 edge, vec2 v) {
838 u.x = step (edge.x, v.x);
839 u.y = step (edge.y, v.y);
843 vec3 step (vec3 edge, vec3 v) {
845 u.x = step (edge.x, v.x);
846 u.y = step (edge.y, v.y);
847 u.z = step (edge.z, v.z);
851 vec4 step (vec4 edge, vec4 v) {
853 u.x = step (edge.x, v.x);
854 u.y = step (edge.y, v.y);
855 u.z = step (edge.z, v.z);
856 u.w = step (edge.w, v.w);
860 vec2 step (float edge, vec2 v) {
861 return step (vec2 (edge), v);
864 vec3 step (float edge, vec3 v) {
865 return step (vec3 (edge), v);
868 vec4 step (float edge, vec4 v) {
869 return step (vec4 (edge), v);
872 float smoothstep (float edge0, float edge1, float x) {
874 t = clamp ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
875 return t * t * (3.0 - 2.0 * t);
878 vec2 smoothstep (vec2 edge0, vec2 edge1, vec2 v) {
880 u.x = smoothstep (edge0.x, edge1.x, v.x);
881 u.y = smoothstep (edge0.y, edge1.y, v.y);
885 vec3 smoothstep (vec3 edge0, vec3 edge1, vec3 v) {
887 u.x = smoothstep (edge0.x, edge1.x, v.x);
888 u.y = smoothstep (edge0.y, edge1.y, v.y);
889 u.z = smoothstep (edge0.z, edge1.z, v.z);
893 vec4 smoothstep (vec4 edge0, vec4 edge1, vec4 v) {
895 u.x = smoothstep (edge0.x, edge1.x, v.x);
896 u.y = smoothstep (edge0.y, edge1.y, v.y);
897 u.z = smoothstep (edge0.z, edge1.z, v.z);
898 u.w = smoothstep (edge0.w, edge1.w, v.w);
902 vec2 smoothstep (float edge0, float edge1, vec2 v) {
904 u.x = smoothstep (edge0, edge1, v.x);
905 u.y = smoothstep (edge0, edge1, v.y);
909 vec3 smoothstep (float edge0, float edge1, vec3 v) {
911 u.x = smoothstep (edge0, edge1, v.x);
912 u.y = smoothstep (edge0, edge1, v.y);
913 u.z = smoothstep (edge0, edge1, v.z);
917 vec4 smoothstep (float edge0, float edge1, vec4 v) {
919 u.x = smoothstep (edge0, edge1, v.x);
920 u.y = smoothstep (edge0, edge1, v.y);
921 u.z = smoothstep (edge0, edge1, v.z);
922 u.w = smoothstep (edge0, edge1, v.w);
927 // 8.4 Geometric Functions
930 float dot (float x, float y) {
934 float dot (vec2 v, vec2 u) {
935 return v.x * u.x + v.y * u.y;
938 float dot (vec3 v, vec3 u) {
939 return v.x * u.x + v.y * u.y + v.z * u.z;
942 float dot (vec4 v, vec4 u) {
943 return v.x * u.x + v.y * u.y + v.z * u.z + v.w * u.w;
946 float length (float x) {
947 return sqrt (dot (x, x));
950 float length (vec2 v) {
951 return sqrt (dot (v, v));
954 float length (vec3 v) {
955 return sqrt (dot (v, v));
958 float length (vec4 v) {
959 return sqrt (dot (v, v));
962 float distance (float x, float y) {
963 return length (x - y);
966 float distance (vec2 v, vec2 u) {
967 return length (v - u);
970 float distance (vec3 v, vec3 u) {
971 return length (v - u);
974 float distance (vec4 v, vec4 u) {
975 return length (v - u);
978 vec3 cross (vec3 v, vec3 u) {
980 t.x = v.y * u.z - u.y * v.z;
981 t.y = v.z * u.x - u.z * v.x;
982 t.z = v.x * u.y - u.x * v.y;
986 float normalize (float x) {
990 vec2 normalize (vec2 v) {
991 return v / length (v);
994 vec3 normalize (vec3 v) {
995 return v / length (v);
998 vec4 normalize (vec4 v) {
999 return v / length (v);
1002 float faceforward (float N, float I, float Nref) {
1003 return dot (Nref, I) < 0.0 ? N : -N;
1006 vec2 faceforward (vec2 N, vec2 I, vec2 Nref) {
1007 return dot (Nref, I) < 0.0 ? N : -N;
1010 vec3 faceforward (vec3 N, vec3 I, vec3 Nref) {
1011 return dot (Nref, I) < 0.0 ? N : -N;
1014 vec4 faceforward (vec4 N, vec4 I, vec4 Nref) {
1015 return dot (Nref, I) < 0.0 ? N : -N;
1018 float reflect (float I, float N) {
1019 return I - 2.0 * dot (N, I) * N;
1022 vec2 reflect (vec2 I, vec2 N) {
1023 return I - 2.0 * dot (N, I) * N;
1026 vec3 reflect (vec3 I, vec3 N) {
1027 return I - 2.0 * dot (N, I) * N;
1030 vec4 reflect (vec4 I, vec4 N) {
1031 return I - 2.0 * dot (N, I) * N;
1034 float refract (float I, float N, float eta) {
1036 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1039 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1042 vec2 refract (vec2 I, vec2 N, float eta) {
1044 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1047 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1050 vec3 refract (vec3 I, vec3 N, float eta) {
1052 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1055 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1058 vec4 refract (vec4 I, vec4 N, float eta) {
1060 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1063 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1067 // 8.5 Matrix Functions
1070 mat2 matrixCompMult (mat2 m, mat2 n) {
1077 mat3 matrixCompMult (mat3 m, mat3 n) {
1085 mat4 matrixCompMult (mat4 m, mat4 n) {
1095 // 8.6 Vector Relational Functions
1098 bvec2 lessThan (vec2 v, vec2 u) {
1105 bvec3 lessThan (vec3 v, vec3 u) {
1113 bvec4 lessThan (vec4 v, vec4 u) {
1122 bvec2 lessThan (ivec2 v, ivec2 u) {
1129 bvec3 lessThan (ivec3 v, ivec3 u) {
1137 bvec4 lessThan (ivec4 v, ivec4 u) {
1146 bvec2 lessThanEqual (vec2 v, vec2 u) {
1153 bvec3 lessThanEqual (vec3 v, vec3 u) {
1161 bvec4 lessThanEqual (vec4 v, vec4 u) {
1170 bvec2 lessThanEqual (ivec2 v, ivec2 u) {
1177 bvec3 lessThanEqual (ivec3 v, ivec3 u) {
1185 bvec4 lessThanEqual (ivec4 v, ivec4 u) {
1194 bvec2 greaterThan (vec2 v, vec2 u) {
1201 bvec3 greaterThan (vec3 v, vec3 u) {
1209 bvec4 greaterThan (vec4 v, vec4 u) {
1218 bvec2 greaterThan (ivec2 v, ivec2 u) {
1225 bvec3 greaterThan (ivec3 v, ivec3 u) {
1233 bvec4 greaterThan (ivec4 v, ivec4 u) {
1242 bvec2 greaterThanEqual (vec2 v, vec2 u) {
1249 bvec3 greaterThanEqual (vec3 v, vec3 u) {
1257 bvec4 greaterThanEqual (vec4 v, vec4 u) {
1266 bvec2 greaterThanEqual (ivec2 v, ivec2 u) {
1273 bvec3 greaterThanEqual (ivec3 v, ivec3 u) {
1281 bvec4 greaterThanEqual (ivec4 v, ivec4 u) {
1290 bvec2 equal (vec2 v, vec2 u) {
1297 bvec3 equal (vec3 v, vec3 u) {
1305 bvec4 equal (vec4 v, vec4 u) {
1314 bvec2 equal (ivec2 v, ivec2 u) {
1321 bvec3 equal (ivec3 v, ivec3 u) {
1329 bvec4 equal (ivec4 v, ivec4 u) {
1338 bvec2 notEqual (vec2 v, vec2 u) {
1345 bvec3 notEqual (vec3 v, vec3 u) {
1353 bvec4 notEqual (vec4 v, vec4 u) {
1362 bvec2 notEqual (ivec2 v, ivec2 u) {
1369 bvec3 notEqual (ivec3 v, ivec3 u) {
1377 bvec4 notEqual (ivec4 v, ivec4 u) {
1386 bool any (bvec2 v) {
1390 bool any (bvec3 v) {
1391 return v.x || v.y || v.z;
1394 bool any (bvec4 v) {
1395 return v.x || v.y || v.z || v.w;
1398 bool all (bvec2 v) {
1402 bool all (bvec3 v) {
1403 return v.x && v.y && v.z;
1406 bool all (bvec4 v) {
1407 return v.x && v.y && v.z && v.w;
1410 bvec2 not (bvec2 v) {
1417 bvec3 not (bvec3 v) {
1425 bvec4 not (bvec4 v) {
1435 // 8.7 Texture Lookup Functions
1438 vec4 texture1D (sampler1D sampler, float coord) {
1443 vec4 texture1DProj (sampler1D sampler, vec2 coord) {
1444 return texture1D (sampler, coord.s / coord.t);
1447 vec4 texture1DProj (sampler1D sampler, vec4 coord) {
1448 return texture1D (sampler, coord.s / coord.q);
1451 vec4 texture2D (sampler2D sampler, vec2 coord) {
1456 vec4 texture2DProj (sampler2D sampler, vec3 coord) {
1458 u.s = coord.s / coord.p;
1459 u.t = coord.t / coord.p;
1460 return texture2D (sampler, u);
1463 vec4 texture2DProj (sampler2D sampler, vec4 coord) {
1465 u.s = coord.s / coord.q;
1466 u.t = coord.t / coord.q;
1467 return texture2D (sampler, u);
1470 vec4 texture3D (sampler3D sampler, vec3 coord) {
1475 vec4 texture3DProj (sampler3D sampler, vec4 coord) {
1477 u.s = coord.s / coord.q;
1478 u.t = coord.t / coord.q;
1479 u.p = coord.p / coord.q;
1480 return texture3D (sampler, u);
1483 vec4 textureCube (samplerCube sampler, vec3 coord) {
1488 vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {
1493 vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
1498 vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {
1500 u.s = coord.s / coord.q;
1502 u.p = coord.p / coord.q;
1503 return shadow1D (sampler, u);
1506 vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {
1508 u.s = coord.s / coord.q;
1509 u.t = coord.t / coord.q;
1510 u.p = coord.p / coord.q;
1511 return shadow2D (sampler, u);
1515 // 8.9 Noise Functions
1518 float noise1 (float x) {
1523 float noise1 (vec2 x) {
1528 float noise1 (vec3 x) {
1533 float noise1 (vec4 x) {
1538 vec2 noise2 (float x) {
1543 vec2 noise2 (vec2 x) {
1548 vec2 noise2 (vec3 x) {
1553 vec2 noise2 (vec4 x) {
1558 vec3 noise3 (float x) {
1563 vec3 noise3 (vec2 x) {
1568 vec3 noise3 (vec3 x) {
1573 vec3 noise3 (vec4 x) {
1578 vec4 noise4 (float x) {
1583 vec4 noise4 (vec2 x) {
1588 vec4 noise4 (vec3 x) {
1593 vec4 noise4 (vec4 x) {