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