1 // This file has been automatically generated from resource file src/Shaders/Declarations.glsl
3 static const char Shaders_Declarations_glsl[] =
5 "//! @file Declarations.glsl includes definition of common uniform variables in OCCT GLSL programs\n"
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"
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"
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"
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"
24 " #define occTexture1D texture\n"
25 " #define occTexture2D texture\n"
26 " #define occTexture3D texture\n"
27 " #define occTextureCube texture\n"
28 " #define occTextureCubeLod textureLod\n"
30 " #define THE_ATTRIBUTE attribute\n"
31 " #define THE_SHADER_IN varying\n"
32 " #define THE_SHADER_OUT varying\n"
34 " #define occTexture1D texture1D\n"
35 " #define occTexture2D texture2D\n"
36 " #define occTexture3D texture3D\n"
37 " #define occTextureCube textureCube\n"
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"
46 "#if (__VERSION__ >= 300)\n"
47 " #define THE_PREC_ENUM highp // lowp should be enough for enums but triggers driver bugs\n"
49 " #define THE_PREC_ENUM lowp\n"
52 " #define THE_PREC_ENUM\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"
61 "#elif defined(FRAGMENT_SHADER)\n"
62 " #if (__VERSION__ >= 130)\n"
63 " #ifdef OCC_ENABLE_draw_buffers\n"
64 " out vec4 occFragColorArray[THE_NB_FRAG_OUTPUTS];\n"
65 " #define occFragColorArrayAlias occFragColorArray\n"
66 " #define occFragColor0 occFragColorArray[0]\n"
68 " out vec4 occFragColor0;\n"
71 " #ifdef OCC_ENABLE_draw_buffers\n"
72 " #define occFragColorArrayAlias gl_FragData\n"
73 " #define occFragColor0 gl_FragData[0]\n"
75 " #define occFragColor0 gl_FragColor\n"
79 " #if (THE_NB_FRAG_OUTPUTS >= 2)\n"
80 " #define occFragColor1 occFragColorArrayAlias[1]\n"
82 " vec4 occFragColor1;\n"
84 " #if (THE_NB_FRAG_OUTPUTS >= 3)\n"
85 " #define occFragColor2 occFragColorArrayAlias[2]\n"
87 " vec4 occFragColor2;\n"
89 " #if (THE_NB_FRAG_OUTPUTS >= 4)\n"
90 " #define occFragColor3 occFragColorArrayAlias[3]\n"
92 " vec4 occFragColor3;\n"
95 " // Built-in outputs notation\n"
96 " #define occFragColor occFragColor0\n"
97 " #define occFragCoverage occFragColor1\n"
99 " #define occPeelDepth occFragColor0\n"
100 " #define occPeelFrontColor occFragColor1\n"
101 " #define occPeelBackColor occFragColor2\n"
103 " //! Define the main Fragment Shader early return procedure.\n"
104 " bool occFragEarlyReturn();\n"
106 " //! Define the main Fragment Shader output - color value.\n"
107 " void occSetFragColor (in vec4 theColor);\n"
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"
120 "uniform mat4 occWorldViewMatrix; //!< World-view matrix\n"
121 "uniform mat4 occProjectionMatrix; //!< Projection matrix\n"
122 "uniform mat4 occModelWorldMatrix; //!< Model-world matrix\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"
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"
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"
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"
142 "vec3 occDiffIBLMap (in vec3 theNormal); //!< Unpacks spherical harmonics coefficients to diffuse IBL map's values\n"
145 "// light type enumeration (same as Graphic3d_TypeOfLightSource)\n"
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"
151 "uniform vec4 occLightAmbient; //!< Cumulative ambient color\n"
152 "#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
153 "#if (THE_MAX_LIGHTS > 1)\n"
154 " #define occLight_Index(theId) theId\n"
156 " #define occLight_Index(theId) 0\n"
158 "uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n"
160 "//! Type of light source, int (see OccLightType enum).\n"
161 "#define occLight_Type(theId) occLightSourcesTypes[occLight_Index(theId)]\n"
163 "//! Specular intensity (equals to diffuse), vec3.\n"
164 "#define occLight_Specular(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n"
166 "//! Intensity of light source (>= 0), float.\n"
167 "#define occLight_Intensity(theId) occLightSources[occLight_Index(theId) * 4 + 0].a\n"
169 "//! Is light a headlight, bool? DEPRECATED method.\n"
170 "#define occLight_IsHeadlight(theId) false\n"
172 "//! Position of specified light source or direction of directional light source, vec3.\n"
173 "#define occLight_Position(theId) occLightSources[occLight_Index(theId) * 4 + 1].xyz\n"
175 "//! Direction of specified spot light source, vec3.\n"
176 "#define occLight_SpotDirection(theId) occLightSources[occLight_Index(theId) * 4 + 2].xyz\n"
178 "//! Range on which point light source (positional or spot) can affect (>= 0), float.\n"
179 "#define occLight_Range(theId) occLightSources[occLight_Index(theId) * 4 + 2].w\n"
181 "//! Maximum spread angle of the spot light (in radians), float.\n"
182 "#define occLight_SpotCutOff(theId) occLightSources[occLight_Index(theId) * 4 + 3].z\n"
184 "//! Attenuation of the spot light intensity (from 0 to 1), float.\n"
185 "#define occLight_SpotExponent(theId) occLightSources[occLight_Index(theId) * 4 + 3].w\n"
187 "#if !defined(THE_IS_PBR)\n"
188 "//! Diffuse intensity (equals to Specular), vec3.\n"
189 "#define occLight_Diffuse(theId) occLightSources[occLight_Index(theId) * 4 + 0].rgb\n"
191 "//! Const attenuation factor of positional light source, float.\n"
192 "#define occLight_ConstAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].x\n"
194 "//! Linear attenuation factor of positional light source, float.\n"
195 "#define occLight_LinearAttenuation(theId) occLightSources[occLight_Index(theId) * 4 + 3].y\n"
199 "#if defined(THE_IS_PBR)\n"
200 "//! Converts roughness value from range [0, 1] to real value for calculations\n"
201 "float occRoughness (in float theNormalizedRoughness);\n"
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"
210 "// Front material properties accessors\n"
211 "vec4 occFrontMaterial_Emission(void); //!< Emission color\n"
212 "vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection\n"
213 "vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection\n"
214 "vec4 occFrontMaterial_Specular(void); //!< Specular reflection\n"
215 "float occFrontMaterial_Shininess(void); //!< Specular exponent\n"
216 "float occFrontMaterial_Transparency(void); //!< Transparency coefficient\n"
218 "// Back material properties accessors\n"
219 "vec4 occBackMaterial_Emission(void); //!< Emission color\n"
220 "vec4 occBackMaterial_Ambient(void); //!< Ambient reflection\n"
221 "vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection\n"
222 "vec4 occBackMaterial_Specular(void); //!< Specular reflection\n"
223 "float occBackMaterial_Shininess(void); //!< Specular exponent\n"
224 "float occBackMaterial_Transparency(void); //!< Transparency coefficient\n"
227 "#ifdef THE_HAS_DEFAULT_SAMPLER\n"
228 "#define occActiveSampler occSampler0 //!< alias for backward compatibility\n"
229 "#define occSamplerBaseColor occSampler0 //!< alias to a base color texture\n"
230 "uniform sampler2D occSampler0; //!< current active sampler;\n"
231 "#endif //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing\n"
233 "#if defined(THE_HAS_TEXTURE_COLOR)\n"
234 "#define occTextureColor(theMatColor, theTexCoord) (theMatColor * occTexture2D(occSamplerBaseColor, theTexCoord))\n"
236 "#define occTextureColor(theMatColor, theTexCoord) theMatColor\n"
239 "#if defined(THE_HAS_TEXTURE_OCCLUSION) && defined(FRAGMENT_SHADER)\n"
240 "uniform sampler2D occSamplerOcclusion; //!< R occlusion texture sampler\n"
241 "#define occTextureOcclusion(theColor, theTexCoord) theColor *= occTexture2D(occSamplerOcclusion, theTexCoord).r;\n"
243 "#define occTextureOcclusion(theColor, theTexCoord)\n"
246 "#if defined(THE_HAS_TEXTURE_EMISSIVE) && defined(FRAGMENT_SHADER)\n"
247 "uniform sampler2D occSamplerEmissive; //!< RGB emissive texture sampler\n"
248 "#define occTextureEmissive(theMatEmis, theTexCoord) (theMatEmis * occTexture2D(occSamplerEmissive, theTexCoord).rgb)\n"
250 "#define occTextureEmissive(theMatEmis, theTexCoord) theMatEmis\n"
253 "#if defined(THE_HAS_TEXTURE_NORMAL) && defined(FRAGMENT_SHADER)\n"
254 "uniform sampler2D occSamplerNormal; //!< XYZ normal texture sampler with W==0 indicating no texture\n"
255 "#define occTextureNormal(theTexCoord) occTexture2D(occSamplerNormal, theTexCoord)\n"
257 "#define occTextureNormal(theTexCoord) vec4(0.0) // no normal map\n"
260 "#if defined(THE_HAS_TEXTURE_METALROUGHNESS) && defined(FRAGMENT_SHADER)\n"
261 "uniform sampler2D occSamplerMetallicRoughness; //!< BG metallic-roughness texture sampler\n"
262 "#define occTextureRoughness(theRoug, theTexCoord) (theRoug * occTexture2D(occSamplerMetallicRoughness, theTexCoord).g)\n"
263 "#define occTextureMetallic(theMet, theTexCoord) (theMet * occTexture2D(occSamplerMetallicRoughness, theTexCoord).b)\n"
265 "#define occTextureRoughness(theRoug, theTexCoord) theRoug\n"
266 "#define occTextureMetallic(theMet, theTexCoord) theMet\n"
269 "uniform vec4 occColor; //!< color value (in case of disabled lighting)\n"
270 "uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?\n"
271 "uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?\n"
272 "uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters\n"
273 "uniform float occPointSize; //!< point size\n"
275 "//! Parameters of blended order-independent transparency rendering algorithm\n"
276 "uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage)\n"
277 "uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment\n"
278 "uniform float occAlphaCutoff; //!< alpha test cutoff value\n"
280 "//! Parameters of clipping planes\n"
281 "#if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)\n"
282 "uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];\n"
283 "uniform THE_PREC_ENUM int occClipPlaneChains[THE_MAX_CLIP_PLANES]; //! Indicating the number of planes in the Chain\n"
284 "uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n"
286 "//! @endfile Declarations.glsl\n";