mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0029283: Visualization - allow defining more than 8 light sources
OpenGl_ShaderManager now overrides THE_MAX_LIGHTS within built-in shading programs so that maximum number of lights is now limited only by OpenGL hardware (e.g. length of GLSL program, number of defined uniforms, result performance, etc.). THE_MAX_CLIP_PLANES is now also defined by OpenGl_ShaderManager, so that unused lights and clipping planes do not reserve extra uniforms in GLSL programs. V3d_View::SetLightOn() does not throw exception anymore, when the number of lights exceeds 8. Instead, OpenGl_ShaderManager::PushLightSourceState() emits warning in case of usage of FFP providing consistent behavior with Clipping Planes number limit.
This commit is contained in:
@@ -13,10 +13,16 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// This files includes definition of common uniform variables in OCCT GLSL programs
|
||||
//! @file Declarations.glsl
|
||||
//! This files includes definition of common uniform variables in OCCT GLSL programs
|
||||
|
||||
#define THE_MAX_LIGHTS 8
|
||||
#define THE_MAX_CLIP_PLANES 8
|
||||
//! @def THE_MAX_LIGHTS
|
||||
//! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager.
|
||||
// #define THE_MAX_LIGHTS 8
|
||||
|
||||
//! @def THE_MAX_CLIP_PLANES
|
||||
//! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager.
|
||||
// #define THE_MAX_CLIP_PLANES 8
|
||||
|
||||
// compatibility macros
|
||||
#if (__VERSION__ >= 130)
|
||||
@@ -92,6 +98,7 @@ const int OccLightType_Spot = 3; //!< spot light source
|
||||
|
||||
// Light sources
|
||||
uniform vec4 occLightAmbient; //!< Cumulative ambient color
|
||||
#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)
|
||||
uniform THE_PREC_ENUM 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?
|
||||
@@ -103,6 +110,7 @@ float occLight_ConstAttenuation (in int theId); //!< Const attenuation factor o
|
||||
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)
|
||||
#endif
|
||||
|
||||
// Front material properties accessors
|
||||
vec4 occFrontMaterial_Emission(void); //!< Emission color
|
||||
@@ -135,5 +143,7 @@ uniform int occOitOutput; //!< Enable bit for writing o
|
||||
uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment
|
||||
|
||||
//! Parameters of clipping planes
|
||||
#if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)
|
||||
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
|
||||
uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes
|
||||
#endif
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
// This file includes implementation of common functions and properties accessors
|
||||
|
||||
#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)
|
||||
// arrays of light sources
|
||||
uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
|
||||
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
|
||||
@@ -30,6 +31,7 @@ float occLight_ConstAttenuation (in int theId) { return occLightSources[theId *
|
||||
float occLight_LinearAttenuation (in int theId) { return occLightSources[theId * 4 + 3].y; }
|
||||
float occLight_SpotCutOff (in int theId) { return occLightSources[theId * 4 + 3].z; }
|
||||
float occLight_SpotExponent (in int theId) { return occLightSources[theId * 4 + 3].w; }
|
||||
#endif
|
||||
|
||||
// material state
|
||||
uniform vec4 occFrontMaterial[5];
|
||||
|
@@ -18,6 +18,7 @@ static const char Shaders_DeclarationsImpl_glsl[] =
|
||||
"\n"
|
||||
"// This file includes implementation of common functions and properties accessors\n"
|
||||
"\n"
|
||||
"#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
|
||||
"// arrays of light sources\n"
|
||||
"uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types\n"
|
||||
"uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters\n"
|
||||
@@ -33,6 +34,7 @@ static const char Shaders_DeclarationsImpl_glsl[] =
|
||||
"float occLight_LinearAttenuation (in int theId) { return occLightSources[theId * 4 + 3].y; }\n"
|
||||
"float occLight_SpotCutOff (in int theId) { return occLightSources[theId * 4 + 3].z; }\n"
|
||||
"float occLight_SpotExponent (in int theId) { return occLightSources[theId * 4 + 3].w; }\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// material state\n"
|
||||
"uniform vec4 occFrontMaterial[5];\n"
|
||||
|
@@ -16,10 +16,16 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"// Alternatively, this file may be used under the terms of Open CASCADE\n"
|
||||
"// commercial license or contractual agreement.\n"
|
||||
"\n"
|
||||
"// This files includes definition of common uniform variables in OCCT GLSL programs\n"
|
||||
"//! @file Declarations.glsl\n"
|
||||
"//! This files includes definition of common uniform variables in OCCT GLSL programs\n"
|
||||
"\n"
|
||||
"#define THE_MAX_LIGHTS 8\n"
|
||||
"#define THE_MAX_CLIP_PLANES 8\n"
|
||||
"//! @def THE_MAX_LIGHTS\n"
|
||||
"//! Specifies the length of array of lights, which is 8 by default. Defined by Shader Manager.\n"
|
||||
"// #define THE_MAX_LIGHTS 8\n"
|
||||
"\n"
|
||||
"//! @def THE_MAX_CLIP_PLANES\n"
|
||||
"//! Specifies the length of array of clipping planes, which is 8 by default. Defined by Shader Manager.\n"
|
||||
"// #define THE_MAX_CLIP_PLANES 8\n"
|
||||
"\n"
|
||||
"// compatibility macros\n"
|
||||
"#if (__VERSION__ >= 130)\n"
|
||||
@@ -95,6 +101,7 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"\n"
|
||||
"// Light sources\n"
|
||||
"uniform vec4 occLightAmbient; //!< Cumulative ambient color\n"
|
||||
"#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n"
|
||||
"uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n"
|
||||
"int occLight_Type (in int theId); //!< Type of light source\n"
|
||||
"int occLight_IsHeadlight (in int theId); //!< Is light a headlight?\n"
|
||||
@@ -106,6 +113,7 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"float occLight_LinearAttenuation (in int theId); //!< Linear attenuation factor of positional light source\n"
|
||||
"float occLight_SpotCutOff (in int theId); //!< Maximum spread angle of the spot light (in radians)\n"
|
||||
"float occLight_SpotExponent (in int theId); //!< Attenuation of the spot light intensity (from 0 to 1)\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"// Front material properties accessors\n"
|
||||
"vec4 occFrontMaterial_Emission(void); //!< Emission color\n"
|
||||
@@ -138,5 +146,7 @@ static const char Shaders_Declarations_glsl[] =
|
||||
"uniform float occOitDepthFactor; //!< Influence of the depth component to the coverage of the accumulated fragment\n"
|
||||
"\n"
|
||||
"//! Parameters of clipping planes\n"
|
||||
"#if defined(THE_MAX_CLIP_PLANES) && (THE_MAX_CLIP_PLANES > 0)\n"
|
||||
"uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];\n"
|
||||
"uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n";
|
||||
"uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes\n"
|
||||
"#endif\n";
|
||||
|
Reference in New Issue
Block a user