0026665: Visualization, TKOpenGl - specify precision for integer uniforms explicitly...
[occt.git] / src / Shaders / Declarations.glsl
CommitLineData
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
55uniform mat4 occWorldViewMatrix; //!< World-view matrix
56uniform mat4 occProjectionMatrix; //!< Projection matrix
57uniform mat4 occModelWorldMatrix; //!< Model-world matrix
58
59uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
60uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
61uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
62
63uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
64uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
65uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
66
67uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
68uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
69uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
70
71// light type enumeration
72const int OccLightType_Direct = 1; //!< directional light source
73const int OccLightType_Point = 2; //!< isotropic point light source
74const int OccLightType_Spot = 3; //!< spot light source
75
76// Light sources
8a53d1c4 77uniform vec4 occLightAmbient; //!< Cumulative ambient color
78uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
12381341 79int occLight_Type (in int theId); //!< Type of light source
80int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
81vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
82vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
83vec4 occLight_Position (in int theId); //!< Position of specified light source
84vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
85float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
86float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
87float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
88float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
89
90// Front material properties accessors
91vec4 occFrontMaterial_Emission(void); //!< Emission color
92vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
93vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
94vec4 occFrontMaterial_Specular(void); //!< Specular reflection
95float occFrontMaterial_Shininess(void); //!< Specular exponent
96float occFrontMaterial_Transparency(void); //!< Transparency coefficient
97
8625ef7e 98// Back material properties accessors
12381341 99vec4 occBackMaterial_Emission(void); //!< Emission color
100vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
101vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
102vec4 occBackMaterial_Specular(void); //!< Specular reflection
103float occBackMaterial_Shininess(void); //!< Specular exponent
104float occBackMaterial_Transparency(void); //!< Transparency coefficient
105
8a53d1c4 106uniform vec4 occColor; //!< color value (in case of disabled lighting)
107uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
108uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
109uniform sampler2D occActiveSampler; //!< Current active sampler
110uniform float occPointSize; //!< point size
12381341 111
112// clipping planes state
113const int OccEquationCoords_View = 0; //!< view-space clipping plane
114const int OccEquationCoords_World = 1; //!< world-space clipping plane
115
116//! Parameters of clipping planes
8a53d1c4 117uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
118uniform THE_PREC_ENUM int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
119uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes