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