0029074: Visualization, TKOpenGl - support Geometry Shader definition
[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
ff6665dc 27 #define occTexture1D texture
b86bb3df 28 #define occTexture2D texture
ff6665dc 29 #define occTexture3D texture
b86bb3df 30#else
31 #define THE_ATTRIBUTE attribute
32 #define THE_SHADER_IN varying
33 #define THE_SHADER_OUT varying
34 #define THE_OUT
ff6665dc 35 #define occTexture1D texture1D
b86bb3df 36 #define occTexture2D texture2D
ff6665dc 37 #define occTexture3D texture3D
b86bb3df 38#endif
39
8a53d1c4 40#ifdef GL_ES
41 #define THE_PREC_ENUM lowp // enumerations should fit into lowp range
42#else
43 #define THE_PREC_ENUM
44#endif
45
12381341 46// Vertex attributes
12381341 47#ifdef VERTEX_SHADER
b86bb3df 48 THE_ATTRIBUTE vec4 occVertex;
49 THE_ATTRIBUTE vec3 occNormal;
50 THE_ATTRIBUTE vec4 occTexCoord;
51 THE_ATTRIBUTE vec4 occVertColor;
8e0a2b19 52#elif defined(FRAGMENT_SHADER)
53 #if (__VERSION__ >= 130)
54 #ifdef OCC_ENABLE_draw_buffers
55 out vec4 occFragColorArray[2];
56 #define occFragColor occFragColorArray[0]
57 #define occFragCoverage occFragColorArray[1]
58 #else
59 out vec4 occFragColor;
60 #endif
177781da 61 #else
8e0a2b19 62 #ifdef OCC_ENABLE_draw_buffers
63 #define occFragColor gl_FragData[0]
64 #define occFragCoverage gl_FragData[1]
65 #else
66 #define occFragColor gl_FragColor
67 #endif
a1073ae2 68 #endif
30f0ad28 69#endif
70
12381341 71// Matrix state
72uniform mat4 occWorldViewMatrix; //!< World-view matrix
73uniform mat4 occProjectionMatrix; //!< Projection matrix
74uniform mat4 occModelWorldMatrix; //!< Model-world matrix
75
76uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
77uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
78uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
79
80uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
81uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
82uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
83
84uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
85uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
86uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
87
88// light type enumeration
89const int OccLightType_Direct = 1; //!< directional light source
90const int OccLightType_Point = 2; //!< isotropic point light source
91const int OccLightType_Spot = 3; //!< spot light source
92
93// Light sources
8a53d1c4 94uniform vec4 occLightAmbient; //!< Cumulative ambient color
95uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
12381341 96int occLight_Type (in int theId); //!< Type of light source
97int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
98vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
99vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
100vec4 occLight_Position (in int theId); //!< Position of specified light source
101vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
102float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
103float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
104float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
105float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
106
107// Front material properties accessors
108vec4 occFrontMaterial_Emission(void); //!< Emission color
109vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
110vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
111vec4 occFrontMaterial_Specular(void); //!< Specular reflection
112float occFrontMaterial_Shininess(void); //!< Specular exponent
113float occFrontMaterial_Transparency(void); //!< Transparency coefficient
114
8625ef7e 115// Back material properties accessors
12381341 116vec4 occBackMaterial_Emission(void); //!< Emission color
117vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
118vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
119vec4 occBackMaterial_Specular(void); //!< Specular reflection
120float occBackMaterial_Shininess(void); //!< Specular exponent
121float occBackMaterial_Transparency(void); //!< Transparency coefficient
122
cc8cbabe 123#define occActiveSampler occSampler0 //!< alias for backward compatibility
124#define occSamplerBaseColor occSampler0 //!< alias to a base color texture
125uniform sampler2D occSampler0; //!< current active sampler;
126 //! occSampler1, occSampler2,... should be defined in GLSL program body for multitexturing
8a53d1c4 127uniform vec4 occColor; //!< color value (in case of disabled lighting)
128uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
129uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
79f4f036 130uniform vec4 occTexTrsf2d[2]; //!< 2D texture transformation parameters
8a53d1c4 131uniform float occPointSize; //!< point size
12381341 132
a1073ae2 133//! Parameters of blended order-independent transparency rendering algorithm
134uniform int occOitOutput; //!< Enable bit for writing output color buffers for OIT (occFragColor, occFragCoverage)
135uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment
136
12381341 137//! Parameters of clipping planes
8a53d1c4 138uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
8a53d1c4 139uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes