1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-13 14:27:08 +03:00

0024310: TKOpenGl - GLSL compatibility issues

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
This commit is contained in:
kgv
2013-11-04 04:42:44 +04:00
committed by abv
parent e91d202a72
commit 1238134135
29 changed files with 1453 additions and 1757 deletions

View File

@@ -1,192 +1,79 @@
#define _OCC_MAX_LIGHTS_ 8
// This files includes definition of common uniform variables in OCCT GLSL programs
#define _OCC_MAX_CLIP_PLANES_ 8
//! OCCT ambient light source.
const int occAmbientLight = 0;
//! OCCT directional light source.
const int occDirectLight = 1;
//! OCCT isotropic point light source.
const int occPointLight = 2;
//! OCCT spot light source.
const int occSpotLight = 3;
//! Parameters of OCCT light source.
struct occLightSource
{
//! Type of light source.
int Type;
//! Is light a headlight?
int Head;
//! Ambient intensity.
vec3 Ambient;
//! Diffuse intensity.
vec3 Diffuse;
//! Specular intensity.
vec3 Specular;
//! Position of light source.
vec3 Position;
//! Direction of the spot light.
vec3 SpotDirection;
//! Maximum spread angle of the spot light (in radians).
float SpotCutoff;
//! Attenuation of the spot light intensity (from 0 to 1).
float SpotExponent;
//! Const attenuation factor of positional light source.
float ConstAttenuation;
//! Linear attenuation factor of positional light source.
float LinearAttenuation;
};
//! Parameters of OCCT material.
struct occMaterialParams
{
//! Emission color.
vec4 Emission;
//! Ambient reflection.
vec4 Ambient;
//! Diffuse reflection.
vec4 Diffuse;
//! Specular reflection.
vec4 Specular;
//! Specular exponent.
float Shininess;
//! Transparency coefficient.
float Transparency;
};
//! OCCT view-space clipping plane.
const int occEquationCoordsView = 0;
//! OCCT world-space clipping plane.
const int occEquationCoordsWorld = 1;
//! Parameters of OCCT clipping plane.
struct occClipPlane
{
//! Plane equation.
vec4 Equation;
//! Equation space.
int Space;
};
#ifdef VERTEX_SHADER
/////////////////////////////////////////////////////////////////////
// OCCT vertex attributes
#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.
//! Vertex color.
#define occColor gl_Color
//! Normal coordinates.
#define occNormal gl_Normal
//! Vertex coordinates.
#define occVertex gl_Vertex
//! Texture coordinates.
#define occTexCoord gl_MultiTexCoord0
#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
/////////////////////////////////////////////////////////////////////
// OCCT matrix state
// Matrix state
uniform mat4 occWorldViewMatrix; //!< World-view matrix
uniform mat4 occProjectionMatrix; //!< Projection matrix
uniform mat4 occModelWorldMatrix; //!< Model-world matrix
//! World-view matrix.
uniform mat4 occWorldViewMatrix;
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
//! Projection matrix.
uniform mat4 occProjectionMatrix;
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
//! Model-world matrix.
uniform mat4 occModelWorldMatrix;
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
//! Inverse of the world-view matrix.
uniform mat4 occWorldViewMatrixInverse;
// 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)
//! Inverse of the projection matrix.
uniform mat4 occProjectionMatrixInverse;
// 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
//! Inverse of the model-world matrix.
uniform mat4 occModelWorldMatrixInverse;
// 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
//! Transpose of the world-view matrix.
uniform mat4 occWorldViewMatrixTranspose;
// clipping planes state
const int OccEquationCoords_View = 0; //!< view-space clipping plane
const int OccEquationCoords_World = 1; //!< world-space clipping plane
//! Transpose of the projection matrix.
uniform mat4 occProjectionMatrixTranspose;
//! Transpose of the model-world matrix.
uniform mat4 occModelWorldMatrixTranspose;
//-------------------------------------------------------
//! Transpose of the inverse of the world-view matrix.
uniform mat4 occWorldViewMatrixInverseTranspose;
//! Transpose of the inverse of the projection matrix.
uniform mat4 occProjectionMatrixInverseTranspose;
//! Transpose of the inverse of the model-world matrix.
uniform mat4 occModelWorldMatrixInverseTranspose;
/////////////////////////////////////////////////////////////////////
// OCCT light source state
//! Array of OCCT light sources.
uniform occLightSource occLightSources[_OCC_MAX_LIGHTS_];
//! Total number of OCCT light sources.
uniform int occLightSourcesCount;
/////////////////////////////////////////////////////////////////////
// OCCT material state
//! Parameters of OCCT back material.
uniform occMaterialParams occBackMaterial;
//! Parameters of OCCT front material.
uniform occMaterialParams occFrontMaterial;
//! Are front and back faces distinguished?
uniform int occDistinguishingMode;
//! Is texture enabled?
uniform int occTextureEnable;
//! Current active sampler.
uniform sampler2D occActiveSampler;
/////////////////////////////////////////////////////////////////////
// OCCT clipping planes state
uniform occClipPlane occClipPlanes[_OCC_MAX_CLIP_PLANES_];
//! Parameters of clipping planes
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
uniform int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];