0025282: Visualization, OpenGl_PrimitiveArray - provide built-in GLSL programs as...
[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
12381341 21// Vertex attributes
12381341 22#ifdef VERTEX_SHADER
7d3e64ef 23 attribute vec4 occVertex;
24 attribute vec3 occNormal;
25 attribute vec4 occTexCoord;
8625ef7e 26 attribute vec4 occVertColor;
30f0ad28 27#endif
28
12381341 29// Matrix state
30uniform mat4 occWorldViewMatrix; //!< World-view matrix
31uniform mat4 occProjectionMatrix; //!< Projection matrix
32uniform mat4 occModelWorldMatrix; //!< Model-world matrix
33
34uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
35uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
36uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
37
38uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
39uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
40uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
41
42uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
43uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
44uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
45
46// light type enumeration
47const int OccLightType_Direct = 1; //!< directional light source
48const int OccLightType_Point = 2; //!< isotropic point light source
49const int OccLightType_Spot = 3; //!< spot light source
50
51// Light sources
52uniform vec4 occLightAmbient; //!< Cumulative ambient color
53uniform int occLightSourcesCount; //!< Total number of light sources
54int occLight_Type (in int theId); //!< Type of light source
55int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
56vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
57vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
58vec4 occLight_Position (in int theId); //!< Position of specified light source
59vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
60float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
61float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
62float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
63float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
64
65// Front material properties accessors
66vec4 occFrontMaterial_Emission(void); //!< Emission color
67vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
68vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
69vec4 occFrontMaterial_Specular(void); //!< Specular reflection
70float occFrontMaterial_Shininess(void); //!< Specular exponent
71float occFrontMaterial_Transparency(void); //!< Transparency coefficient
72
8625ef7e 73// Back material properties accessors
12381341 74vec4 occBackMaterial_Emission(void); //!< Emission color
75vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
76vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
77vec4 occBackMaterial_Specular(void); //!< Specular reflection
78float occBackMaterial_Shininess(void); //!< Specular exponent
79float occBackMaterial_Transparency(void); //!< Transparency coefficient
80
8625ef7e 81uniform vec4 occColor; //!< color value (in case of disabled lighting)
12381341 82uniform int occDistinguishingMode; //!< Are front and back faces distinguished?
83uniform int occTextureEnable; //!< Is texture enabled?
84uniform sampler2D occActiveSampler; //!< Current active sampler
8625ef7e 85uniform float occPointSize; //!< point size
12381341 86
87// clipping planes state
88const int OccEquationCoords_View = 0; //!< view-space clipping plane
89const int OccEquationCoords_World = 1; //!< world-space clipping plane
90
91//! Parameters of clipping planes
92uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
93uniform int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
5495fa7e 94uniform int occClipPlaneCount; //!< Total number of clip planes