d5f74e42 |
1 | // Created on: 2013-10-10 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
daf73ab7 |
16 | //! @file Declarations.glsl |
17 | //! This files includes definition of common uniform variables in OCCT GLSL programs |
30f0ad28 |
18 | |
daf73ab7 |
19 | //! @def THE_MAX_LIGHTS |
20 | //! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager. |
21 | // #define THE_MAX_LIGHTS 8 |
22 | |
23 | //! @def THE_MAX_CLIP_PLANES |
24 | //! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager. |
25 | // #define THE_MAX_CLIP_PLANES 8 |
30f0ad28 |
26 | |
b17e5bae |
27 | //! @def THE_NB_FRAG_OUTPUTS |
28 | //! Specifies the length of array of Fragment Shader outputs, which is 1 by default. Defined by Shader Manager. |
29 | // #define THE_NB_FRAG_OUTPUTS 1 |
30 | |
b86bb3df |
31 | // compatibility macros |
32 | #if (__VERSION__ >= 130) |
33 | #define THE_ATTRIBUTE in |
34 | #define THE_SHADER_IN in |
35 | #define THE_SHADER_OUT out |
36 | #define THE_OUT out |
ff6665dc |
37 | #define occTexture1D texture |
b86bb3df |
38 | #define occTexture2D texture |
ff6665dc |
39 | #define occTexture3D texture |
b86bb3df |
40 | #else |
41 | #define THE_ATTRIBUTE attribute |
42 | #define THE_SHADER_IN varying |
43 | #define THE_SHADER_OUT varying |
44 | #define THE_OUT |
ff6665dc |
45 | #define occTexture1D texture1D |
b86bb3df |
46 | #define occTexture2D texture2D |
ff6665dc |
47 | #define occTexture3D texture3D |
b86bb3df |
48 | #endif |
49 | |
8a53d1c4 |
50 | #ifdef GL_ES |
51 | #define THE_PREC_ENUM lowp // enumerations should fit into lowp range |
52 | #else |
53 | #define THE_PREC_ENUM |
54 | #endif |
55 | |
12381341 |
56 | // Vertex attributes |
12381341 |
57 | #ifdef VERTEX_SHADER |
b86bb3df |
58 | THE_ATTRIBUTE vec4 occVertex; |
59 | THE_ATTRIBUTE vec3 occNormal; |
60 | THE_ATTRIBUTE vec4 occTexCoord; |
61 | THE_ATTRIBUTE vec4 occVertColor; |
8e0a2b19 |
62 | #elif defined(FRAGMENT_SHADER) |
63 | #if (__VERSION__ >= 130) |
64 | #ifdef OCC_ENABLE_draw_buffers |
b17e5bae |
65 | out vec4 occFragColorArray[THE_NB_FRAG_OUTPUTS]; |
66 | #define occFragColorArrayAlias occFragColorArray |
67 | #define occFragColor0 occFragColorArray[0] |
8e0a2b19 |
68 | #else |
b17e5bae |
69 | out vec4 occFragColor0; |
8e0a2b19 |
70 | #endif |
177781da |
71 | #else |
8e0a2b19 |
72 | #ifdef OCC_ENABLE_draw_buffers |
b17e5bae |
73 | #define occFragColorArrayAlias gl_FragData |
74 | #define occFragColor0 gl_FragData[0] |
8e0a2b19 |
75 | #else |
b17e5bae |
76 | #define occFragColor0 gl_FragColor |
8e0a2b19 |
77 | #endif |
a1073ae2 |
78 | #endif |
b17e5bae |
79 | |
80 | #if (THE_NB_FRAG_OUTPUTS >= 2) |
81 | #define occFragColor1 occFragColorArrayAlias[1] |
82 | #else |
83 | vec4 occFragColor1; |
84 | #endif |
85 | #if (THE_NB_FRAG_OUTPUTS >= 3) |
86 | #define occFragColor2 occFragColorArrayAlias[2] |
87 | #else |
88 | vec4 occFragColor2; |
89 | #endif |
90 | #if (THE_NB_FRAG_OUTPUTS >= 4) |
91 | #define occFragColor3 occFragColorArrayAlias[3] |
92 | #else |
93 | vec4 occFragColor3; |
94 | #endif |
95 | |
96 | // Built-in outputs notation |
97 | #define occFragColor occFragColor0 |
98 | #define occFragCoverage occFragColor1 |
99 | |
100 | //! Define the main Fragment Shader output - color value. |
101 | void occSetFragColor (in vec4 theColor); |
30f0ad28 |
102 | #endif |
103 | |
12381341 |
104 | // Matrix state |
105 | uniform mat4 occWorldViewMatrix; //!< World-view matrix |
106 | uniform mat4 occProjectionMatrix; //!< Projection matrix |
107 | uniform mat4 occModelWorldMatrix; //!< Model-world matrix |
108 | |
109 | uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix |
110 | uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix |
111 | uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix |
112 | |
113 | uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix |
114 | uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix |
115 | uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix |
116 | |
117 | uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix |
118 | uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix |
119 | uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix |
120 | |
121 | // light type enumeration |
122 | const int OccLightType_Direct = 1; //!< directional light source |
123 | const int OccLightType_Point = 2; //!< isotropic point light source |
124 | const int OccLightType_Spot = 3; //!< spot light source |
125 | |
126 | // Light sources |
8a53d1c4 |
127 | uniform vec4 occLightAmbient; //!< Cumulative ambient color |
daf73ab7 |
128 | #if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0) |
8a53d1c4 |
129 | uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources |
12381341 |
130 | int occLight_Type (in int theId); //!< Type of light source |
131 | int occLight_IsHeadlight (in int theId); //!< Is light a headlight? |
132 | vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source |
133 | vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity) |
134 | vec4 occLight_Position (in int theId); //!< Position of specified light source |
135 | vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source |
136 | float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source |
137 | float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source |
138 | float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians) |
139 | float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1) |
daf73ab7 |
140 | #endif |
12381341 |
141 | |
142 | // Front material properties accessors |
143 | vec4 occFrontMaterial_Emission(void); //!< Emission color |
144 | vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection |
145 | vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection |
146 | vec4 occFrontMaterial_Specular(void); //!< Specular reflection |
147 | float occFrontMaterial_Shininess(void); //!< Specular exponent |
148 | float occFrontMaterial_Transparency(void); //!< Transparency coefficient |
149 | |
8625ef7e |
150 | // Back material properties accessors |
12381341 |
151 | vec4 occBackMaterial_Emission(void); //!< Emission color |
152 | vec4 occBackMaterial_Ambient(void); //!< Ambient reflection |
153 | vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection |
154 | vec4 occBackMaterial_Specular(void); //!< Specular reflection |
155 | float occBackMaterial_Shininess(void); //!< Specular exponent |
156 | float occBackMaterial_Transparency(void); //!< Transparency coefficient |
157 | |
cc8cbabe |
158 | #define occActiveSampler occSampler0 //!< alias for backward compatibility |
159 | #define occSamplerBaseColor occSampler0 //!< alias to a base color texture |
160 | uniform sampler2D occSampler0; //!< current active sampler; |
161 | //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing |
8a53d1c4 |
162 | uniform vec4 occColor; //!< color value (in case of disabled lighting) |
163 | uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished? |
164 | uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled? |
79f4f036 |
165 | uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters |
8a53d1c4 |
166 | uniform float occPointSize; //!< point size |
12381341 |
167 | |
a1073ae2 |
168 | //! Parameters of blended order-independent transparency rendering algorithm |
169 | uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage) |
170 | uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment |
c40eb6b9 |
171 | uniform float occAlphaCutoff; //!< alpha test cutoff value |
a1073ae2 |
172 | |
12381341 |
173 | //! Parameters of clipping planes |
daf73ab7 |
174 | #if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0) |
8a53d1c4 |
175 | uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES]; |
25c35042 |
176 | uniform THE_PREC_ENUM int occClipPlaneChains[THE_MAX_CLIP_PLANES]; //! Indicating the number of planes in the Chain |
8a53d1c4 |
177 | uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes |
daf73ab7 |
178 | #endif |