4 // - implement texture1D, texture3D, textureCube,
5 // - implement shadow1D, shadow2D,
9 // From Shader Spec, ver. 1.10, rev. 59
12 const int gl_MaxLights = 8;
13 const int gl_MaxClipPlanes = 6;
14 const int gl_MaxTextureUnits = 8;
15 const int gl_MaxTextureCoords = 8;
16 const int gl_MaxVertexAttribs = 16;
17 const int gl_MaxVertexUniformComponents = 512;
18 const int gl_MaxVaryingFloats = 32;
19 const int gl_MaxVertexTextureImageUnits = 0;
20 const int gl_MaxCombinedTextureImageUnits = 2;
21 const int gl_MaxTextureImageUnits = 2;
22 const int gl_MaxFragmentUniformComponents = 64;
23 const int gl_MaxDrawBuffers = 1;
25 uniform mat4 gl_ModelViewMatrix;
26 uniform mat4 gl_ProjectionMatrix;
27 uniform mat4 gl_ModelViewProjectionMatrix;
28 uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
30 uniform mat3 gl_NormalMatrix;
32 uniform mat4 gl_ModelViewMatrixInverse;
33 uniform mat4 gl_ProjectionMatrixInverse;
34 uniform mat4 gl_ModelViewProjectionMatrixInverse;
35 uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];
37 uniform mat4 gl_ModelViewMatrixTranspose;
38 uniform mat4 gl_ProjectionMatrixTranspose;
39 uniform mat4 gl_ModelViewProjectionMatrixTranspose;
40 uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];
42 uniform mat4 gl_ModelViewMatrixInverseTranspose;
43 uniform mat4 gl_ProjectionMatrixInverseTranspose;
44 uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;
45 uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];
47 uniform float gl_NormalScale;
49 struct gl_DepthRangeParameters {
55 uniform gl_DepthRangeParameters gl_DepthRange;
57 uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
59 struct gl_PointParameters {
63 float fadeThresholdSize;
64 float distanceConstantAttenuation;
65 float distanceLinearAttenuation;
66 float distanceQuadraticAttenuation;
69 uniform gl_PointParameters gl_Point;
71 struct gl_MaterialParameters {
79 uniform gl_MaterialParameters gl_FrontMaterial;
80 uniform gl_MaterialParameters gl_BackMaterial;
82 struct gl_LightSourceParameters {
92 float constantAttenuation;
93 float linearAttenuation;
94 float quadraticAttenuation;
97 uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
99 struct gl_LightModelParameters {
103 uniform gl_LightModelParameters gl_LightModel;
105 struct gl_LightModelProducts {
109 uniform gl_LightModelProducts gl_FrontLightModelProduct;
110 uniform gl_LightModelProducts gl_BackLightModelProduct;
112 struct gl_LightProducts {
118 uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
119 uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
121 uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];
122 uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
123 uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
124 uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
125 uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
126 uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
127 uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
128 uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
129 uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
131 struct gl_FogParameters {
139 uniform gl_FogParameters gl_Fog;
142 // 8.1 Angle and Trigonometry Functions
145 float radians (float deg) {
146 return 3.141593 * deg / 180.0;
149 vec2 radians (vec2 deg) {
150 return vec2 (3.141593) * deg / vec2 (180.0);
153 vec3 radians (vec3 deg) {
154 return vec3 (3.141593) * deg / vec3 (180.0);
157 vec4 radians (vec4 deg) {
158 return vec4 (3.141593) * deg / vec4 (180.0);
161 float degrees (float rad) {
162 return 180.0 * rad / 3.141593;
165 vec2 degrees (vec2 rad) {
166 return vec2 (180.0) * rad / vec2 (3.141593);
169 vec3 degrees (vec3 rad) {
170 return vec3 (180.0) * rad / vec3 (3.141593);
173 vec4 degrees (vec4 rad) {
174 return vec4 (180.0) * rad / vec4 (3.141593);
177 float sin (float angle) {
179 __asm float_sine x, angle;
183 vec2 sin (vec2 angle) {
190 vec3 sin (vec3 angle) {
198 vec4 sin (vec4 angle) {
207 float cos (float angle) {
208 return sin (angle + 1.5708);
211 vec2 cos (vec2 angle) {
218 vec3 cos (vec3 angle) {
226 vec4 cos (vec4 angle) {
235 float tan (float angle) {
236 return sin (angle) / cos (angle);
239 vec2 tan (vec2 angle) {
246 vec3 tan (vec3 angle) {
254 vec4 tan (vec4 angle) {
263 float asin (float x) {
265 __asm float_arcsine y, x;
293 float acos (float x) {
294 return 1.5708 - asin (x);
321 float atan (float y_over_x) {
323 __asm float_arctan z, y_over_x;
327 vec2 atan (vec2 y_over_x) {
334 vec3 atan (vec3 y_over_x) {
342 vec4 atan (vec4 y_over_x) {
351 float atan (float y, float x) {
363 vec2 atan (vec2 u, vec2 v) {
370 vec3 atan (vec3 u, vec3 v) {
378 vec4 atan (vec4 u, vec4 v) {
388 // 8.2 Exponential Functions
391 float pow (float x, float y) {
393 __asm float_power p, x, y;
397 vec2 pow (vec2 v, vec2 u) {
404 vec3 pow (vec3 v, vec3 u) {
412 vec4 pow (vec4 v, vec4 u) {
421 float exp (float x) {
422 return pow (2.71828183, x);
426 return pow (vec2 (2.71828183), v);
430 return pow (vec3 (2.71828183), v);
434 return pow (vec4 (2.71828183), v);
437 float log2 (float x) {
439 __asm float_log2 y, x;
467 float log (float x) {
468 return log2 (x) / log2 (2.71828183);
472 return log2 (v) / log2 (vec2 (2.71828183));
476 return log2 (v) / log2 (vec3 (2.71828183));
480 return log2 (v) / log2 (vec4 (2.71828183));
483 float exp2 (float x) {
488 return pow (vec2 (2.0), v);
492 return pow (vec3 (2.0), v);
496 return pow (vec4 (2.0), v);
499 float sqrt (float x) {
504 return pow (v, vec2 (0.5));
508 return pow (v, vec3 (0.5));
512 return pow (v, vec4 (0.5));
515 float inversesqrt (float x) {
516 return 1.0 / sqrt (x);
519 vec2 inversesqrt (vec2 v) {
520 return vec2 (1.0) / sqrt (v);
523 vec3 inversesqrt (vec3 v) {
524 return vec3 (1.0) / sqrt (v);
527 vec4 inversesqrt (vec4 v) {
528 return vec4 (1.0) / sqrt (v);
532 // 8.3 Common Functions
535 float abs (float x) {
536 return x >= 0.0 ? x : -x;
563 float sign (float x) {
564 return x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0;
591 float floor (float x) {
593 __asm float_floor y, x;
597 vec2 floor (vec2 v) {
604 vec3 floor (vec3 v) {
612 vec4 floor (vec4 v) {
621 float ceil (float x) {
623 __asm float_ceil y, x;
651 float fract (float x) {
652 return x - floor (x);
655 vec2 fract (vec2 v) {
656 return v - floor (v);
659 vec3 fract (vec3 v) {
660 return v - floor (v);
663 vec4 fract (vec4 v) {
664 return v - floor (v);
667 float mod (float x, float y) {
668 return x - y * floor (x / y);
671 vec2 mod (vec2 v, float u) {
672 return v - u * floor (v / u);
675 vec3 mod (vec3 v, float u) {
676 return v - u * floor (v / u);
679 vec4 mod (vec4 v, float u) {
680 return v - u * floor (v / u);
683 vec2 mod (vec2 v, vec2 u) {
684 return v - u * floor (v / u);
687 vec3 mod (vec3 v, vec3 u) {
688 return v - u * floor (v / u);
691 vec4 mod (vec4 v, vec4 u) {
692 return v - u * floor (v / u);
695 float min (float x, float y) {
696 return x < y ? x : y;
699 vec2 min (vec2 v, vec2 u) {
706 vec3 min (vec3 v, vec3 u) {
714 vec4 min (vec4 v, vec4 u) {
723 vec2 min (vec2 v, float y) {
724 return min (v, vec2 (y));
727 vec3 min (vec3 v, float y) {
728 return min (v, vec3 (y));
731 vec4 min (vec4 v, float y) {
732 return min (v, vec4 (y));
735 float max (float x, float y) {
736 return x < y ? y : x;
739 vec2 max (vec2 v, vec2 u) {
746 vec3 max (vec3 v, vec3 u) {
754 vec4 max (vec4 v, vec4 u) {
763 vec2 max (vec2 v, float y) {
764 return max (v, vec2 (y));
767 vec3 max (vec3 v, float y) {
768 return max (v, vec3 (y));
771 vec4 max (vec4 v, float y) {
772 return max (v, vec4 (y));
775 float clamp (float x, float minVal, float maxVal) {
776 return min (max (x, minVal), maxVal);
779 vec2 clamp (vec2 x, float minVal, float maxVal) {
780 return min (max (x, minVal), maxVal);
783 vec3 clamp (vec3 x, float minVal, float maxVal) {
784 return min (max (x, minVal), maxVal);
787 vec4 clamp (vec4 x, float minVal, float maxVal) {
788 return min (max (x, minVal), maxVal);
791 vec2 clamp (vec2 x, vec2 minVal, vec2 maxVal) {
792 return min (max (x, minVal), maxVal);
795 vec3 clamp (vec3 x, vec3 minVal, vec3 maxVal) {
796 return min (max (x, minVal), maxVal);
799 vec4 clamp (vec4 x, vec4 minVal, vec4 maxVal) {
800 return min (max (x, minVal), maxVal);
803 float mix (float x, float y, float a) {
804 return x * (1.0 - a) + y * a;
807 vec2 mix (vec2 x, vec2 y, float a) {
808 return x * (1.0 - a) + y * a;
811 vec3 mix (vec3 x, vec3 y, float a) {
812 return x * (1.0 - a) + y * a;
815 vec4 mix (vec4 x, vec4 y, float a) {
816 return x * (1.0 - a) + y * a;
819 vec2 mix (vec2 x, vec2 y, vec2 a) {
820 return x * (1.0 - a) + y * a;
823 vec3 mix (vec3 x, vec3 y, vec3 a) {
824 return x * (1.0 - a) + y * a;
827 vec4 mix (vec4 x, vec4 y, vec4 a) {
828 return x * (1.0 - a) + y * a;
831 float step (float edge, float x) {
832 return x < edge ? 0.0 : 1.0;
835 vec2 step (vec2 edge, vec2 v) {
842 vec3 step (vec3 edge, vec3 v) {
850 vec4 step (vec4 edge, vec4 v) {
859 vec2 step (float edge, vec2 v) {
860 return step (vec2 (edge), v);
863 vec3 step (float edge, vec3 v) {
864 return step (vec3 (edge), v);
867 vec4 step (float edge, vec4 v) {
868 return step (vec4 (edge), v);
871 float smoothstep (float edge0, float edge1, float x) {
873 t = clamp ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
874 return t * t * (3.0 - 2.0 * t);
877 vec2 smoothstep (vec2 edge0, vec2 edge1, vec2 v) {
879 smoothstep (edge0.x, edge1.x, v.x),
880 smoothstep (edge0.y, edge1.y, v.y)
884 vec3 smoothstep (vec3 edge0, vec3 edge1, vec3 v) {
886 smoothstep (edge0.x, edge1.x, v.x),
887 smoothstep (edge0.y, edge1.y, v.y),
888 smoothstep (edge0.z, edge1.z, v.z)
892 vec4 smoothstep (vec4 edge0, vec4 edge1, vec4 v) {
894 smoothstep (edge0.x, edge1.x, v.x),
895 smoothstep (edge0.y, edge1.y, v.y),
896 smoothstep (edge0.z, edge1.z, v.z),
897 smoothstep (edge0.w, edge1.w, v.w)
901 vec2 smoothstep (float edge0, float edge1, vec2 v) {
903 smoothstep (edge0, edge1, v.x),
904 smoothstep (edge0, edge1, v.y)
908 vec3 smoothstep (float edge0, float edge1, vec3 v) {
910 smoothstep (edge0, edge1, v.x),
911 smoothstep (edge0, edge1, v.y),
912 smoothstep (edge0, edge1, v.z)
916 vec4 smoothstep (float edge0, float edge1, vec4 v) {
918 smoothstep (edge0, edge1, v.x),
919 smoothstep (edge0, edge1, v.y),
920 smoothstep (edge0, edge1, v.z),
921 smoothstep (edge0, edge1, v.w)
926 // 8.4 Geometric Functions
929 float dot (float x, float y) {
933 float dot (vec2 v, vec2 u) {
934 return v.x * u.x + v.y * u.y;
937 float dot (vec3 v, vec3 u) {
938 return v.x * u.x + v.y * u.y + v.z * u.z;
941 float dot (vec4 v, vec4 u) {
942 return v.x * u.x + v.y * u.y + v.z * u.z + v.w * u.w;
945 float length (float x) {
946 return sqrt (dot (x, x));
949 float length (vec2 v) {
950 return sqrt (dot (v, v));
953 float length (vec3 v) {
954 return sqrt (dot (v, v));
957 float length (vec4 v) {
958 return sqrt (dot (v, v));
961 float distance (float x, float y) {
962 return length (x - y);
965 float distance (vec2 v, vec2 u) {
966 return length (v - u);
969 float distance (vec3 v, vec3 u) {
970 return length (v - u);
973 float distance (vec4 v, vec4 u) {
974 return length (v - u);
977 vec3 cross (vec3 v, vec3 u) {
979 v.y * u.z - u.y * v.z,
980 v.z * u.x - u.z * v.x,
981 v.x * u.y - u.x * v.y
985 float normalize (float x) {
989 vec2 normalize (vec2 v) {
990 return v / length (v);
993 vec3 normalize (vec3 v) {
994 return v / length (v);
997 vec4 normalize (vec4 v) {
998 return v / length (v);
1001 float faceforward (float N, float I, float Nref) {
1002 return dot (Nref, I) < 0.0 ? N : -N;
1005 vec2 faceforward (vec2 N, vec2 I, vec2 Nref) {
1006 return dot (Nref, I) < 0.0 ? N : -N;
1009 vec3 faceforward (vec3 N, vec3 I, vec3 Nref) {
1010 return dot (Nref, I) < 0.0 ? N : -N;
1013 vec4 faceforward (vec4 N, vec4 I, vec4 Nref) {
1014 return dot (Nref, I) < 0.0 ? N : -N;
1017 float reflect (float I, float N) {
1018 return I - 2.0 * dot (N, I) * N;
1021 vec2 reflect (vec2 I, vec2 N) {
1022 return I - 2.0 * dot (N, I) * N;
1025 vec3 reflect (vec3 I, vec3 N) {
1026 return I - 2.0 * dot (N, I) * N;
1029 vec4 reflect (vec4 I, vec4 N) {
1030 return I - 2.0 * dot (N, I) * N;
1033 float refract (float I, float N, float eta) {
1035 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1038 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1041 vec2 refract (vec2 I, vec2 N, float eta) {
1043 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1046 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1049 vec3 refract (vec3 I, vec3 N, float eta) {
1051 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1054 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1057 vec4 refract (vec4 I, vec4 N, float eta) {
1059 k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
1062 return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
1066 // 8.5 Matrix Functions
1069 mat2 matrixCompMult (mat2 m, mat2 n) {
1070 return mat2 (m[0] * n[0], m[1] * n[1]);
1073 mat3 matrixCompMult (mat3 m, mat3 n) {
1074 return mat3 (m[0] * n[0], m[1] * n[1], m[2] * n[2]);
1077 mat4 matrixCompMult (mat4 m, mat4 n) {
1078 return mat4 (m[0] * n[0], m[1] * n[1], m[2] * n[2], m[3] * n[3]);
1082 // 8.6 Vector Relational Functions
1085 bvec2 lessThan (vec2 v, vec2 u) {
1086 return bvec2 (v.x < u.x, v.y < u.y);
1089 bvec3 lessThan (vec3 v, vec3 u) {
1090 return bvec3 (v.x < u.x, v.y < u.y, v.z < u.z);
1093 bvec4 lessThan (vec4 v, vec4 u) {
1094 return bvec4 (v.x < u.x, v.y < u.y, v.z < u.z, v.w < u.w);
1097 bvec2 lessThan (ivec2 v, ivec2 u) {
1098 return bvec2 (v.x < u.x, v.y < u.y);
1101 bvec3 lessThan (ivec3 v, ivec3 u) {
1102 return bvec3 (v.x < u.x, v.y < u.y, v.z < u.z);
1105 bvec4 lessThan (ivec4 v, ivec4 u) {
1106 return bvec4 (v.x < u.x, v.y < u.y, v.z < u.z, v.w < u.w);
1109 bvec2 lessThanEqual (vec2 v, vec2 u) {
1110 return bvec2 (v.x <= u.x, v.y <= u.y);
1113 bvec3 lessThanEqual (vec3 v, vec3 u) {
1114 return bvec3 (v.x <= u.x, v.y <= u.y, v.z <= u.z);
1117 bvec4 lessThanEqual (vec4 v, vec4 u) {
1118 return bvec4 (v.x <= u.x, v.y <= u.y, v.z <= u.z, v.w <= u.w);
1121 bvec2 lessThanEqual (ivec2 v, ivec2 u) {
1122 return bvec2 (v.x <= u.x, v.y <= u.y);
1125 bvec3 lessThanEqual (ivec3 v, ivec3 u) {
1126 return bvec3 (v.x <= u.x, v.y <= u.y, v.z <= u.z);
1129 bvec4 lessThanEqual (ivec4 v, ivec4 u) {
1130 return bvec4 (v.x <= u.x, v.y <= u.y, v.z <= u.z, v.w <= u.w);
1133 bvec2 greaterThan (vec2 v, vec2 u) {
1134 return bvec2 (v.x > u.x, v.y > u.y);
1137 bvec3 greaterThan (vec3 v, vec3 u) {
1138 return bvec3 (v.x > u.x, v.y > u.y, v.z > u.z);
1141 bvec4 greaterThan (vec4 v, vec4 u) {
1142 return bvec4 (v.x > u.x, v.y > u.y, v.z > u.z, v.w > u.w);
1145 bvec2 greaterThan (ivec2 v, ivec2 u) {
1146 return bvec2 (v.x > u.x, v.y > u.y);
1149 bvec3 greaterThan (ivec3 v, ivec3 u) {
1150 return bvec3 (v.x > u.x, v.y > u.y, v.z > u.z);
1153 bvec4 greaterThan (ivec4 v, ivec4 u) {
1154 return bvec4 (v.x > u.x, v.y > u.y, v.z > u.z, v.w > u.w);
1157 bvec2 greaterThanEqual (vec2 v, vec2 u) {
1158 return bvec2 (v.x >= u.x, v.y >= u.y);
1161 bvec3 greaterThanEqual (vec3 v, vec3 u) {
1162 return bvec3 (v.x >= u.x, v.y >= u.y, v.z >= u.z);
1165 bvec4 greaterThanEqual (vec4 v, vec4 u) {
1166 return bvec4 (v.x >= u.x, v.y >= u.y, v.z >= u.z, v.w >= u.w);
1169 bvec2 greaterThanEqual (ivec2 v, ivec2 u) {
1170 return bvec2 (v.x >= u.x, v.y >= u.y);
1173 bvec3 greaterThanEqual (ivec3 v, ivec3 u) {
1174 return bvec3 (v.x >= u.x, v.y >= u.y, v.z >= u.z);
1177 bvec4 greaterThanEqual (ivec4 v, ivec4 u) {
1178 return bvec4 (v.x >= u.x, v.y >= u.y, v.z >= u.z, v.w >= u.w);
1181 bvec2 equal (vec2 v, vec2 u) {
1182 return bvec2 (v.x == u.x, v.y == u.y);
1185 bvec3 equal (vec3 v, vec3 u) {
1186 return bvec3 (v.x == u.x, v.y == u.y, v.z == u.z);
1189 bvec4 equal (vec4 v, vec4 u) {
1190 return bvec4 (v.x == u.x, v.y == u.y, v.z == u.z, v.w == u.w);
1193 bvec2 equal (ivec2 v, ivec2 u) {
1194 return bvec2 (v.x == u.x, v.y == u.y);
1197 bvec3 equal (ivec3 v, ivec3 u) {
1198 return bvec3 (v.x == u.x, v.y == u.y, v.z == u.z);
1201 bvec4 equal (ivec4 v, ivec4 u) {
1202 return bvec4 (v.x == u.x, v.y == u.y, v.z == u.z, v.w == u.w);
1205 bvec2 notEqual (vec2 v, vec2 u) {
1206 return bvec2 (v.x != u.x, v.y != u.y);
1209 bvec3 notEqual (vec3 v, vec3 u) {
1210 return bvec3 (v.x != u.x, v.y != u.y, v.z != u.z);
1213 bvec4 notEqual (vec4 v, vec4 u) {
1214 return bvec4 (v.x != u.x, v.y != u.y, v.z != u.z, v.w != u.w);
1217 bvec2 notEqual (ivec2 v, ivec2 u) {
1218 return bvec2 (v.x != u.x, v.y != u.y);
1221 bvec3 notEqual (ivec3 v, ivec3 u) {
1222 return bvec3 (v.x != u.x, v.y != u.y, v.z != u.z);
1225 bvec4 notEqual (ivec4 v, ivec4 u) {
1226 return bvec4 (v.x != u.x, v.y != u.y, v.z != u.z, v.w != u.w);
1229 bool any (bvec2 v) {
1233 bool any (bvec3 v) {
1234 return v.x || v.y || v.z;
1237 bool any (bvec4 v) {
1238 return v.x || v.y || v.z || v.w;
1241 bool all (bvec2 v) {
1245 bool all (bvec3 v) {
1246 return v.x && v.y && v.z;
1249 bool all (bvec4 v) {
1250 return v.x && v.y && v.z && v.w;
1253 bvec2 not (bvec2 v) {
1254 return bvec2 (!v.x, !v.y);
1257 bvec3 not (bvec3 v) {
1258 return bvec3 (!v.x, !v.y, !v.z);
1261 bvec4 not (bvec4 v) {
1262 return bvec4 (!v.x, !v.y, !v.z, !v.w);
1266 // 8.7 Texture Lookup Functions
1269 vec4 texture1D (sampler1D sampler, float coord) {
1274 vec4 texture1DProj (sampler1D sampler, vec2 coord) {
1275 return texture1D (sampler, coord.s / coord.t);
1278 vec4 texture1DProj (sampler1D sampler, vec4 coord) {
1279 return texture1D (sampler, coord.s / coord.q);
1282 vec4 texture2D (sampler2D sampler, vec2 coord) {
1284 __asm vec4_tex2d texel, sampler, coord;
1288 vec4 texture2DProj (sampler2D sampler, vec3 coord) {
1289 return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p));
1292 vec4 texture2DProj (sampler2D sampler, vec4 coord) {
1293 return texture2D (sampler, vec2 (coord.s / coord.q, coord.t / coord.q));
1296 vec4 texture3D (sampler3D sampler, vec3 coord) {
1301 vec4 texture3DProj (sampler3D sampler, vec4 coord) {
1302 return texture3D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
1305 vec4 textureCube (samplerCube sampler, vec3 coord) {
1310 vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {
1315 vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
1320 vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {
1321 return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));
1324 vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {
1325 return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
1329 // 8.9 Noise Functions
1331 // AUTHOR: Stefan Gustavson (stegu@itn.liu.se), Nov 26, 2005
1334 float noise1 (float x) {
1336 __asm float_noise1 a, x;
1340 float noise1 (vec2 x) {
1342 __asm float_noise2 a, x;
1346 float noise1 (vec3 x) {
1348 __asm float_noise3 a, x;
1352 float noise1 (vec4 x) {
1354 __asm float_noise4 a, x;
1358 vec2 noise2 (float x) {
1365 vec2 noise2 (vec2 x) {
1368 noise1 (x + vec2 (19.34, 7.66))
1372 vec2 noise2 (vec3 x) {
1375 noise1 (x + vec3 (19.34, 7.66, 3.23))
1379 vec2 noise2 (vec4 x) {
1382 noise1 (x + vec4 (19.34, 7.66, 3.23, 2.77))
1386 vec3 noise3 (float x) {
1394 vec3 noise3 (vec2 x) {
1397 noise1 (x + vec2 (19.34, 7.66)),
1398 noise1 (x + vec2 (5.47, 17.85))
1402 vec3 noise3 (vec3 x) {
1405 noise1 (x + vec3 (19.34, 7.66, 3.23)),
1406 noise1 (x + vec3 (5.47, 17.85, 11.04))
1410 vec3 noise3 (vec4 x) {
1413 noise1 (x + vec4 (19.34, 7.66, 3.23, 2.77)),
1414 noise1 (x + vec4 (5.47, 17.85, 11.04, 13.19))
1418 vec4 noise4 (float x) {
1427 vec4 noise4 (vec2 x) {
1430 noise1 (x + vec2 (19.34, 7.66)),
1431 noise1 (x + vec2 (5.47, 17.85)),
1432 noise1 (x + vec2 (23.54, 29.11))
1436 vec4 noise4 (vec3 x) {
1439 noise1 (x + vec3 (19.34, 7.66, 3.23)),
1440 noise1 (x + vec3 (5.47, 17.85, 11.04)),
1441 noise1 (x + vec3 (23.54, 29.11, 31.91))
1445 vec4 noise4 (vec4 x) {
1448 noise1 (x + vec4 (19.34, 7.66, 3.23, 2.77)),
1449 noise1 (x + vec4 (5.47, 17.85, 11.04, 13.19)),
1450 noise1 (x + vec4 (23.54, 29.11, 31.91, 37.48))