ee5befae |
1 | // This file has been automatically generated from resource file src/Shaders/Declarations.glsl |
2 | |
3 | static const char Shaders_Declarations_glsl[] = |
ee5befae |
4 | "\n" |
d95f5ce1 |
5 | "//! @file Declarations.glsl includes definition of common uniform variables in OCCT GLSL programs\n" |
daf73ab7 |
6 | "//! @def THE_MAX_LIGHTS\n" |
7 | "//! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager.\n" |
8 | "// #define THE_MAX_LIGHTS 8\n" |
9 | "\n" |
10 | "//! @def THE_MAX_CLIP_PLANES\n" |
11 | "//! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager.\n" |
12 | "// #define THE_MAX_CLIP_PLANES 8\n" |
ee5befae |
13 | "\n" |
b17e5bae |
14 | "//! @def THE_NB_FRAG_OUTPUTS\n" |
15 | "//! Specifies the length of array of Fragment Shader outputs, which is 1 by default. Defined by Shader Manager.\n" |
16 | "// #define THE_NB_FRAG_OUTPUTS 1\n" |
17 | "\n" |
ee5befae |
18 | "// compatibility macros\n" |
19 | "#if (__VERSION__ >= 130)\n" |
20 | " #define THE_ATTRIBUTE in\n" |
21 | " #define THE_SHADER_IN in\n" |
22 | " #define THE_SHADER_OUT out\n" |
23 | " #define THE_OUT out\n" |
ff6665dc |
24 | " #define occTexture1D texture\n" |
ee5befae |
25 | " #define occTexture2D texture\n" |
ff6665dc |
26 | " #define occTexture3D texture\n" |
67312b79 |
27 | " #define occTextureCube texture\n" |
28 | " #define occTextureCubeLod textureLod\n" |
ee5befae |
29 | "#else\n" |
30 | " #define THE_ATTRIBUTE attribute\n" |
31 | " #define THE_SHADER_IN varying\n" |
32 | " #define THE_SHADER_OUT varying\n" |
33 | " #define THE_OUT\n" |
ff6665dc |
34 | " #define occTexture1D texture1D\n" |
ee5befae |
35 | " #define occTexture2D texture2D\n" |
ff6665dc |
36 | " #define occTexture3D texture3D\n" |
67312b79 |
37 | " #define occTextureCube textureCube\n" |
75642c14 |
38 | " #if !defined(GL_ES) || defined(textureCubeLod)\n" |
39 | " #define occTextureCubeLod textureCubeLod\n" |
40 | " #else // fallback\n" |
41 | " #define occTextureCubeLod(theSampl,theCoord,theLod) textureCube(theSampl,theCoord)\n" |
42 | " #endif\n" |
ee5befae |
43 | "#endif\n" |
44 | "\n" |
45 | "#ifdef GL_ES\n" |
67312b79 |
46 | "#if (__VERSION__ >= 300)\n" |
47 | " #define THE_PREC_ENUM highp // lowp should be enough for enums but triggers driver bugs\n" |
48 | "#else\n" |
49 | " #define THE_PREC_ENUM lowp\n" |
50 | "#endif\n" |
ee5befae |
51 | "#else\n" |
52 | " #define THE_PREC_ENUM\n" |
53 | "#endif\n" |
54 | "\n" |
55 | "// Vertex attributes\n" |
56 | "#ifdef VERTEX_SHADER\n" |
57 | " THE_ATTRIBUTE vec4 occVertex;\n" |
58 | " THE_ATTRIBUTE vec3 occNormal;\n" |
59 | " THE_ATTRIBUTE vec4 occTexCoord;\n" |
60 | " THE_ATTRIBUTE vec4 occVertColor;\n" |
8e0a2b19 |
61 | "#elif defined(FRAGMENT_SHADER)\n" |
62 | " #if (__VERSION__ >= 130)\n" |
63 | " #ifdef OCC_ENABLE_draw_buffers\n" |
b17e5bae |
64 | " out vec4 occFragColorArray[THE_NB_FRAG_OUTPUTS];\n" |
65 | " #define occFragColorArrayAlias occFragColorArray\n" |
66 | " #define occFragColor0 occFragColorArray[0]\n" |
8e0a2b19 |
67 | " #else\n" |
b17e5bae |
68 | " out vec4 occFragColor0;\n" |
8e0a2b19 |
69 | " #endif\n" |
177781da |
70 | " #else\n" |
8e0a2b19 |
71 | " #ifdef OCC_ENABLE_draw_buffers\n" |
b17e5bae |
72 | " #define occFragColorArrayAlias gl_FragData\n" |
73 | " #define occFragColor0 gl_FragData[0]\n" |
8e0a2b19 |
74 | " #else\n" |
b17e5bae |
75 | " #define occFragColor0 gl_FragColor\n" |
8e0a2b19 |
76 | " #endif\n" |
a1073ae2 |
77 | " #endif\n" |
b17e5bae |
78 | "\n" |
79 | " #if (THE_NB_FRAG_OUTPUTS >= 2)\n" |
80 | " #define occFragColor1 occFragColorArrayAlias[1]\n" |
81 | " #else\n" |
82 | " vec4 occFragColor1;\n" |
83 | " #endif\n" |
84 | " #if (THE_NB_FRAG_OUTPUTS >= 3)\n" |
85 | " #define occFragColor2 occFragColorArrayAlias[2]\n" |
86 | " #else\n" |
87 | " vec4 occFragColor2;\n" |
88 | " #endif\n" |
89 | " #if (THE_NB_FRAG_OUTPUTS >= 4)\n" |
90 | " #define occFragColor3 occFragColorArrayAlias[3]\n" |
91 | " #else\n" |
92 | " vec4 occFragColor3;\n" |
93 | " #endif\n" |
94 | "\n" |
95 | " // Built-in outputs notation\n" |
96 | " #define occFragColor occFragColor0\n" |
97 | " #define occFragCoverage occFragColor1\n" |
98 | "\n" |
78c4e836 |
99 | " #define occPeelDepth occFragColor0\n" |
100 | " #define occPeelFrontColor occFragColor1\n" |
101 | " #define occPeelBackColor occFragColor2\n" |
102 | "\n" |
103 | " //! Define the main Fragment Shader early return procedure.\n" |
104 | " bool occFragEarlyReturn();\n" |
105 | "\n" |
b17e5bae |
106 | " //! Define the main Fragment Shader output - color value.\n" |
107 | " void occSetFragColor (in vec4 theColor);\n" |
ee5befae |
108 | "#endif\n" |
109 | "\n" |
67312b79 |
110 | "// Pi number definitions\n" |
111 | "#define PI 3.141592654\n" |
112 | "#define PI_2 6.283185307\n" |
113 | "#define PI_DIV_2 1.570796327\n" |
114 | "#define PI_DIV_3 1.047197551\n" |
115 | "#define PI_DIV_4 0.785398163\n" |
116 | "#define INV_PI 0.318309886\n" |
117 | "#define INV_PI_2 0.159154943\n" |
118 | "\n" |
ee5befae |
119 | "// Matrix state\n" |
120 | "uniform mat4 occWorldViewMatrix; //!< World-view matrix\n" |
121 | "uniform mat4 occProjectionMatrix; //!< Projection matrix\n" |
122 | "uniform mat4 occModelWorldMatrix; //!< Model-world matrix\n" |
123 | "\n" |
124 | "uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix\n" |
125 | "uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix\n" |
126 | "uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix\n" |
127 | "\n" |
128 | "uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix\n" |
129 | "uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix\n" |
130 | "uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix\n" |
131 | "\n" |
132 | "uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix\n" |
133 | "uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix\n" |
134 | "uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix\n" |
135 | "\n" |
67312b79 |
136 | "#if defined(THE_IS_PBR)\n" |
137 | "uniform sampler2D occEnvLUT; //!< Environment Lookup Table\n" |
138 | "uniform sampler2D occDiffIBLMapSHCoeffs; //!< Packed diffuse (irradiance) IBL map's spherical harmonics coefficients\n" |
139 | "uniform samplerCube occSpecIBLMap; //!< Specular IBL map\n" |
140 | "uniform int occNbSpecIBLLevels; //!< Number of mipmap levels used in occSpecIBLMap to store different roughness values maps\n" |
141 | "\n" |
142 | "vec3 occDiffIBLMap (in vec3 theNormal); //!< Unpacks spherical harmonics coefficients to diffuse IBL map's values\n" |
143 | "#endif\n" |
144 | "\n" |
565baee6 |
145 | "// light type enumeration (same as Graphic3d_TypeOfLightSource)\n" |
ee5befae |
146 | "const int OccLightType_Direct = 1; //!< directional light source\n" |
147 | "const int OccLightType_Point = 2; //!< isotropic point light source\n" |
148 | "const int OccLightType_Spot = 3; //!< spot light source\n" |
149 | "\n" |
150 | "// Light sources\n" |
151 | "uniform vec4 occLightAmbient; //!< Cumulative ambient color\n" |
daf73ab7 |
152 | "#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n" |
8f8fe4a9 |
153 | "#if (THE_MAX_LIGHTS > 1)\n" |
154 | " #define occLight_Index(theId) theId\n" |
155 | "#else\n" |
156 | " #define occLight_Index(theId) 0\n" |
157 | "#endif\n" |
ee5befae |
158 | "uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n" |
565baee6 |
159 | "\n" |
160 | "//! Type of light source, int (see OccLightType enum).\n" |
8f8fe4a9 |
161 | "#define occLight_Type(theId) occLightSourcesTypes[occLight_Index(theId)]\n" |
565baee6 |
162 | "\n" |
9504a30d |
163 | "//! Specular intensity (equals to diffuse), vec3.\n" |
8f8fe4a9 |
164 | "#define occLight_Specular(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n" |
565baee6 |
165 | "\n" |
9504a30d |
166 | "//! Intensity of light source (>= 0), float.\n" |
8f8fe4a9 |
167 | "#define occLight_Intensity(theId) occLightSources[occLight_Index(theId) * 4 + 0].a\n" |
565baee6 |
168 | "\n" |
37f80e16 |
169 | "//! Is light a headlight, bool? DEPRECATED method.\n" |
170 | "#define occLight_IsHeadlight(theId) false\n" |
565baee6 |
171 | "\n" |
37f80e16 |
172 | "//! Position of specified light source or direction of directional light source, vec3.\n" |
8f8fe4a9 |
173 | "#define occLight_Position(theId) occLightSources[occLight_Index(theId) * 4 + 1].xyz\n" |
9504a30d |
174 | "\n" |
175 | "//! Direction of specified spot light source, vec3.\n" |
8f8fe4a9 |
176 | "#define occLight_SpotDirection(theId) occLightSources[occLight_Index(theId) * 4 + 2].xyz\n" |
565baee6 |
177 | "\n" |
88b312d3 |
178 | "//! Range on which point light source (positional or spot) can affect (>= 0), float.\n" |
8f8fe4a9 |
179 | "#define occLight_Range(theId) occLightSources[occLight_Index(theId) * 4 + 2].w\n" |
88b312d3 |
180 | "\n" |
565baee6 |
181 | "//! Maximum spread angle of the spot light (in radians), float.\n" |
8f8fe4a9 |
182 | "#define occLight_SpotCutOff(theId) occLightSources[occLight_Index(theId) * 4 + 3].z\n" |
565baee6 |
183 | "\n" |
184 | "//! Attenuation of the spot light intensity (from 0 to 1), float.\n" |
8f8fe4a9 |
185 | "#define occLight_SpotExponent(theId) occLightSources[occLight_Index(theId) * 4 + 3].w\n" |
565baee6 |
186 | "\n" |
9504a30d |
187 | "#if !defined(THE_IS_PBR)\n" |
188 | "//! Diffuse intensity (equals to Specular), vec3.\n" |
8f8fe4a9 |
189 | "#define occLight_Diffuse(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n" |
565baee6 |
190 | "\n" |
191 | "//! Const attenuation factor of positional light source, float.\n" |
8f8fe4a9 |
192 | "#define occLight_ConstAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].x\n" |
565baee6 |
193 | "\n" |
194 | "//! Linear attenuation factor of positional light source, float.\n" |
8f8fe4a9 |
195 | "#define occLight_LinearAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].y\n" |
daf73ab7 |
196 | "#endif\n" |
67312b79 |
197 | "#endif\n" |
198 | "\n" |
72f6dc61 |
199 | "#if defined(THE_IS_PBR)\n" |
200 | "//! Converts roughness value from range [0, 1] to real value for calculations\n" |
67312b79 |
201 | "float occRoughness (in float theNormalizedRoughness);\n" |
ee5befae |
202 | "\n" |
72f6dc61 |
203 | "// Front/back material properties accessors\n" |
204 | "vec4 occPBRMaterial_Color(in bool theIsFront); //!< Base color of PBR material\n" |
205 | "float occPBRMaterial_Metallic(in bool theIsFront); //!< Metallic coefficient\n" |
206 | "float occPBRMaterial_NormalizedRoughness(in bool theIsFront); //!< Normalized roughness coefficient\n" |
207 | "vec3 occPBRMaterial_Emission(in bool theIsFront); //!< Light intensity emitted by material\n" |
208 | "float occPBRMaterial_IOR(in bool theIsFront); //!< Index of refraction\n" |
941f6cae |
209 | "#define occMaterial_Emission occPBRMaterial_Emission\n" |
210 | "#define occMaterial_Color occPBRMaterial_Color\n" |
67312b79 |
211 | "#else\n" |
941f6cae |
212 | "vec4 occMaterial_Diffuse(in bool theIsFront); //!< Diffuse reflection\n" |
213 | "vec3 occMaterial_Specular(in bool theIsFront); //!< Specular reflection\n" |
214 | "float occMaterial_Shininess(in bool theIsFront); //!< Specular exponent\n" |
215 | "vec3 occMaterial_Ambient(in bool theIsFront); //!< Ambient reflection\n" |
216 | "vec3 occMaterial_Emission(in bool theIsFront); //!< Emission color\n" |
217 | "#define occMaterial_Color occMaterial_Diffuse\n" |
67312b79 |
218 | "#endif\n" |
ee5befae |
219 | "\n" |
737e9a8d |
220 | "#ifdef THE_HAS_DEFAULT_SAMPLER\n" |
72f6dc61 |
221 | "#define occActiveSampler occSampler0 //!< alias for backward compatibility\n" |
222 | "#define occSamplerBaseColor occSampler0 //!< alias to a base color texture\n" |
223 | "uniform sampler2D occSampler0; //!< current active sampler;\n" |
224 | "#endif //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing\n" |
225 | "\n" |
941f6cae |
226 | "#if defined(THE_HAS_TEXTURE_COLOR) && defined(FRAGMENT_SHADER)\n" |
227 | "#define occMaterialBaseColor(theIsFront, theTexCoord) (occMaterial_Color(theIsFront) * occTexture2D(occSamplerBaseColor, theTexCoord))\n" |
72f6dc61 |
228 | "#else\n" |
941f6cae |
229 | "#define occMaterialBaseColor(theIsFront, theTexCoord) occMaterial_Color(theIsFront)\n" |
72f6dc61 |
230 | "#endif\n" |
231 | "\n" |
232 | "#if defined(THE_HAS_TEXTURE_OCCLUSION) && defined(FRAGMENT_SHADER)\n" |
233 | "uniform sampler2D occSamplerOcclusion; //!< R occlusion texture sampler\n" |
941f6cae |
234 | "#define occMaterialOcclusion(theColor, theTexCoord) theColor *= occTexture2D(occSamplerOcclusion, theTexCoord).r;\n" |
72f6dc61 |
235 | "#else\n" |
941f6cae |
236 | "#define occMaterialOcclusion(theColor, theTexCoord)\n" |
737e9a8d |
237 | "#endif\n" |
72f6dc61 |
238 | "\n" |
239 | "#if defined(THE_HAS_TEXTURE_EMISSIVE) && defined(FRAGMENT_SHADER)\n" |
240 | "uniform sampler2D occSamplerEmissive; //!< RGB emissive texture sampler\n" |
941f6cae |
241 | "#define occMaterialEmission(theIsFront, theTexCoord) (occMaterial_Emission(theIsFront) * occTexture2D(occSamplerEmissive, theTexCoord).rgb)\n" |
72f6dc61 |
242 | "#else\n" |
941f6cae |
243 | "#define occMaterialEmission(theIsFront, theTexCoord) occMaterial_Emission(theIsFront)\n" |
72f6dc61 |
244 | "#endif\n" |
245 | "\n" |
246 | "#if defined(THE_HAS_TEXTURE_NORMAL) && defined(FRAGMENT_SHADER)\n" |
247 | "uniform sampler2D occSamplerNormal; //!< XYZ normal texture sampler with W==0 indicating no texture\n" |
248 | "#define occTextureNormal(theTexCoord) occTexture2D(occSamplerNormal, theTexCoord)\n" |
249 | "#else\n" |
250 | "#define occTextureNormal(theTexCoord) vec4(0.0) // no normal map\n" |
251 | "#endif\n" |
252 | "\n" |
253 | "#if defined(THE_HAS_TEXTURE_METALROUGHNESS) && defined(FRAGMENT_SHADER)\n" |
254 | "uniform sampler2D occSamplerMetallicRoughness; //!< BG metallic-roughness texture sampler\n" |
941f6cae |
255 | "#define occMaterialRoughness(theIsFront, theTexCoord) (occPBRMaterial_NormalizedRoughness(theIsFront) * occTexture2D(occSamplerMetallicRoughness, theTexCoord).g)\n" |
256 | "#define occMaterialMetallic(theIsFront, theTexCoord) (occPBRMaterial_Metallic(theIsFront) * occTexture2D(occSamplerMetallicRoughness, theTexCoord).b)\n" |
72f6dc61 |
257 | "#else\n" |
941f6cae |
258 | "#define occMaterialRoughness(theIsFront, theTexCoord) occPBRMaterial_NormalizedRoughness(theIsFront)\n" |
259 | "#define occMaterialMetallic(theIsFront, theTexCoord) occPBRMaterial_Metallic(theIsFront)\n" |
72f6dc61 |
260 | "#endif\n" |
261 | "\n" |
ee5befae |
262 | "uniform vec4 occColor; //!< color value (in case of disabled lighting)\n" |
263 | "uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?\n" |
264 | "uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?\n" |
ee5befae |
265 | "uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters\n" |
266 | "uniform float occPointSize; //!< point size\n" |
267 | "\n" |
a1073ae2 |
268 | "//! Parameters of blended order-independent transparency rendering algorithm\n" |
269 | "uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage)\n" |
270 | "uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment\n" |
c40eb6b9 |
271 | "uniform float occAlphaCutoff; //!< alpha test cutoff value\n" |
a1073ae2 |
272 | "\n" |
ee5befae |
273 | "//! Parameters of clipping planes\n" |
daf73ab7 |
274 | "#if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)\n" |
ee5befae |
275 | "uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];\n" |
25c35042 |
276 | "uniform THE_PREC_ENUM int occClipPlaneChains[THE_MAX_CLIP_PLANES]; //! Indicating the number of planes in the Chain\n" |
daf73ab7 |
277 | "uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n" |
d95f5ce1 |
278 | "#endif\n" |
279 | "//! @endfile Declarations.glsl\n"; |