OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / share / qtcreator / glsl / glsl_120_common.glsl
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 // Built-in constants.
34 const int gl_MaxLights = 8;
35 const int gl_MaxClipPlanes = 6;
36 const int gl_MaxTextureUnits = 2;
37 const int gl_MaxTextureCoords = 2;
38 const int gl_MaxVertexAttribs = 16;
39 const int gl_MaxVertexUniformComponents = 512;
40 const int gl_MaxVaryingFloats = 32;
41 const int gl_MaxVertexTextureImageUnits = 0;
42 const int gl_MaxCombinedTextureImageUnits = 2;
43 const int gl_MaxTextureImageUnits = 2;
44 const int gl_MaxFragmentUniformComponents = 64;
45 const int gl_MaxDrawBuffers = 1;
46
47 // Built-in uniform state.
48 uniform mat4 gl_ModelViewMatrix;
49 uniform mat4 gl_ProjectionMatrix;
50 uniform mat4 gl_ModelViewProjectionMatrix;
51 uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
52 uniform mat3 gl_NormalMatrix;
53
54 uniform mat4 gl_ModelViewMatrixInverse;
55 uniform mat4 gl_ProjectionMatrixInverse;
56 uniform mat4 gl_ModelViewProjectionMatrixInverse;
57 uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];
58
59 uniform mat4 gl_ModelViewMatrixTranspose;
60 uniform mat4 gl_ProjectionMatrixTranspose;
61 uniform mat4 gl_ModelViewProjectionMatrixTranspose;
62 uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];
63
64 uniform mat4 gl_ModelViewMatrixInverseTranspose;
65 uniform mat4 gl_ProjectionMatrixInverseTranspose;
66 uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;
67 uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];
68
69 uniform float gl_NormalScale;
70
71 struct gl_DepthRangeParameters {
72     float near;
73     float far;
74     float diff;
75 };
76 uniform gl_DepthRangeParameters gl_DepthRange;
77
78 uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
79
80 struct gl_PointParameters {
81     float size;
82     float sizeMin;
83     float sizeMax;
84     float fadeThresholdSize;
85     float distanceConstantAttenuation;
86     float distanceLinearAttenuation;
87     float distanceQuadraticAttenuation;
88 };
89 uniform gl_PointParameters gl_Point;
90
91 struct gl_MaterialParameters {
92     vec4  emission;
93     vec4  ambient;
94     vec4  diffuse;
95     vec4  specular;
96     float shininess;
97 };
98 uniform gl_MaterialParameters gl_FrontMaterial;
99 uniform gl_MaterialParameters gl_BackMaterial;
100
101 struct gl_LightSourceParameters {
102     vec4  ambient;
103     vec4  diffuse;
104     vec4  specular;
105     vec4  position;
106     vec4  halfVector;
107     vec3  spotDirection;
108     float spotExponent;
109     float spotCutoff;
110     float spotCosCutoff;
111     float constantAttenuation;
112     float linearAttenuation;
113     float quadraticAttenuation;
114 };
115 uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
116
117 struct gl_LightModelParameters {
118     vec4  ambient;
119 };
120 uniform gl_LightModelParameters gl_LightModel;
121
122 struct gl_LightModelProducts {
123     vec4  sceneColor;
124 };
125 uniform gl_LightModelProducts gl_FrontLightModelProduct;
126 uniform gl_LightModelProducts gl_BackLightModelProduct;
127
128 struct gl_LightProducts {
129     vec4  ambient;
130     vec4  diffuse;
131     vec4  specular;
132 };
133 uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
134 uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
135
136 uniform vec4 gl_TextureEnvColor[gl_MaxTextureUnits];
137 uniform vec4 gl_EyePlaneS[gl_MaxTextureUnits];
138 uniform vec4 gl_EyePlaneT[gl_MaxTextureUnits];
139 uniform vec4 gl_EyePlaneR[gl_MaxTextureUnits];
140 uniform vec4 gl_EyePlaneQ[gl_MaxTextureUnits];
141 uniform vec4 gl_ObjectPlaneS[gl_MaxTextureUnits];
142 uniform vec4 gl_ObjectPlaneT[gl_MaxTextureUnits];
143 uniform vec4 gl_ObjectPlaneR[gl_MaxTextureUnits];
144 uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureUnits];
145
146 struct gl_FogParameters {
147     vec4  color;
148     float density;
149     float start;
150     float end;
151     float scale;
152 };
153 uniform gl_FogParameters gl_Fog;
154
155 // Angle and trigonometry functions.
156 float radians(float degress);
157 vec2 radians(vec2 degress);
158 vec3 radians(vec3 degress);
159 vec4 radians(vec4 degress);
160 float degrees(float radians);
161 vec2 degrees(vec2 radians);
162 vec3 degrees(vec3 radians);
163 vec4 degrees(vec4 radians);
164 float sin(float angle);
165 vec2 sin(vec2 angle);
166 vec3 sin(vec3 angle);
167 vec4 sin(vec4 angle);
168 float cos(float angle);
169 vec2 cos(vec2 angle);
170 vec3 cos(vec3 angle);
171 vec4 cos(vec4 angle);
172 float tan(float angle);
173 vec2 tan(vec2 angle);
174 vec3 tan(vec3 angle);
175 vec4 tan(vec4 angle);
176 float asin(float x);
177 vec2 asin(vec2 x);
178 vec3 asin(vec3 x);
179 vec4 asin(vec4 x);
180 float acos(float x);
181 vec2 acos(vec2 x);
182 vec3 acos(vec3 x);
183 vec4 acos(vec4 x);
184 float atan(float y, float x);
185 vec2 atan(vec2 y, vec2 x);
186 vec3 atan(vec3 y, vec3 x);
187 vec4 atan(vec4 y, vec4 x);
188 float atan(float y_over_x);
189 vec2 atan(vec2 y_over_x);
190 vec3 atan(vec3 y_over_x);
191 vec4 atan(vec4 y_over_x);
192
193 // Exponential functions.
194 float pow(float x, float y);
195 vec2 pow(vec2 x, vec2 y);
196 vec3 pow(vec3 x, vec3 y);
197 vec4 pow(vec4 x, vec4 y);
198 float exp(float x);
199 vec2 exp(vec2 x);
200 vec3 exp(vec3 x);
201 vec4 exp(vec4 x);
202 float log(float x);
203 vec2 log(vec2 x);
204 vec3 log(vec3 x);
205 vec4 log(vec4 x);
206 float exp2(float x);
207 vec2 exp2(vec2 x);
208 vec3 exp2(vec3 x);
209 vec4 exp2(vec4 x);
210 float log2(float x);
211 vec2 log2(vec2 x);
212 vec3 log2(vec3 x);
213 vec4 log2(vec4 x);
214 float sqrt(float x);
215 vec2 sqrt(vec2 x);
216 vec3 sqrt(vec3 x);
217 vec4 sqrt(vec4 x);
218 float inversesqrt(float x);
219 vec2 inversesqrt(vec2 x);
220 vec3 inversesqrt(vec3 x);
221 vec4 inversesqrt(vec4 x);
222
223 // Common functions.
224 float abs(float x);
225 vec2 abs(vec2 x);
226 vec3 abs(vec3 x);
227 vec4 abs(vec4 x);
228 float sign(float x);
229 vec2 sign(vec2 x);
230 vec3 sign(vec3 x);
231 vec4 sign(vec4 x);
232 float floor(float x);
233 vec2 floor(vec2 x);
234 vec3 floor(vec3 x);
235 vec4 floor(vec4 x);
236 float ceil(float x);
237 vec2 ceil(vec2 x);
238 vec3 ceil(vec3 x);
239 vec4 ceil(vec4 x);
240 float fract(float x);
241 vec2 fract(vec2 x);
242 vec3 fract(vec3 x);
243 vec4 fract(vec4 x);
244 float mod(float x, float y);
245 vec2 mod(vec2 x, float y);
246 vec3 mod(vec3 x, float y);
247 vec4 mod(vec4 x, float y);
248 float mod(float x, float y);
249 vec2 mod(vec2 x, vec2 y);
250 vec3 mod(vec3 x, vec3 y);
251 vec4 mod(vec4 x, vec4 y);
252 float min(float x, float y);
253 vec2 min(vec2 x, float y);
254 vec3 min(vec3 x, float y);
255 vec4 min(vec4 x, float y);
256 float min(float x, float y);
257 vec2 min(vec2 x, vec2 y);
258 vec3 min(vec3 x, vec3 y);
259 vec4 min(vec4 x, vec4 y);
260 float max(float x, float y);
261 vec2 max(vec2 x, float y);
262 vec3 max(vec3 x, float y);
263 vec4 max(vec4 x, float y);
264 float max(float x, float y);
265 vec2 max(vec2 x, vec2 y);
266 vec3 max(vec3 x, vec3 y);
267 vec4 max(vec4 x, vec4 y);
268 float clamp(float x, float minVal, float maxVal);
269 vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);
270 vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);
271 vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);
272 float clamp(float x, float minVal, float maxVal);
273 vec2 clamp(vec2 x, float minVal, float maxVal);
274 vec3 clamp(vec3 x, float minVal, float maxVal);
275 vec4 clamp(vec4 x, float minVal, float maxVal);
276 float mix(float x, float y, float a);
277 vec2 mix(vec2 x, vec2 y, vec2 a);
278 vec3 mix(vec3 x, vec3 y, vec3 a);
279 vec4 mix(vec4 x, vec4 y, vec4 a);
280 float mix(float x, float y, float a);
281 vec2 mix(vec2 x, vec2 y, float a);
282 vec3 mix(vec3 x, vec3 y, float a);
283 vec4 mix(vec4 x, vec4 y, float a);
284 float step(float edge, float x);
285 vec2 step(vec2 edge, vec2 x);
286 vec3 step(vec3 edge, vec3 x);
287 vec4 step(vec4 edge, vec4 x);
288 float step(float edge, float x);
289 vec2 step(float edge, vec2 x);
290 vec3 step(float edge, vec3 x);
291 vec4 step(float edge, vec4 x);
292 float smoothstep(float edge0, float edge1, float x);
293 vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);
294 vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);
295 vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);
296 float smoothstep(float edge0, float edge1, float x);
297 vec2 smoothstep(float edge0, float edge1, vec2 x);
298 vec3 smoothstep(float edge0, float edge1, vec3 x);
299 vec4 smoothstep(float edge0, float edge1, vec4 x);
300
301 // Geometric functions.
302 float length(float x);
303 float length(vec2 x);
304 float length(vec3 x);
305 float length(vec4 x);
306 float distance(float p0, float p1);
307 float distance(vec2 p0, vec2 p1);
308 float distance(vec3 p0, vec3 p1);
309 float distance(vec4 p0, vec4 p1);
310 float dot(float x, float y);
311 float dot(vec2 x, vec2 y);
312 float dot(vec3 x, vec3 y);
313 float dot(vec4 x, vec4 y);
314 vec3 cross(vec3 x, vec3 y);
315 float normalize(float x);
316 vec2 normalize(vec2 x);
317 vec3 normalize(vec3 x);
318 vec4 normalize(vec4 x);
319 float faceforward(float N, float I, float Nref);
320 vec2 faceforward(vec2 N, vec2 I, vec2 Nref);
321 vec3 faceforward(vec3 N, vec3 I, vec3 Nref);
322 vec4 faceforward(vec4 N, vec4 I, vec4 Nref);
323 float reflect(float I, float N);
324 vec2 reflect(vec2 I, vec2 N);
325 vec3 reflect(vec3 I, vec3 N);
326 vec4 reflect(vec4 I, vec4 N);
327 float refract(float I, float N, float eta);
328 vec2 refract(vec2 I, vec2 N, float eta);
329 vec3 refract(vec3 I, vec3 N, float eta);
330 vec4 refract(vec4 I, vec4 N, float eta);
331
332 // Matrix functions.
333 mat2 matrixCompMult(mat2 x, mat2 y);
334 mat3 matrixCompMult(mat3 x, mat3 y);
335 mat4 matrixCompMult(mat4 x, mat4 y);
336 mat2x4 matrixCompMult(mat2x4 x, mat2x4 y);
337 mat4x2 matrixCompMult(mat4x2 x, mat4x2 y);
338 mat2x3 matrixCompMult(mat2x3 x, mat2x3 y);
339 mat3x2 matrixCompMult(mat3x2 x, mat3x2 y);
340 mat3x4 matrixCompMult(mat3x4 x, mat3x4 y);
341 mat4x3 matrixCompMult(mat4x3 x, mat4x3 y);
342 mat2 outerProduct(vec2 c, vec2 r);
343 mat3 outerProduct(vec3 c, vec3 r);
344 mat4 outerProduct(vec4 c, vec4 r);
345 mat2x3 outerProduct(vec3 c, vec2 r);
346 mat3x2 outerProduct(vec2 c, vec3 r);
347 mat2x4 outerProduct(vec4 c, vec2 r);
348 mat4x2 outerProduct(vec2 c, vec4 r);
349 mat3x4 outerProduct(vec4 c, vec3 r);
350 mat4x3 outerProduct(vec3 c, vec4 r);
351 mat2 transpose(mat2 m);
352 mat3 transpose(mat3 m);
353 mat4 transpose(mat4 m);
354 mat2x3 transpose(mat3x2 m);
355 mat3x2 transpose(mat2x3 m);
356 mat2x4 transpose(mat4x2 m);
357 mat4x2 transpose(mat2x4 m);
358 mat3x4 transpose(mat4x3 m);
359 mat4x3 transpose(mat3x4 m);
360
361 // Vector relational functions.
362 bvec2 lessThan(vec2 x, vec2 y);
363 bvec2 lessThan(ivec2 x, ivec2 y);
364 bvec3 lessThan(vec3 x, vec3 y);
365 bvec3 lessThan(ivec3 x, ivec3 y);
366 bvec4 lessThan(vec4 x, vec4 y);
367 bvec4 lessThan(ivec4 x, ivec4 y);
368 bvec2 lessThanEqual(vec2 x, vec2 y);
369 bvec2 lessThanEqual(ivec2 x, ivec2 y);
370 bvec3 lessThanEqual(vec3 x, vec3 y);
371 bvec3 lessThanEqual(ivec3 x, ivec3 y);
372 bvec4 lessThanEqual(vec4 x, vec4 y);
373 bvec4 lessThanEqual(ivec4 x, ivec4 y);
374 bvec2 greaterThan(vec2 x, vec2 y);
375 bvec2 greaterThan(ivec2 x, ivec2 y);
376 bvec3 greaterThan(vec3 x, vec3 y);
377 bvec3 greaterThan(ivec3 x, ivec3 y);
378 bvec4 greaterThan(vec4 x, vec4 y);
379 bvec4 greaterThan(ivec4 x, ivec4 y);
380 bvec2 greaterThanEqual(vec2 x, vec2 y);
381 bvec2 greaterThanEqual(ivec2 x, ivec2 y);
382 bvec3 greaterThanEqual(vec3 x, vec3 y);
383 bvec3 greaterThanEqual(ivec3 x, ivec3 y);
384 bvec4 greaterThanEqual(vec4 x, vec4 y);
385 bvec4 greaterThanEqual(ivec4 x, ivec4 y);
386 bvec2 equal(vec2 x, vec2 y);
387 bvec2 equal(ivec2 x, ivec2 y);
388 bvec2 equal(bvec2 x, bvec2 y);
389 bvec3 equal(vec3 x, vec3 y);
390 bvec3 equal(ivec3 x, ivec3 y);
391 bvec3 equal(bvec3 x, bvec3 y);
392 bvec4 equal(vec4 x, vec4 y);
393 bvec4 equal(ivec4 x, ivec4 y);
394 bvec4 equal(bvec4 x, bvec4 y);
395 bvec2 notEqual(vec2 x, vec2 y);
396 bvec2 notEqual(ivec2 x, ivec2 y);
397 bvec2 notEqual(bvec2 x, bvec2 y);
398 bvec3 notEqual(vec3 x, vec3 y);
399 bvec3 notEqual(ivec3 x, ivec3 y);
400 bvec3 notEqual(bvec3 x, bvec3 y);
401 bvec4 notEqual(vec4 x, vec4 y);
402 bvec4 notEqual(ivec4 x, ivec4 y);
403 bvec4 notEqual(bvec4 x, bvec4 y);
404 bool any(bvec2 x);
405 bool any(bvec3 x);
406 bool any(bvec4 x);
407 bool all(bvec2 x);
408 bool all(bvec3 x);
409 bool all(bvec4 x);
410 bvec2 not(bvec2 x);
411 bvec3 not(bvec3 x);
412 bvec4 not(bvec4 x);
413
414 // Texture lookup functions.
415 vec4 texture1D(sampler1D sampler, float coord);
416 vec4 texture1D(sampler1D sampler, float coord, float bias);
417 vec4 texture1DProj(sampler1D sampler, vec2 coord);
418 vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);
419 vec4 texture1DProj(sampler1D sampler, vec4 coord);
420 vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);
421
422 vec4 texture2D(sampler2D sampler, vec2 coord);
423 vec4 texture2D(sampler2D sampler, vec2 coord, float bias);
424 vec4 texture2DProj(sampler2D sampler, vec3 coord);
425 vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);
426 vec4 texture2DProj(sampler2D sampler, vec4 coord);
427 vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);
428
429 vec4 texture3D(sampler3D sampler, vec3 coord);
430 vec4 texture3D(sampler3D sampler, vec3 coord, float bias);
431 vec4 texture3DProj(sampler3D sampler, vec4 coord);
432 vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);
433
434 vec4 textureCube(samplerCube sampler, vec3 coord);
435 vec4 textureCube(samplerCube sampler, vec3 coord, float bias);
436
437 vec4 shadow1D(sampler1DShadow sampler, vec3 coord);
438 vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);
439 vec4 shadow2D(sampler2DShadow sampler, vec3 coord);
440 vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);
441 vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);
442 vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);
443 vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);
444 vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);
445
446 // Noise functions.
447 float noise1(float x);
448 float noise1(vec2 x);
449 float noise1(vec3 x);
450 float noise1(vec4 x);
451 vec2 noise2(float x);
452 vec2 noise2(vec2 x);
453 vec2 noise2(vec3 x);
454 vec2 noise2(vec4 x);
455 vec3 noise3(float x);
456 vec3 noise3(vec2 x);
457 vec3 noise3(vec3 x);
458 vec3 noise3(vec4 x);
459 vec4 noise4(float x);
460 vec4 noise4(vec2 x);
461 vec4 noise4(vec3 x);
462 vec4 noise4(vec4 x);