2 //! @file Declarations.glsl includes definition of common uniform variables in OCCT GLSL programs
3 //! @def THE_MAX_LIGHTS
4 //! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager.
5 // #define THE_MAX_LIGHTS 8
7 //! @def THE_MAX_CLIP_PLANES
8 //! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager.
9 // #define THE_MAX_CLIP_PLANES 8
11 //! @def THE_NB_FRAG_OUTPUTS
12 //! Specifies the length of array of Fragment Shader outputs, which is 1 by default. Defined by Shader Manager.
13 // #define THE_NB_FRAG_OUTPUTS 1
15 // compatibility macros
16 #if (__VERSION__ >= 130)
17 #define THE_ATTRIBUTE in
18 #define THE_SHADER_IN in
19 #define THE_SHADER_OUT out
21 #define occTexture1D texture
22 #define occTexture2D texture
23 #define occTexture3D texture
25 #define THE_ATTRIBUTE attribute
26 #define THE_SHADER_IN varying
27 #define THE_SHADER_OUT varying
29 #define occTexture1D texture1D
30 #define occTexture2D texture2D
31 #define occTexture3D texture3D
35 #define THE_PREC_ENUM lowp // enumerations should fit into lowp range
42 THE_ATTRIBUTE vec4 occVertex;
43 THE_ATTRIBUTE vec3 occNormal;
44 THE_ATTRIBUTE vec4 occTexCoord;
45 THE_ATTRIBUTE vec4 occVertColor;
46 #elif defined(FRAGMENT_SHADER)
47 #if (__VERSION__ >= 130)
48 #ifdef OCC_ENABLE_draw_buffers
49 out vec4 occFragColorArray[THE_NB_FRAG_OUTPUTS];
50 #define occFragColorArrayAlias occFragColorArray
51 #define occFragColor0 occFragColorArray[0]
53 out vec4 occFragColor0;
56 #ifdef OCC_ENABLE_draw_buffers
57 #define occFragColorArrayAlias gl_FragData
58 #define occFragColor0 gl_FragData[0]
60 #define occFragColor0 gl_FragColor
64 #if (THE_NB_FRAG_OUTPUTS >= 2)
65 #define occFragColor1 occFragColorArrayAlias[1]
69 #if (THE_NB_FRAG_OUTPUTS >= 3)
70 #define occFragColor2 occFragColorArrayAlias[2]
74 #if (THE_NB_FRAG_OUTPUTS >= 4)
75 #define occFragColor3 occFragColorArrayAlias[3]
80 // Built-in outputs notation
81 #define occFragColor occFragColor0
82 #define occFragCoverage occFragColor1
84 //! Define the main Fragment Shader output - color value.
85 void occSetFragColor (in vec4 theColor);
89 uniform mat4 occWorldViewMatrix; //!< World-view matrix
90 uniform mat4 occProjectionMatrix; //!< Projection matrix
91 uniform mat4 occModelWorldMatrix; //!< Model-world matrix
93 uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
94 uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
95 uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
97 uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
98 uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
99 uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
101 uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
102 uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
103 uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
105 // light type enumeration (same as Graphic3d_TypeOfLightSource)
106 const int OccLightType_Direct = 1; //!< directional light source
107 const int OccLightType_Point = 2; //!< isotropic point light source
108 const int OccLightType_Spot = 3; //!< spot light source
111 uniform vec4 occLightAmbient; //!< Cumulative ambient color
112 #if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)
113 uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
115 //! Type of light source, int (see OccLightType enum).
116 #define occLight_Type(theId) occLightSourcesTypes[theId].x
118 //! Is light a headlight, int?
119 #define occLight_IsHeadlight(theId) occLightSourcesTypes[theId].y
121 //! Specular intensity (equals to diffuse), vec4.
122 #define occLight_Specular(theId) occLightSources[theId * 4 + 0]
124 //! Position of specified light source, vec4.
125 #define occLight_Position(theId) occLightSources[theId * 4 + 1]
127 //! Direction of specified spot light source, vec4.
128 #define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2]
130 //! Maximum spread angle of the spot light (in radians), float.
131 #define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z
133 //! Attenuation of the spot light intensity (from 0 to 1), float.
134 #define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w
136 //! Diffuse intensity (equals to Specular), vec4.
137 #define occLight_Diffuse(theId) occLightSources[theId * 4 + 0]
139 //! Const attenuation factor of positional light source, float.
140 #define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x
142 //! Linear attenuation factor of positional light source, float.
143 #define occLight_LinearAttenuation(theId) occLightSources[theId * 4 + 3].y
146 // Front material properties accessors
147 vec4 occFrontMaterial_Emission(void); //!< Emission color
148 vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
149 vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
150 vec4 occFrontMaterial_Specular(void); //!< Specular reflection
151 float occFrontMaterial_Shininess(void); //!< Specular exponent
152 float occFrontMaterial_Transparency(void); //!< Transparency coefficient
154 // Back material properties accessors
155 vec4 occBackMaterial_Emission(void); //!< Emission color
156 vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
157 vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
158 vec4 occBackMaterial_Specular(void); //!< Specular reflection
159 float occBackMaterial_Shininess(void); //!< Specular exponent
160 float occBackMaterial_Transparency(void); //!< Transparency coefficient
162 #ifdef THE_HAS_DEFAULT_SAMPLER
163 #define occActiveSampler occSampler0 //!< alias for backward compatibility
164 #define occSamplerBaseColor occSampler0 //!< alias to a base color texture
165 uniform sampler2D occSampler0; //!< current active sampler;
167 //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing
168 uniform vec4 occColor; //!< color value (in case of disabled lighting)
169 uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
170 uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
171 uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters
172 uniform float occPointSize; //!< point size
174 //! Parameters of blended order-independent transparency rendering algorithm
175 uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage)
176 uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment
177 uniform float occAlphaCutoff; //!< alpha test cutoff value
179 //! Parameters of clipping planes
180 #if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)
181 uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
182 uniform THE_PREC_ENUM int occClipPlaneChains[THE_MAX_CLIP_PLANES]; //! Indicating the number of planes in the Chain
183 uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes
185 //! @endfile Declarations.glsl