mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
Lights defintion clean up: - remove duplicated enumeration TLightType (equals to Visual3d_TypeOfLightSource) - remove unused fields from Graphic3d_CLight - OpenGl_Light, reuse Graphic3d_CLight definition Phong GLSL program: - move out cumulative ambient light intencity from limited list of lights - compatibility issues, replace array of structures (light sources, materials, clipping planes) with arrays of primitive types New Draw Harness command vlight to alter light sources definition. OpenGl_ShaderProgram::Initialize() - add missing Linker log
80 lines
4.4 KiB
GLSL
80 lines
4.4 KiB
GLSL
// This files includes definition of common uniform variables in OCCT GLSL programs
|
|
|
|
#define THE_MAX_LIGHTS 8
|
|
#define THE_MAX_CLIP_PLANES 8
|
|
|
|
// Vertex attributes
|
|
// Note: At the moment, we just 'rename' the default OpenGL
|
|
// vertex attributes from compatibility profile. In the next
|
|
// release old functionality will be removed from shader API.
|
|
#ifdef VERTEX_SHADER
|
|
#define occColor gl_Color //!< Vertex color
|
|
#define occNormal gl_Normal //!< Normal coordinates
|
|
#define occVertex gl_Vertex //!< Vertex coordinates
|
|
#define occTexCoord gl_MultiTexCoord0 //!< Texture coordinates
|
|
#endif
|
|
|
|
// Matrix state
|
|
uniform mat4 occWorldViewMatrix; //!< World-view matrix
|
|
uniform mat4 occProjectionMatrix; //!< Projection matrix
|
|
uniform mat4 occModelWorldMatrix; //!< Model-world matrix
|
|
|
|
uniform mat4 occWorldViewMatrixInverse; //!< Inverse of the world-view matrix
|
|
uniform mat4 occProjectionMatrixInverse; //!< Inverse of the projection matrix
|
|
uniform mat4 occModelWorldMatrixInverse; //!< Inverse of the model-world matrix
|
|
|
|
uniform mat4 occWorldViewMatrixTranspose; //!< Transpose of the world-view matrix
|
|
uniform mat4 occProjectionMatrixTranspose; //!< Transpose of the projection matrix
|
|
uniform mat4 occModelWorldMatrixTranspose; //!< Transpose of the model-world matrix
|
|
|
|
uniform mat4 occWorldViewMatrixInverseTranspose; //!< Transpose of the inverse of the world-view matrix
|
|
uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix
|
|
uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix
|
|
|
|
// light type enumeration
|
|
const int OccLightType_Direct = 1; //!< directional light source
|
|
const int OccLightType_Point = 2; //!< isotropic point light source
|
|
const int OccLightType_Spot = 3; //!< spot light source
|
|
|
|
// Light sources
|
|
uniform vec4 occLightAmbient; //!< Cumulative ambient color
|
|
uniform int occLightSourcesCount; //!< Total number of light sources
|
|
int occLight_Type (in int theId); //!< Type of light source
|
|
int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
|
|
vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
|
|
vec4 occLight_Specular (in int theId); //!< Specular intensity (currently - equals to diffuse intencity)
|
|
vec4 occLight_Position (in int theId); //!< Position of specified light source
|
|
vec4 occLight_SpotDirection (in int theId); //!< Direction of specified spot light source
|
|
float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor of positional light source
|
|
float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source
|
|
float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)
|
|
float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)
|
|
|
|
// Front material properties accessors
|
|
vec4 occFrontMaterial_Emission(void); //!< Emission color
|
|
vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection
|
|
vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection
|
|
vec4 occFrontMaterial_Specular(void); //!< Specular reflection
|
|
float occFrontMaterial_Shininess(void); //!< Specular exponent
|
|
float occFrontMaterial_Transparency(void); //!< Transparency coefficient
|
|
|
|
// Front material properties accessors
|
|
vec4 occBackMaterial_Emission(void); //!< Emission color
|
|
vec4 occBackMaterial_Ambient(void); //!< Ambient reflection
|
|
vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection
|
|
vec4 occBackMaterial_Specular(void); //!< Specular reflection
|
|
float occBackMaterial_Shininess(void); //!< Specular exponent
|
|
float occBackMaterial_Transparency(void); //!< Transparency coefficient
|
|
|
|
uniform int occDistinguishingMode; //!< Are front and back faces distinguished?
|
|
uniform int occTextureEnable; //!< Is texture enabled?
|
|
uniform sampler2D occActiveSampler; //!< Current active sampler
|
|
|
|
// clipping planes state
|
|
const int OccEquationCoords_View = 0; //!< view-space clipping plane
|
|
const int OccEquationCoords_World = 1; //!< world-space clipping plane
|
|
|
|
//! Parameters of clipping planes
|
|
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
|
|
uniform int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
|