1 // Created on: 2013-10-10
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 // This files includes definition of common uniform variables in OCCT GLSL programs
18 #define THE_MAX_LIGHTS 8
19 #define THE_MAX_CLIP_PLANES 8
21 // compatibility macros
22 #if (__VERSION__ >= 130)
23 #define THE_ATTRIBUTE in
24 #define THE_SHADER_IN in
25 #define THE_SHADER_OUT out
27 #define occTexture1D texture
28 #define occTexture2D texture
29 #define occTexture3D texture
31 #define THE_ATTRIBUTE attribute
32 #define THE_SHADER_IN varying
33 #define THE_SHADER_OUT varying
35 #define occTexture1D texture1D
36 #define occTexture2D texture2D
37 #define occTexture3D texture3D
41 #define THE_PREC_ENUM lowp // enumerations should fit into lowp range
48 THE_ATTRIBUTE vec4 occVertex;
49 THE_ATTRIBUTE vec3 occNormal;
50 THE_ATTRIBUTE vec4 occTexCoord;
51 THE_ATTRIBUTE vec4 occVertColor;
52 #elif (__VERSION__ >= 130)
53 #ifdef OCC_ENABLE_draw_buffers
54 out vec4 occFragColorArray[2];
55 #define occFragColor occFragColorArray[0]
56 #define occFragCoverage occFragColorArray[1]
58 out vec4 occFragColor;
61 #ifdef OCC_ENABLE_draw_buffers
62 #define occFragColor gl_FragData[0]
63 #define occFragCoverage gl_FragData[1]
65 #define occFragColor gl_FragColor
70 uniform mat4 occWorldViewMatrix; //!< World-view matrix
71 uniform mat4 occProjectionMatrix; //!< Projection matrix
72 uniform mat4 occModelWorldMatrix; //!< Model-world matrix
74 uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
75 uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
76 uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
78 uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
79 uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
80 uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
82 uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
83 uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
84 uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
86 // light type enumeration
87 const int OccLightType_Direct = 1; //!< directional light source
88 const int OccLightType_Point = 2; //!< isotropic point light source
89 const int OccLightType_Spot = 3; //!< spot light source
92 uniform vec4 occLightAmbient; //!< Cumulative ambient color
93 uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
94 int occLight_Type (in int theId); //!< Type of light source
95 int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
96 vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
97 vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
98 vec4 occLight_Position (in int theId); //!< Position of specified light source
99 vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
100 float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
101 float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
102 float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
103 float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
105 // Front material properties accessors
106 vec4 occFrontMaterial_Emission(void); //!< Emission color
107 vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
108 vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
109 vec4 occFrontMaterial_Specular(void); //!< Specular reflection
110 float occFrontMaterial_Shininess(void); //!< Specular exponent
111 float occFrontMaterial_Transparency(void); //!< Transparency coefficient
113 // Back material properties accessors
114 vec4 occBackMaterial_Emission(void); //!< Emission color
115 vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
116 vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
117 vec4 occBackMaterial_Specular(void); //!< Specular reflection
118 float occBackMaterial_Shininess(void); //!< Specular exponent
119 float occBackMaterial_Transparency(void); //!< Transparency coefficient
121 uniform vec4 occColor; //!< color value (in case of disabled lighting)
122 uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
123 uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
124 uniform sampler2D occActiveSampler; //!< Current active sampler
125 uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters
126 uniform float occPointSize; //!< point size
128 //! Parameters of blended order-independent transparency rendering algorithm
129 uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage)
130 uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment
132 //! Parameters of clipping planes
133 uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
134 uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes