mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +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:
@@ -149,6 +149,8 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
|
||||
myProgramID (NO_PROGRAM),
|
||||
myProxy (theProxy),
|
||||
myShareCount(1),
|
||||
myNbLightsMax (0),
|
||||
myNbClipPlanesMax (0),
|
||||
myHasTessShader (false)
|
||||
{
|
||||
memset (myCurrentState, 0, sizeof (myCurrentState));
|
||||
@@ -327,11 +329,24 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
case Graphic3d_TOS_FRAGMENT: { aHeaderType = "#define FRAGMENT_SHADER\n"; break; }
|
||||
}
|
||||
|
||||
TCollection_AsciiString aHeaderConstants;
|
||||
myNbLightsMax = !myProxy.IsNull() ? myProxy->NbLightsMax() : 0;
|
||||
myNbClipPlanesMax = !myProxy.IsNull() ? myProxy->NbClipPlanesMax() : 0;
|
||||
if (myNbLightsMax > 0)
|
||||
{
|
||||
aHeaderConstants += TCollection_AsciiString("#define THE_MAX_LIGHTS ") + myNbLightsMax + "\n";
|
||||
}
|
||||
if (myNbClipPlanesMax > 0)
|
||||
{
|
||||
aHeaderConstants += TCollection_AsciiString("#define THE_MAX_CLIP_PLANES ") + myNbClipPlanesMax + "\n";
|
||||
}
|
||||
|
||||
const TCollection_AsciiString aSource = aHeaderVer // #version - header defining GLSL version, should be first
|
||||
+ (!aHeaderVer.IsEmpty() ? "\n" : "")
|
||||
+ anExtensions // #extension - list of enabled extensions, should be second
|
||||
+ aPrecisionHeader // precision - default precision qualifiers, should be before any code
|
||||
+ aHeaderType // auxiliary macros defining a shader stage (type)
|
||||
+ aHeaderConstants
|
||||
+ Shaders_Declarations_glsl // common declarations (global constants and Vertex Shader inputs)
|
||||
+ Shaders_DeclarationsImpl_glsl
|
||||
+ anIter.Value()->Source(); // the source code itself (defining main() function)
|
||||
|
Reference in New Issue
Block a user