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 | |
12381341 |
16 | // This files includes definition of common uniform variables in OCCT GLSL programs |
30f0ad28 |
17 | |
12381341 |
18 | #define THE_MAX_LIGHTS 8 |
19 | #define THE_MAX_CLIP_PLANES 8 |
30f0ad28 |
20 | |
b86bb3df |
21 | // compatibility macros |
22 | #if (__VERSION__ >= 130) |
23 | #define THE_ATTRIBUTE in |
24 | #define THE_SHADER_IN in |
25 | #define THE_SHADER_OUT out |
26 | #define THE_OUT out |
27 | #define occTexture2D texture |
28 | #else |
29 | #define THE_ATTRIBUTE attribute |
30 | #define THE_SHADER_IN varying |
31 | #define THE_SHADER_OUT varying |
32 | #define THE_OUT |
33 | #define occTexture2D texture2D |
34 | #endif |
35 | |
8a53d1c4 |
36 | #ifdef GL_ES |
37 | #define THE_PREC_ENUM lowp // enumerations should fit into lowp range |
38 | #else |
39 | #define THE_PREC_ENUM |
40 | #endif |
41 | |
12381341 |
42 | // Vertex attributes |
12381341 |
43 | #ifdef VERTEX_SHADER |
b86bb3df |
44 | THE_ATTRIBUTE vec4 occVertex; |
45 | THE_ATTRIBUTE vec3 occNormal; |
46 | THE_ATTRIBUTE vec4 occTexCoord; |
47 | THE_ATTRIBUTE vec4 occVertColor; |
48 | #elif (__VERSION__ >= 130) |
49 | out vec4 occFragColor; |
50 | #else |
51 | #define occFragColor gl_FragColor |
30f0ad28 |
52 | #endif |
53 | |
12381341 |
54 | // Matrix state |
55 | uniform mat4 occWorldViewMatrix; //!< World-view matrix |
56 | uniform mat4 occProjectionMatrix; //!< Projection matrix |
57 | uniform mat4 occModelWorldMatrix; //!< Model-world matrix |
58 | |
59 | uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix |
60 | uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix |
61 | uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix |
62 | |
63 | uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix |
64 | uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix |
65 | uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix |
66 | |
67 | uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix |
68 | uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix |
69 | uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix |
70 | |
71 | // light type enumeration |
72 | const int OccLightType_Direct = 1; //!< directional light source |
73 | const int OccLightType_Point = 2; //!< isotropic point light source |
74 | const int OccLightType_Spot = 3; //!< spot light source |
75 | |
76 | // Light sources |
8a53d1c4 |
77 | uniform vec4 occLightAmbient; //!< Cumulative ambient color |
78 | uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources |
12381341 |
79 | int occLight_Type (in int theId); //!< Type of light source |
80 | int occLight_IsHeadlight (in int theId); //!< Is light a headlight? |
81 | vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source |
82 | vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity) |
83 | vec4 occLight_Position (in int theId); //!< Position of specified light source |
84 | vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source |
85 | float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source |
86 | float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source |
87 | float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians) |
88 | float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1) |
89 | |
90 | // Front material properties accessors |
91 | vec4 occFrontMaterial_Emission(void); //!< Emission color |
92 | vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection |
93 | vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection |
94 | vec4 occFrontMaterial_Specular(void); //!< Specular reflection |
95 | float occFrontMaterial_Shininess(void); //!< Specular exponent |
96 | float occFrontMaterial_Transparency(void); //!< Transparency coefficient |
97 | |
8625ef7e |
98 | // Back material properties accessors |
12381341 |
99 | vec4 occBackMaterial_Emission(void); //!< Emission color |
100 | vec4 occBackMaterial_Ambient(void); //!< Ambient reflection |
101 | vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection |
102 | vec4 occBackMaterial_Specular(void); //!< Specular reflection |
103 | float occBackMaterial_Shininess(void); //!< Specular exponent |
104 | float occBackMaterial_Transparency(void); //!< Transparency coefficient |
105 | |
8a53d1c4 |
106 | uniform vec4 occColor; //!< color value (in case of disabled lighting) |
107 | uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished? |
108 | uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled? |
109 | uniform sampler2D occActiveSampler; //!< Current active sampler |
79f4f036 |
110 | uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters |
8a53d1c4 |
111 | uniform float occPointSize; //!< point size |
12381341 |
112 | |
12381341 |
113 | //! Parameters of clipping planes |
8a53d1c4 |
114 | uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES]; |
8a53d1c4 |
115 | uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes |