use FetchTexelf() in GetTexImage() to return float textures correctly
[mesa.git] / src / mesa / shader / slang_common_builtin.gc
1
2 //
3 // TODO:
4 // - implement sin, asin, acos, atan, pow, log2, floor, ceil,
5 // - implement texture1D, texture2D, texture3D, textureCube,
6 // - implement shadow1D, shadow2D,
7 // - implement noise1, noise2, noise3, noise4,
8 //
9
10 //
11 // From Shader Spec, ver. 1.051
12 //
13 // The following built-in constants are provided to vertex and fragment shaders.
14 //
15
16 //
17 // Implementation dependent constants. The example values below
18 // are the minimum values allowed for these maximums.
19 //
20
21 const int gl_MaxLights = 8; // GL 1.0
22 const int gl_MaxClipPlanes = 6; // GL 1.0
23 const int gl_MaxTextureUnits = 2; // GL 1.2
24 const int gl_MaxTextureCoordsARB = 2; // ARB_fragment_program
25 const int gl_MaxVertexAttributesGL2 = 16; // GL2_vertex_shader
26 const int gl_MaxVertexUniformFloatsGL2 = 512; // GL2_vertex_shader
27 const int gl_MaxVaryingFloatsGL2 = 32; // GL2_vertex_shader
28 const int gl_MaxVertexTextureUnitsGL2 = 1; // GL2_vertex_shader
29 const int gl_MaxFragmentTextureUnitsGL2 = 2; // GL2_fragment_shader
30 const int gl_MaxFragmentUniformFloatsGL2 = 64; // GL2_fragment_shader
31
32 //
33 // As an aid to accessing OpenGL processing state, the following uniform variables are built into
34 // the OpenGL Shading Language. All page numbers and notations are references to the 1.4
35 // specification.
36 //
37
38 //
39 // Matrix state. p. 31, 32, 37, 39, 40.
40 //
41
42 uniform mat4 gl_ModelViewMatrix;
43 uniform mat4 gl_ProjectionMatrix;
44 uniform mat4 gl_ModelViewProjectionMatrix;
45 uniform mat3 gl_NormalMatrix; // derived
46 uniform mat4 gl_TextureMatrix[gl_MaxTextureCoordsARB];
47
48 //
49 // Normal scaling p. 39.
50 //
51
52 uniform float gl_NormalScale;
53
54 //
55 // Depth range in window coordinates, p. 33
56 //
57
58 struct gl_DepthRangeParameters {
59 float near; // n
60 float far; // f
61 float diff; // f - n
62 };
63
64 uniform gl_DepthRangeParameters gl_DepthRange;
65
66 //
67 // Clip planes p. 42.
68 //
69
70 uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
71
72 //
73 // Point Size, p. 66, 67.
74 //
75
76 struct gl_PointParameters {
77 float size;
78 float sizeMin;
79 float sizeMax;
80 float fadeThresholdSize;
81 float distanceConstantAttenuation;
82 float distanceLinearAttenuation;
83 float distanceQuadraticAttenuation;
84 };
85
86 uniform gl_PointParameters gl_Point;
87
88 //
89 // Material State p. 50, 55.
90 //
91
92 struct gl_MaterialParameters {
93 vec4 emission; // Ecm
94 vec4 ambient; // Acm
95 vec4 diffuse; // Dcm
96 vec4 specular; // Scm
97 float shininess; // Srm
98 };
99
100 uniform gl_MaterialParameters gl_FrontMaterial;
101 uniform gl_MaterialParameters gl_BackMaterial;
102
103 //
104 // Light State p 50, 53, 55.
105 //
106
107 struct gl_LightSourceParameters {
108 vec4 ambient; // Acli
109 vec4 diffuse; // Dcli
110 vec4 specular; // Scli
111 vec4 position; // Ppli
112 vec4 halfVector; // Derived: Hi
113 vec3 spotDirection; // Sdli
114 float spotExponent; // Srli
115 float spotCutoff; // Crli
116 // (range: [0.0,90.0], 180.0)
117 float spotCosCutoff; // Derived: cos(Crli)
118 // (range: [1.0,0.0],-1.0)
119 float constantAttenuation; // K0
120 float linearAttenuation; // K1
121 float quadraticAttenuation; // K2
122 };
123
124 uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
125
126 struct gl_LightModelParameters {
127 vec4 ambient; // Acs
128 };
129
130 uniform gl_LightModelParameters gl_LightModel;
131
132 //
133 // Derived state from products of light and material.
134 //
135
136 struct gl_LightModelProducts {
137 vec4 sceneColor; // Derived. Ecm + Acm * Acs
138 };
139
140 uniform gl_LightModelProducts gl_FrontLightModelProduct;
141 uniform gl_LightModelProducts gl_BackLightModelProduct;
142
143 struct gl_LightProducts {
144 vec4 ambient; // Acm * Acli
145 vec4 diffuse; // Dcm * Dcli
146 vec4 specular; // Scm * Scli
147 };
148
149 uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
150 uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
151
152 //
153 // Textureg Environment and Generation, p. 152, p. 40-42.
154 //
155
156 uniform vec4 gl_TextureEnvColor[gl_MaxFragmentTextureUnitsGL2];
157 uniform vec4 gl_EyePlaneS[gl_MaxTextureCoordsARB];
158 uniform vec4 gl_EyePlaneT[gl_MaxTextureCoordsARB];
159 uniform vec4 gl_EyePlaneR[gl_MaxTextureCoordsARB];
160 uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoordsARB];
161 uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoordsARB];
162 uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoordsARB];
163 uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoordsARB];
164 uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoordsARB];
165
166 //
167 // Fog p. 161
168 //
169
170 struct gl_FogParameters {
171 vec4 color;
172 float density;
173 float start;
174 float end;
175 float scale; // 1 / (gl_FogEnd - gl_FogStart)
176 };
177
178 uniform gl_FogParameters gl_Fog;
179
180 //
181 // The OpenGL Shading Language defines an assortment of built-in convenience functions for scalar
182 // and vector operations. Many of these built-in functions can be used in more than one type
183 // of shader, but some are intended to provide a direct mapping to hardware and so are available
184 // only for a specific type of shader.
185 //
186 // The built-in functions basically fall into three categories:
187 //
188 // \95 They expose some necessary hardware functionality in a convenient way such as accessing
189 // a texture map. There is no way in the language for these functions to be emulated by a shader.
190 //
191 // \95 They represent a trivial operation (clamp, mix, etc.) that is very simple for the user
192 // to write, but they are very common and may have direct hardware support. It is a very hard
193 // problem for the compiler to map expressions to complex assembler instructions.
194 //
195 // \95 They represent an operation graphics hardware is likely to accelerate at some point. The
196 // trigonometry functions fall into this category.
197 //
198 // Many of the functions are similar to the same named ones in common C libraries, but they support
199 // vector input as well as the more traditional scalar input.
200 //
201 // Applications should be encouraged to use the built-in functions rather than do the equivalent
202 // computations in their own shader code since the built-in functions are assumed to be optimal
203 // (e.g., perhaps supported directly in hardware).
204 //
205 // User code can replace built-in functions with their own if they choose, by simply re-declaring
206 // and defining the same name and argument list.
207 //
208
209 //
210 // Angle and Trigonometry Functions
211 //
212 // Function parameters specified as angle are assumed to be in units of radians. In no case will
213 // any of these functions result in a divide by zero error. If the divisor of a ratio is 0, then
214 // results will be undefined.
215 //
216 // These all operate component-wise.
217 //
218
219 //
220 // Converts degrees to radians and returns the result, i.e., result = PI*deg/180.
221 //
222
223 float radians (float deg) {
224 return 3.141593 * deg / 180.0;
225 }
226 vec2 radians (vec2 deg) {
227 return vec2 (radians (deg.x), radians (deg.y));
228 }
229 vec3 radians (vec3 deg) {
230 return vec3 (radians (deg.x), radians (deg.y), radians (deg.z));
231 }
232 vec4 radians (vec4 deg) {
233 return vec4 (radians (deg.x), radians (deg.y), radians (deg.z), radians (deg.w));
234 }
235
236 //
237 // Converts radians to degrees and returns the result, i.e., result = 180*rad/PI.
238 //
239
240 float degrees (float rad) {
241 return 180.0 * rad / 3.141593;
242 }
243 vec2 degrees (vec2 rad) {
244 return vec2 (degrees (rad.x), degrees (rad.y));
245 }
246 vec3 degrees (vec3 rad) {
247 return vec3 (degrees (rad.x), degrees (rad.y), degrees (rad.z));
248 }
249 vec4 degrees (vec4 rad) {
250 return vec4 (degrees (rad.x), degrees (rad.y), degrees (rad.z), degrees (rad.w));
251 }
252
253 //
254 // The standard trigonometric sine function.
255 //
256 // XXX
257 float sin (float angle) {
258 return 0.0;
259 }
260 vec2 sin (vec2 angle) {
261 return vec2 (sin (angle.x), sin (angle.y));
262 }
263 vec3 sin (vec3 angle) {
264 return vec3 (sin (angle.x), sin (angle.y), sin (angle.z));
265 }
266 vec4 sin (vec4 angle) {
267 return vec4 (sin (angle.x), sin (angle.y), sin (angle.z), sin (angle.w));
268 }
269
270 //
271 // The standard trigonometric cosine function.
272 //
273
274 float cos (float angle) {
275 return sin (angle + 1.5708);
276 }
277 vec2 cos (vec2 angle) {
278 return vec2 (cos (angle.x), cos (angle.y));
279 }
280 vec3 cos (vec3 angle) {
281 return vec3 (cos (angle.x), cos (angle.y), cos (angle.z));
282 }
283 vec4 cos (vec4 angle) {
284 return vec4 (cos (angle.x), cos (angle.y), cos (angle.z), cos (angle.w));
285 }
286
287 //
288 // The standard trigonometric tangent.
289 //
290
291 float tan (float angle) {
292 return sin (angle) / cos (angle);
293 }
294 vec2 tan (vec2 angle) {
295 return vec2 (tan (angle.x), tan (angle.y));
296 }
297 vec3 tan (vec3 angle) {
298 return vec3 (tan (angle.x), tan (angle.y), tan (angle.z));
299 }
300 vec4 tan (vec4 angle) {
301 return vec4 (tan (angle.x), tan (angle.y), tan (angle.z), tan (angle.w));
302 }
303
304 //
305 // Arc sine. Returns an angle whose sine is x. The range of values returned by this function is
306 // [\96PI/2, PI/2]. Results are undefined if |x| > 1.
307 //
308 // XXX
309 float asin (float x) {
310 return 0.0;
311 }
312 vec2 asin (vec2 x) {
313 return vec2 (asin (x.x), asin (x.y));
314 }
315 vec3 asin (vec3 x) {
316 return vec3 (asin (x.x), asin (x.y), asin (x.z));
317 }
318 vec4 asin (vec4 x) {
319 return vec4 (asin (x.x), asin (x.y), asin (x.z), asin (x.w));
320 }
321
322 //
323 // Arc cosine. Returns an angle whose cosine is x. The range of values returned by this function is
324 // [0, PI]. Results are undefined if |x| > 1.
325 //
326 // XXX
327 float acos (float x) {
328 return 0.0;
329 }
330 vec2 acos (vec2 x) {
331 return vec2 (acos (x.x), acos (x.y));
332 }
333 vec3 acos (vec3 x) {
334 return vec3 (acos (x.x), acos (x.y), acos (x.z));
335 }
336 vec4 acos (vec4 x) {
337 return vec4 (acos (x.x), acos (x.y), acos (x.z), acos (x.w));
338 }
339
340 //
341 // Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine
342 // what quadrant the angle is in. The range of values returned by this function is [\96PI, PI].
343 // Results are undefined if x and y are both 0.
344 //
345 // XXX
346 float atan (float x, float y) {
347 return 0.0;
348 }
349 vec2 atan (vec2 x, vec2 y) {
350 return vec2 (atan (x.x, y.x), atan (x.y, y.y));
351 }
352 vec3 atan (vec3 x, vec3 y) {
353 return vec3 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z));
354 }
355 vec4 atan (vec4 x, vec4 y) {
356 return vec4 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z), atan (x.w, y.w));
357 }
358
359 //
360 // Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this
361 // function is [\96PI/2, PI/2].
362 //
363 // XXX
364 float atan (float y_over_x) {
365 return 0.0;
366 }
367 vec2 atan (vec2 y_over_x) {
368 return vec2 (atan (y_over_x.x), atan (y_over_x.y));
369 }
370 vec3 atan (vec3 y_over_x) {
371 return vec3 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z));
372 }
373 vec4 atan (vec4 y_over_x) {
374 return vec4 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z), atan (y_over_x.w));
375 }
376
377 //
378 // Exponential Functions
379 //
380 // These all operate component-wise.
381 //
382
383 //
384 // Returns x raised to the y power, i.e., x^y
385 //
386 // XXX
387 float pow (float x, float y) {
388 return 0.0;
389 }
390 vec2 pow (vec2 x, vec2 y) {
391 return vec2 (pow (x.x, y.x), pow (x.y, y.y));
392 }
393 vec3 pow (vec3 x, vec3 y) {
394 return vec3 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z));
395 }
396 vec4 pow (vec4 x, vec4 y) {
397 return vec4 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z), pow (x.w, y.w));
398 }
399
400 //
401 // Returns 2 raised to the x power, i.e., 2^x
402 //
403
404 float exp2 (float x) {
405 return pow (2.0, x);
406 }
407 vec2 exp2 (vec2 x) {
408 return vec2 (exp2 (x.x), exp2 (x.y));
409 }
410 vec3 exp2 (vec3 x) {
411 return vec3 (exp2 (x.x), exp2 (x.y), exp2 (x.z));
412 }
413 vec4 exp2 (vec4 x) {
414 return vec4 (exp2 (x.x), exp2 (x.y), exp2 (x.z), exp2 (x.w));
415 }
416
417 //
418 // Returns the base 2 log of x, i.e., returns the value y which satisfies the equation x = 2^y
419 //
420 // XXX
421 float log2 (float x) {
422 return 0.0;
423 }
424 vec2 log2 (vec2 x) {
425 return vec2 (log2 (x.x), log2 (x.y));
426 }
427 vec3 log2 (vec3 x) {
428 return vec3 (log2 (x.x), log2 (x.y), log2 (x.z));
429 }
430 vec4 log2 (vec4 x) {
431 return vec4 (log2 (x.x), log2 (x.y), log2 (x.z), log2 (x.w));
432 }
433
434 //
435 // Returns the positive square root of x
436 //
437
438 float sqrt (float x) {
439 return pow (x, 0.5);
440 }
441 vec2 sqrt (vec2 x) {
442 return vec2 (sqrt (x.x), sqrt (x.y));
443 }
444 vec3 sqrt (vec3 x) {
445 return vec3 (sqrt (x.x), sqrt (x.y), sqrt (x.z));
446 }
447 vec4 sqrt (vec4 x) {
448 return vec4 (sqrt (x.x), sqrt (x.y), sqrt (x.z), sqrt (x.w));
449 }
450
451 //
452 // Returns the reciprocal of the positive square root of x
453 //
454
455 float inversesqrt (float x) {
456 return 1.0 / sqrt (x);
457 }
458 vec2 inversesqrt (vec2 x) {
459 return vec2 (inversesqrt (x.x), inversesqrt (x.y));
460 }
461 vec3 inversesqrt (vec3 x) {
462 return vec3 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z));
463 }
464 vec4 inversesqrt (vec4 x) {
465 return vec4 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z), inversesqrt (x.w));
466 }
467
468 //
469 // Common Functions
470 //
471 // These all operate component-wise.
472 //
473
474 //
475 // Returns x if x >= 0, otherwise it returns \96x
476 //
477
478 float abs (float x) {
479 return x >= 0.0 ? x : -x;
480 }
481 vec2 abs (vec2 x) {
482 return vec2 (abs (x.x), abs (x.y));
483 }
484 vec3 abs (vec3 x) {
485 return vec3 (abs (x.x), abs (x.y), abs (x.z));
486 }
487 vec4 abs (vec4 x) {
488 return vec4 (abs (x.x), abs (x.y), abs (x.z), abs (x.w));
489 }
490
491 //
492 // Returns 1.0 if x > 0, 0.0 if x = 0, or \961.0 if x < 0
493 //
494
495 float sign (float x) {
496 return x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0;
497 }
498 vec2 sign (vec2 x) {
499 return vec2 (sign (x.x), sign (x.y));
500 }
501 vec3 sign (vec3 x) {
502 return vec3 (sign (x.x), sign (x.y), sign (x.z));
503 }
504 vec4 sign (vec4 x) {
505 return vec4 (sign (x.x), sign (x.y), sign (x.z), sign (x.w));
506 }
507
508 //
509 // Returns a value equal to the nearest integer that is less than or equal to x
510 //
511 // XXX
512 float floor (float x) {
513 return 0.0;
514 }
515 vec2 floor (vec2 x) {
516 return vec2 (floor (x.x), floor (x.y));
517 }
518 vec3 floor (vec3 x) {
519 return vec3 (floor (x.x), floor (x.y), floor (x.z));
520 }
521 vec4 floor (vec4 x) {
522 return vec4 (floor (x.x), floor (x.y), floor (x.z), floor (x.w));
523 }
524
525 //
526 // Returns a value equal to the nearest integer that is greater than or equal to x
527 //
528 // XXX
529 float ceil (float x) {
530 return 0.0;
531 }
532 vec2 ceil (vec2 x) {
533 return vec2 (ceil (x.x), ceil (x.y));
534 }
535 vec3 ceil (vec3 x) {
536 return vec3 (ceil (x.x), ceil (x.y), ceil (x.z));
537 }
538 vec4 ceil (vec4 x) {
539 return vec4 (ceil (x.x), ceil (x.y), ceil (x.z), ceil (x.w));
540 }
541
542 //
543 // Returns x \96 floor (x)
544 //
545
546 float fract (float x) {
547 return x - floor (x);
548 }
549 vec2 fract (vec2 x) {
550 return vec2 (fract (x.x), fract (x.y));
551 }
552 vec3 fract (vec3 x) {
553 return vec3 (fract (x.x), fract (x.y), fract (x.z));
554 }
555 vec4 fract (vec4 x) {
556 return vec4 (fract (x.x), fract (x.y), fract (x.z), fract (x.w));
557 }
558
559 //
560 // Modulus. Returns x \96 y * floor (x/y)
561 //
562
563 float mod (float x, float y) {
564 return x - y * floor (x / y);
565 }
566 vec2 mod (vec2 x, float y) {
567 return vec2 (mod (x.x, y), mod (x.y, y));
568 }
569 vec3 mod (vec3 x, float y) {
570 return vec3 (mod (x.x, y), mod (x.y, y), mod (x.z, y));
571 }
572 vec4 mod (vec4 x, float y) {
573 return vec4 (mod (x.x, y), mod (x.y, y), mod (x.z, y), mod (x.w, y));
574 }
575 vec2 mod (vec2 x, vec2 y) {
576 return vec2 (mod (x.x, y.x), mod (x.y, y.y));
577 }
578 vec3 mod (vec3 x, vec3 y) {
579 return vec3 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z));
580 }
581 vec4 mod (vec4 x, vec4 y) {
582 return vec4 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z), mod (x.w, y.w));
583 }
584
585 //
586 // Returns y if y < x, otherwise it returns x
587 //
588
589 float min (float x, float y) {
590 return y < x ? y : x;
591 }
592 vec2 min (vec2 x, float y) {
593 return vec2 (min (x.x, y), min (x.y, y));
594 }
595 vec3 min (vec3 x, float y) {
596 return vec3 (min (x.x, y), min (x.y, y), min (x.z, y));
597 }
598 vec4 min (vec4 x, float y) {
599 return vec4 (min (x.x, y), min (x.y, y), min (x.z, y), min (x.w, y));
600 }
601 vec2 min (vec2 x, vec2 y) {
602 return vec2 (min (x.x, y.x), min (x.y, y.y));
603 }
604 vec3 min (vec3 x, vec3 y) {
605 return vec3 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z));
606 }
607 vec4 min (vec4 x, vec4 y) {
608 return vec4 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z), min (x.w, y.w));
609 }
610
611 //
612 // Returns y if x < y, otherwise it returns x
613 //
614
615 float max (float x, float y) {
616 return min (y, x);
617 }
618 vec2 max (vec2 x, float y) {
619 return vec2 (max (x.x, y), max (x.y, y));
620 }
621 vec3 max (vec3 x, float y) {
622 return vec3 (max (x.x, y), max (x.y, y), max (x.z, y));
623 }
624 vec4 max (vec4 x, float y) {
625 return vec4 (max (x.x, y), max (x.y, y), max (x.z, y), max (x.w, y));
626 }
627 vec2 max (vec2 x, vec2 y) {
628 return vec2 (max (x.x, y.x), max (x.y, y.y));
629 }
630 vec3 max (vec3 x, vec3 y) {
631 return vec3 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z));
632 }
633 vec4 max (vec4 x, vec4 y) {
634 return vec4 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z), max (x.w, y.w));
635 }
636
637 //
638 // Returns min (max (x, minVal), maxVal)
639 //
640 // Note that colors and depths written by fragment shaders will be clamped by the implementation
641 // after the fragment shader runs.
642 //
643
644 float clamp (float x, float minVal, float maxVal) {
645 return min (max (x, minVal), maxVal);
646 }
647 vec2 clamp (vec2 x, float minVal, float maxVal) {
648 return vec2 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal));
649 }
650 vec3 clamp (vec3 x, float minVal, float maxVal) {
651 return vec3 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),
652 clamp (x.z, minVal, maxVal));
653 }
654 vec4 clamp (vec4 x, float minVal, float maxVal) {
655 return vec4 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),
656 clamp (x.z, minVal, maxVal), clamp (x.w, minVal, maxVal));
657 }
658 vec2 clamp (vec2 x, vec2 minVal, vec2 maxVal) {
659 return vec2 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y));
660 }
661 vec3 clamp (vec3 x, vec3 minVal, vec3 maxVal) {
662 return vec3 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y),
663 clamp (x.z, minVal.z, maxVal.z));
664 }
665 vec4 clamp (vec4 x, vec4 minVal, vec4 maxVal) {
666 return vec4 (clamp (x.x, minVal.x, maxVal.y), clamp (x.y, minVal.y, maxVal.y),
667 clamp (x.z, minVal.z, maxVal.z), clamp (x.w, minVal.w, maxVal.w));
668 }
669
670 //
671 // Returns x * (1 \96 a) + y * a, i.e., the linear blend of x and y
672 //
673
674 float mix (float x, float y, float a) {
675 return x * (1.0 - a) + y * a;
676 }
677 vec2 mix (vec2 x, vec2 y, float a) {
678 return vec2 (mix (x.x, y.x, a), mix (x.y, y.y, a));
679 }
680 vec3 mix (vec3 x, vec3 y, float a) {
681 return vec3 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a));
682 }
683 vec4 mix (vec4 x, vec4 y, float a) {
684 return vec4 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a), mix (x.w, y.w, a));
685 }
686 vec2 mix (vec2 x, vec2 y, vec2 a) {
687 return vec2 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y));
688 }
689 vec3 mix (vec3 x, vec3 y, vec3 a) {
690 return vec3 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z));
691 }
692 vec4 mix (vec4 x, vec4 y, vec4 a) {
693 return vec4 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z),
694 mix (x.w, y.w, a.w));
695 }
696
697 //
698 // Returns 0.0 if x <= edge, otherwise it returns 1.0
699 //
700
701 float step (float edge, float x) {
702 return x <= edge ? 0.0 : 1.0;
703 }
704 vec2 step (float edge, vec2 x) {
705 return vec2 (step (edge, x.x), step (edge, x.y));
706 }
707 vec3 step (float edge, vec3 x) {
708 return vec3 (step (edge, x.x), step (edge, x.y), step (edge, x.z));
709 }
710 vec4 step (float edge, vec4 x) {
711 return vec4 (step (edge, x.x), step (edge, x.y), step (edge, x.z), step (edge, x.w));
712 }
713 vec2 step (vec2 edge, vec2 x) {
714 return vec2 (step (edge.x, x.x), step (edge.y, x.y));
715 }
716 vec3 step (vec3 edge, vec3 x) {
717 return vec3 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z));
718 }
719 vec4 step (vec4 edge, vec4 x) {
720 return vec4 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z), step (edge.w, x.w));
721 }
722
723 //
724 // Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation
725 // between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold
726 // function with a smooth transition. This is equivalent to:
727 // <type> t;
728 // t = clamp ((x \96 edge0) / (edge1 \96 edge0), 0, 1);
729 // return t * t * (3 \96 2 * t);
730 //
731
732 float smoothstep (float edge0, float edge1, float x) {
733 const float t = clamp ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
734 return t * t * (3.0 - 2.0 * t);
735 }
736 vec2 smoothstep (float edge0, float edge1, vec2 x) {
737 return vec2 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y));
738 }
739 vec3 smoothstep (float edge0, float edge1, vec3 x) {
740 return vec3 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),
741 smoothstep (edge0, edge1, x.z));
742 }
743 vec4 smoothstep (float edge0, float edge1, vec4 x) {
744 return vec4 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),
745 smoothstep (edge0, edge1, x.z), smoothstep (edge0, edge1, x.w));
746 }
747 vec2 smoothstep (vec2 edge0, vec2 edge1, vec2 x) {
748 return vec2 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y));
749 }
750 vec3 smoothstep (vec3 edge0, vec3 edge1, vec3 x) {
751 return vec3 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),
752 smoothstep (edge0.z, edge1.z, x.z));
753 }
754 vec4 smoothstep (vec4 edge0, vec4 edge1, vec4 x) {
755 return vec4 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),
756 smoothstep (edge0.z, edge1.z, x.z), smoothstep (edge0.w, edge1.w, x.w));
757 }
758
759 //
760 // Geometric Functions
761 //
762 // These operate on vectors as vectors, not component-wise.
763 //
764
765 //
766 // Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1] + ...
767 //
768
769 float dot (float x, float y) {
770 return x * y;
771 }
772 float dot (vec2 x, vec2 y) {
773 return dot (x.x, y.x) + dot (x.y, y.y);
774 }
775 float dot (vec3 x, vec3 y) {
776 return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z);
777 }
778 float dot (vec4 x, vec4 y) {
779 return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z) + dot (x.w, y.w);
780 }
781
782 //
783 // Returns the length of vector x, i.e., sqrt (x[0] * x[0] + x[1] * x[1] + ...)
784 //
785
786 float length (float x) {
787 return sqrt (dot (x, x));
788 }
789 float length (vec2 x) {
790 return sqrt (dot (x, x));
791 }
792 float length (vec3 x) {
793 return sqrt (dot (x, x));
794 }
795 float length (vec4 x) {
796 return sqrt (dot (x, x));
797 }
798
799 //
800 // Returns the distance between p0 and p1, i.e. length (p0 \96 p1)
801 //
802
803 float distance (float x, float y) {
804 return length (x - y);
805 }
806 float distance (vec2 x, vec2 y) {
807 return length (x - y);
808 }
809 float distance (vec3 x, vec3 y) {
810 return length (x - y);
811 }
812 float distance (vec4 x, vec4 y) {
813 return length (x - y);
814 }
815
816 //
817 // Returns the cross product of x and y, i.e.
818 // result.0 = x[1] * y[2] - y[1] * x[2]
819 // result.1 = x[2] * y[0] - y[2] * x[0]
820 // result.2 = x[0] * y[1] - y[0] * x[1]
821 //
822
823 vec3 cross (vec3 x, vec3 y) {
824 return vec3 (x.y * y.z - y.y * x.z, x.z * y.x - y.z * x.x, x.x * y.y - y.x * x.y);
825 }
826
827 //
828 // Returns a vector in the same direction as x but with a length of 1.
829 //
830
831 float normalize (float x) {
832 return 1.0;
833 }
834 vec2 normalize (vec2 x) {
835 return x / length (x);
836 }
837 vec3 normalize (vec3 x) {
838 return x / length (x);
839 }
840 vec4 normalize (vec4 x) {
841 return x / length (x);
842 }
843
844 //
845 // If dot (Nref, I) < 0 return N otherwise return \96N
846 //
847
848 float faceforward (float N, float I, float Nref) {
849 return dot (Nref, I) < 0.0 ? N : -N;
850 }
851 vec2 faceforward (vec2 N, vec2 I, vec2 Nref) {
852 return dot (Nref, I) < 0.0 ? N : -N;
853 }
854 vec3 faceforward (vec3 N, vec3 I, vec3 Nref) {
855 return dot (Nref, I) < 0.0 ? N : -N;
856 }
857 vec4 faceforward (vec4 N, vec4 I, vec4 Nref) {
858 return dot (Nref, I) < 0.0 ? N : -N;
859 }
860
861 //
862 // For the incident vector I and surface orientation N, returns the reflection direction:
863 // result = I \96 2 * dot (N, I) * N
864 // N should be normalized in order to achieve the desired result.
865
866 float reflect (float I, float N) {
867 return I - 2.0 * dot (N, I) * N;
868 }
869 vec2 reflect (vec2 I, vec2 N) {
870 return I - 2.0 * dot (N, I) * N;
871 }
872 vec3 reflect (vec3 I, vec3 N) {
873 return I - 2.0 * dot (N, I) * N;
874 }
875 vec4 reflect (vec4 I, vec4 N) {
876 return I - 2.0 * dot (N, I) * N;
877 }
878
879 //
880 // Matrix Functions
881 //
882
883 //
884 // Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product
885 // of x[i][j] and y[i][j].
886 // Note: to get linear algebraic matrix multiplication, use the multiply operator (*).
887 //
888
889 mat2 matrixCompMult (mat2 x, mat2 y) {
890 return mat2 (
891 x[0].x * y[0].x, x[0].y * y[0].y,
892 x[1].x * y[1].x, x[1].y * y[1].y
893 );
894 }
895 mat3 matrixCompMult (mat3 x, mat3 y) {
896 return mat4 (
897 x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z,
898 x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z,
899 x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z
900 );
901 }
902 mat4 matrixCompMult (mat4 x, mat4 y) {
903 return mat4 (
904 x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z + x[0].w * y[0].w,
905 x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z + x[1].w * y[1].w,
906 x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z + x[2].w * y[2].w,
907 x[3].x * y[3].x, x[3].y * y[3].y, x[3].z * y[3].z + x[3].w * y[3].w
908 );
909 }
910
911 //
912 // Vector Relational Functions
913 //
914 // Relational and equality operators (<, <=, >, >=, ==, !=) are defined (or reserved) to produce
915 // scalar Boolean results.
916 //
917
918 //
919 // Returns the component-wise compare of x < y.
920 //
921
922 bvec2 lessThan (vec2 x, vec2 y) {
923 return bvec2 (x.x < y.x, x.y < y.y);
924 }
925 bvec3 lessThan (vec3 x, vec3 y) {
926 return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);
927 }
928 bvec4 lessThan (vec4 x, vec4 y) {
929 return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);
930 }
931 bvec2 lessThan (ivec2 x, ivec2 y) {
932 return bvec2 (x.x < y.x, x.y < y.y);
933 }
934 bvec3 lessThan (ivec3 x, ivec3 y) {
935 return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);
936 }
937 bvec4 lessThan (ivec4 x, ivec4 y) {
938 return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);
939 }
940
941 //
942 // Returns the component-wise compare of x <= y.
943 //
944
945 bvec2 lessThanEqual (vec2 x, vec2 y) {
946 return bvec2 (x.x <= y.x, x.y <= y.y);
947 }
948 bvec3 lessThanEqual (vec3 x, vec3 y) {
949 return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);
950 }
951 bvec4 lessThanEqual (vec4 x, vec4 y) {
952 return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);
953 }
954 bvec2 lessThanEqual (ivec2 x, ivec2 y) {
955 return bvec2 (x.x <= y.x, x.y <= y.y);
956 }
957 bvec3 lessThanEqual (ivec3 x, ivec3 y) {
958 return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);
959 }
960 bvec4 lessThanEqual (ivec4 x, ivec4 y) {
961 return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);
962 }
963
964 //
965 // Returns the component-wise compare of x > y.
966 //
967
968 bvec2 greaterThan (vec2 x, vec2 y) {
969 return bvec2 (x.x > y.x, x.y > y.y);
970 }
971 bvec3 greaterThan (vec3 x, vec3 y) {
972 return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);
973 }
974 bvec4 greaterThan (vec4 x, vec4 y) {
975 return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);
976 }
977 bvec2 greaterThan (ivec2 x, ivec2 y) {
978 return bvec2 (x.x > y.x, x.y > y.y);
979 }
980 bvec3 greaterThan (ivec3 x, ivec3 y) {
981 return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);
982 }
983 bvec4 greaterThan (ivec4 x, ivec4 y) {
984 return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);
985 }
986
987 //
988 // Returns the component-wise compare of x >= y.
989 //
990
991 bvec2 greaterThanEqual (vec2 x, vec2 y) {
992 return bvec2 (x.x >= y.x, x.y >= y.y);
993 }
994 bvec3 greaterThanEqual (vec3 x, vec3 y) {
995 return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);
996 }
997 bvec4 greaterThanEqual (vec4 x, vec4 y) {
998 return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);
999 }
1000 bvec2 greaterThanEqual (ivec2 x, ivec2 y) {
1001 return bvec2 (x.x >= y.x, x.y >= y.y);
1002 }
1003 bvec3 greaterThanEqual (ivec3 x, ivec3 y) {
1004 return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);
1005 }
1006 bvec4 greaterThanEqual (ivec4 x, ivec4 y) {
1007 return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);
1008 }
1009
1010 //
1011 // Returns the component-wise compare of x == y.
1012 //
1013
1014 bvec2 equal (vec2 x, vec2 y) {
1015 return bvec2 (x.x == y.x, x.y == y.y);
1016 }
1017 bvec3 equal (vec3 x, vec3 y) {
1018 return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);
1019 }
1020 bvec4 equal (vec4 x, vec4 y) {
1021 return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);
1022 }
1023 bvec2 equal (ivec2 x, ivec2 y) {
1024 return bvec2 (x.x == y.x, x.y == y.y);
1025 }
1026 bvec3 equal (ivec3 x, ivec3 y) {
1027 return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);
1028 }
1029 bvec4 equal (ivec4 x, ivec4 y) {
1030 return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);
1031 }
1032
1033 //
1034 // Returns the component-wise compare of x != y.
1035 //
1036
1037 bvec2 notEqual (vec2 x, vec2 y) {
1038 return bvec2 (x.x != y.x, x.y != y.y);
1039 }
1040 bvec3 notEqual (vec3 x, vec3 y) {
1041 return bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);
1042 }
1043 bvec4 notEqual (vec4 x, vec4 y) {
1044 return (bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);
1045 }
1046 bvec2 notEqual (ivec2 x, ivec2 y) {
1047 return (bvec2 (x.x != y.x, x.y != y.y);
1048 }
1049 bvec3 notEqual (ivec3 x, ivec3 y) {
1050 return (bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);
1051 }
1052 bvec4 notEqual (ivec4 x, ivec4 y) {
1053 return (bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);
1054 }
1055
1056 //
1057 // Returns true if any component of x is true.
1058 //
1059
1060 bool any (bvec2 x) {
1061 return x.x || x.y;
1062 }
1063 bool any (bvec3 x) {
1064 return x.x || x.y || x.z;
1065 }
1066 bool any (bvec4 x) {
1067 return x.x || x.y || x.z || x.w;
1068 }
1069
1070 //
1071 // Returns true only if all components of x are true.
1072 //
1073
1074 bool all (bvec2 x) {
1075 return x.x && x.y;
1076 }
1077 bool all (bvec3 x) {
1078 return x.x && x.y && x.z;
1079 }
1080 bool all (bvec4 x) {
1081 return x.x && x.y && x.z && x.w;
1082 }
1083
1084 //
1085 // Returns the component-wise logical complement of x.
1086 //
1087
1088 bvec2 not (bvec2 x) {
1089 return bvec2 (!x.x, !x.y);
1090 }
1091 bvec3 not (bvec3 x) {
1092 return bvec3 (!x.x, !x.y, !x.z);
1093 }
1094 bvec4 not (bvec4 x) {
1095 return bvec4 (!x.x, !x.y, !x.z, !x.w);
1096 }
1097
1098 //
1099 // Texture Lookup Functions
1100 //
1101 // Texture lookup functions are available to both vertex and fragment shaders. However, level
1102 // of detail is not computed by fixed functionality for vertex shaders, so there are some
1103 // differences in operation between vertex and fragment texture lookups. The functions in the table
1104 // below provide access to textures through samplers, as set up through the OpenGL API. Texture
1105 // properties such as size, pixel format, number of dimensions, filtering method, number of mip-map
1106 // levels, depth comparison, and so on are also defined by OpenGL API calls. Such properties are
1107 // taken into account as the texture is accessed via the built-in functions defined below.
1108 //
1109 // If a non-shadow texture call is made to a sampler whose texture has depth comparisons enabled,
1110 // then results are undefined. If a shadow texture call is made to a sampler whose texture does not
1111 // have depth comparisions enabled, the results are also undefined.
1112 //
1113 // In all functions below, the bias parameter is optional for fragment shaders. The bias parameter
1114 // is not accepted in a vertex shader. For a fragment shader, if bias is present, it is added to
1115 // the calculated level of detail prior to performing the texture access operation. If the bias
1116 // parameter is not provided, then the implementation automatically selects level of detail:
1117 // For a texture that is not mip-mapped, the texture is used directly. If it is mip-mapped and
1118 // running in a fragment shader, the LOD computed by the implementation is used to do the texture
1119 // lookup. If it is mip-mapped and running on the vertex shader, then the base texture is used.
1120 //
1121 // The built-ins suffixed with \93Lod\94 are allowed only in a vertex shader. For the \93Lod\94 functions,
1122 // lod is directly used as the level of detail.
1123 //
1124
1125 //
1126 // Use the texture coordinate coord to do a texture lookup in the 1D texture currently bound
1127 // to sampler. For the projective (\93Proj\94) versions, the texture coordinate coord.s is divided by
1128 // the last component of coord.
1129 //
1130 // XXX
1131 vec4 texture1D (sampler1D sampler, float coord) {
1132 return vec4 (0.0);
1133 }
1134 vec4 texture1DProj (sampler1D sampler, vec2 coord) {
1135 return texture1D (sampler, coord.s / coord.t);
1136 }
1137 vec4 texture1DProj (sampler1D sampler, vec4 coord) {
1138 return texture1D (sampler, coord.s / coord.q);
1139 }
1140
1141 //
1142 // Use the texture coordinate coord to do a texture lookup in the 2D texture currently bound
1143 // to sampler. For the projective (\93Proj\94) versions, the texture coordinate (coord.s, coord.t) is
1144 // divided by the last component of coord. The third component of coord is ignored for the vec4
1145 // coord variant.
1146 //
1147 // XXX
1148 vec4 texture2D (sampler2D sampler, vec2 coord) {
1149 return vec4 (0.0);
1150 }
1151 vec4 texture2DProj (sampler2D sampler, vec3 coord) {
1152 return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p));
1153 }
1154 vec4 texture2DProj (sampler2D sampler, vec4 coord) {
1155 return texture2D (sampler, vec2 (coord.s / coord.q, coord.t / coord.q));
1156 }
1157
1158 //
1159 // Use the texture coordinate coord to do a texture lookup in the 3D texture currently bound
1160 // to sampler. For the projective (\93Proj\94) versions, the texture coordinate is divided by coord.q.
1161 //
1162 // XXX
1163 vec4 texture3D (sampler3D sampler, vec3 coord) {
1164 return vec4 (0.0);
1165 }
1166 vec4 texture3DProj (sampler3D sampler, vec4 coord) {
1167 return texture3D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
1168 }
1169
1170 //
1171 // Use the texture coordinate coord to do a texture lookup in the cube map texture currently bound
1172 // to sampler. The direction of coord is used to select which face to do a 2-dimensional texture
1173 // lookup in, as described in section 3.8.6 in version 1.4 of the OpenGL specification.
1174 //
1175 // XXX
1176 vec4 textureCube (samplerCube sampler, vec3 coord) {
1177 return vec4 (0.0);
1178 }
1179
1180 //
1181 // Use texture coordinate coord to do a depth comparison lookup on the depth texture bound
1182 // to sampler, as described in section 3.8.14 of version 1.4 of the OpenGL specification. The 3rd
1183 // component of coord (coord.p) is used as the R value. The texture bound to sampler must be a
1184 // depth texture, or results are undefined. For the projective (\93Proj\94) version of each built-in,
1185 // the texture coordinate is divide by coord.q, giving a depth value R of coord.p/coord.q. The
1186 // second component of coord is ignored for the \931D\94 variants.
1187 //
1188 // XXX
1189 vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {
1190 return vec4 (0.0);
1191 }
1192 // XXX
1193 vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
1194 return vec4 (0.0);
1195 }
1196 vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {
1197 return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));
1198 }
1199 vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {
1200 return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
1201 }
1202
1203 //
1204 // Noise Functions
1205 //
1206 // Noise functions are available to both fragment and vertex shaders. They are stochastic functions
1207 // that can be used to increase visual complexity. Values returned by the following noise functions
1208 // give the appearance of randomness, but are not truly random. The noise functions below are
1209 // defined to have the following characteristics:
1210 //
1211 // \95 The return value(s) are always in the range [-1,1]
1212 // \95 The return value(s) have an overall average of 0.0
1213 // \95 They are repeatable, in that a particular input value will always produce the same return value
1214 // \95 They are statistically invariant under rotation (i.e., no matter how the domain is rotated, it
1215 // has the same statistical character)
1216 // \95 They have a statistical invariance under translation (i.e., no matter how the domain is
1217 // translated, it has the same statistical character)
1218 // \95 They typically give different results under translation.
1219 // \95 They have a narrow bandpass limit in frequency (i.e., it has no visible features larger or
1220 // smaller than a certain narrow size range)
1221 //
1222
1223 //
1224 // Returns a 1D noise value based on the input value x.
1225 //
1226 // XXX
1227 float noise1 (float x) {
1228 return 0.0;
1229 }
1230 // XXX
1231 float noise1 (vec2 x) {
1232 return 0.0;
1233 }
1234 // XXX
1235 float noise1 (vec3 x) {
1236 return 0.0;
1237 }
1238 // XXX
1239 float noise1 (vec4 x) {
1240 return 0.0;
1241 }
1242
1243 //
1244 // Returns a 2D noise value based on the input value x.
1245 //
1246 // XXX
1247 vec2 noise2 (float x) {
1248 return vec2 (0.0);
1249 }
1250 // XXX
1251 vec2 noise2 (vec2 x) {
1252 return vec2 (0.0);
1253 }
1254 // XXX
1255 vec2 noise2 (vec3 x) {
1256 return vec2 (0.0);
1257 }
1258 // XXX
1259 vec2 noise2 (vec4 x) {
1260 return vec2 (0.0);
1261 }
1262
1263 //
1264 // Returns a 3D noise value based on the input value x.
1265 //
1266 // XXX
1267 vec3 noise3 (float x) {
1268 return vec3 (0.0);
1269 }
1270 // XXX
1271 vec3 noise3 (vec2 x) {
1272 return vec3 (0.0);
1273 }
1274 // XXX
1275 vec3 noise3 (vec3 x) {
1276 return vec3 (0.0);
1277 }
1278 // XXX
1279 vec3 noise3 (vec4 x) {
1280 return vec3 (0.0);
1281 }
1282
1283 //
1284 // Returns a 4D noise value based on the input value x.
1285 //
1286 // XXX
1287 vec4 noise4 (float x) {
1288 return vec4 (0.0);
1289 }
1290 // XXX
1291 vec4 noise4 (vec2 x) {
1292 return vec4 (0.0);
1293 }
1294 // XXX
1295 vec4 noise4 (vec3 x) {
1296 return vec4 (0.0);
1297 }
1298 // XXX
1299 vec4 noise4 (vec4 x) {
1300 return vec4 (0.0);
1301 }
1302