LightManager
Manage a set of lights that can cast hard and soft shadows.Soft Shadows is done using Variance Shadow Mapping Utility to manage lights into an Opengl scene This class must be used with the Light class. It centralizes all the Lights and managed them.
The LightManager manages lighting effects in SOFA's OpenGL scenes, including hard and soft shadows using Variance Shadow Mapping (VSM). It centralizes light management and works with the Light class for visual representation.
- module
- Sofa.GL.Component.Shader
- namespace
- sofa::gl::component::shader
- include
- sofa/gl/component/shader/LightManager.h
- inherits
-
- VisualManager
- description
The LightManager component in the SOFA framework is primarily responsible for managing lighting effects, including shadow casting with Variance Shadow Mapping (VSM), within OpenGL scenes. This component does not directly contribute to any governing equations or operators related to Finite Element Method (FEM) simulations such as mass matrix ((M")), stiffness matrix ((K")), internal force vector ((f_{int}")), residual vector ((R")), or constitutive laws like stress-strain relationships. Instead, it focuses on the visual representation and rendering aspects of the simulation environment.
Mathematical and Physical Description
Role in Global FEM Pipeline:*
- The LightManager** does not play a direct role in the assembly phase (mass matrix construction, internal force computation), time integration, nonlinear or linear solve phases, constraint handling, or mappings. It is instead part of the scene graph architecture that handles visual parameters and rendering.
Constitutive or Kinematic Laws:*
- The LightManager** does not involve any constitutive laws (stress-strain relationships) or kinematic laws related to deformation or motion. Instead, it deals with lighting effects such as ambient light contributions and shadow management.
*Numerical Methods or Discretization Choices:
- The component does not encode numerical methods relevant for FEM simulations like spatial discretization (meshing), time integration schemes, or iterative solvers. Its functionality is more related to OpenGL rendering techniques such as Variance Shadow Mapping (VSM) for soft shadows.
Variational / Lagrangian Mechanics Framework:*
- There is no direct connection between the LightManager** and variational principles or Lagrangian mechanics used in FEM formulations. It operates at a higher level of abstraction, focusing on visual effects rather than physical simulation details.
Data Fields and Methods:
- The shadowsEnabled field ((d_{\text{shadowsEnabled}}")) is a boolean that enables or disables shadow casting in the scene (default = false).
- The softShadowsEnabled field ((d_{\text{softShadowsEnabled}}")) is another boolean that, when enabled along with shadows, applies Variance Shadow Mapping for soft shadows (default = false).
- The ambient field ((d_{\text{ambient}}")) specifies the ambient light contribution as an RGBAColor vector (default = [0.0f, 0.0f, 0.0f, 0.0f]).
- The debugDraw field ((d_{\text{drawIsEnabled}}")) is a boolean that enables or disables the drawing of lights' shadow textures for debugging purposes (default = false).
Methods:
- Methods such as
init,bwdInit,reinit,doInitVisual, and others are inherited from VisualManager and handle initialization, scene rendering, and visual parameter management.
In summary, the LightManager is a component designed for managing lighting effects in SOFA's OpenGL scenes, focusing on visual representation rather than physical simulation equations or operators.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_shadowsEnabled |
bool | |
Enable Shadow in the scene. (default=0) |
d_softShadowsEnabled |
bool | |
If Shadows enabled, Enable Variance Soft Shadow in the scene. (default=0) |
d_ambient |
sofa::type::RGBAColor | |
Ambient lights contribution (Vec4f)(default=[0.0f,0.0f,0.0f,0.0f]) |
d_drawIsEnabled |
bool | |
enable/disable drawing of lights shadow textures. (default=false) |
Methods
void
init
()
virtual
void
bwdInit
()
virtual
void
reinit
()
virtual
void
doInitVisual
(const core::visual::VisualParams * vparams)
virtual
void
preDrawScene
(core::visual::VisualParams * vp)
virtual
bool
drawScene
(core::visual::VisualParams * vp)
virtual
void
postDrawScene
(core::visual::VisualParams * vp)
virtual
void
draw
(const core::visual::VisualParams * vparams)
virtual
void
fwdDraw
(core::visual::VisualParams * )
virtual
void
bwdDraw
(core::visual::VisualParams * )
virtual
void
putLight
(int light)
void
putLights
(int m_lights)
void
clear
()
void
restoreDefaultLight
(core::visual::VisualParams * vparams)
void
handleEvent
(sofa::core::objectmodel::Event * event)
virtual
{
"name": "LightManager",
"namespace": "sofa::gl::component::shader",
"module": "Sofa.GL.Component.Shader",
"include": "sofa/gl/component/shader/LightManager.h",
"doc": "Manage a set of lights that can cast hard and soft shadows.Soft Shadows is done using Variance Shadow Mapping\n\nUtility to manage lights into an Opengl scene\n This class must be used with the Light class.\n It centralizes all the Lights and managed them.",
"inherits": [
"VisualManager"
],
"templates": [],
"data_fields": [
{
"name": "d_shadowsEnabled",
"type": "bool",
"xmlname": "shadows",
"help": "Enable Shadow in the scene. (default=0)"
},
{
"name": "d_softShadowsEnabled",
"type": "bool",
"xmlname": "softShadows",
"help": "If Shadows enabled, Enable Variance Soft Shadow in the scene. (default=0)"
},
{
"name": "d_ambient",
"type": "sofa::type::RGBAColor",
"xmlname": "ambient",
"help": "Ambient lights contribution (Vec4f)(default=[0.0f,0.0f,0.0f,0.0f])"
},
{
"name": "d_drawIsEnabled",
"type": "bool",
"xmlname": "debugDraw",
"help": "enable/disable drawing of lights shadow textures. (default=false)"
}
],
"links": [],
"methods": [
{
"name": "init",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "bwdInit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "reinit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "doInitVisual",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "preDrawScene",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "drawScene",
"return_type": "bool",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "postDrawScene",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "draw",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "fwdDraw",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "bwdDraw",
"return_type": "void",
"params": [
{
"name": "",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "putLight",
"return_type": "void",
"params": [
{
"name": "light",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "putLights",
"return_type": "void",
"params": [
{
"name": "m_lights",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "clear",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "restoreDefaultLight",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "handleEvent",
"return_type": "void",
"params": [
{
"name": "event",
"type": "sofa::core::objectmodel::Event *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The **LightManager** is a component in the SOFA framework, specifically within the `sofa::gl::component::shader` namespace, which manages a set of lights capable of casting both hard and soft shadows using Variance Shadow Mapping (VSM). It centralizes light management for OpenGL scenes and works in conjunction with the Light class. The LightManager inherits from **VisualManager**, indicating it plays a role in visual representation within SOFA simulations.\n\n**Role and Purpose:**\nThe primary purpose of the LightManager is to enable and manage lighting, including shadow effects, within SOFA's OpenGL rendering environment. It provides control over ambient light contribution and options for enabling/disabling shadows and soft shadows.\n\n**Interactions with Other Components:*\nThe component interacts with other components through a set of public methods inherited from VisualManager, such as `init`, `bwdInit`, `reinit`, `doInitVisual`, and others. These methods manage initialization, drawing scenes, and handling visual parameters. Additionally, it interacts with the Light class for specific light management operations.\n\n**Practical Usage Guidance:*\nThe **LightManager** provides several data fields to configure its behavior:\n- **shadows**: A boolean field (`d_shadowsEnabled`) to enable or disable shadow casting in the scene (default is false).\n- **softShadows**: Another boolean field (`d_softShadowsEnabled`) to enable Variance Shadow Mapping for soft shadows when shadows are enabled (also default is false).\n- **ambient**: An RGBAColor field (`d_ambient`) to set ambient light contribution, typically used as a background lighting effect (default value is [0.0f, 0.0f, 0.0f, 0.0f]).\n- **debugDraw**: A boolean field (`d_drawIsEnabled`) for enabling or disabling the drawing of lights' shadow textures (useful for debugging and default is false).\n\nThese fields allow users to configure lighting effects in a SOFA simulation scene effectively.",
"maths": "The **LightManager** component in the SOFA framework is primarily responsible for managing lighting effects, including shadow casting with Variance Shadow Mapping (VSM), within OpenGL scenes. This component does not directly contribute to any governing equations or operators related to Finite Element Method (FEM) simulations such as mass matrix (\\(M\")), stiffness matrix (\\(K\")), internal force vector (\\(f_{int}\")), residual vector (\\(R\")), or constitutive laws like stress-strain relationships. Instead, it focuses on the visual representation and rendering aspects of the simulation environment.\n\n### Mathematical and Physical Description\n\n**Role in Global FEM Pipeline:*\n- The **LightManager** does not play a direct role in the assembly phase (mass matrix construction, internal force computation), time integration, nonlinear or linear solve phases, constraint handling, or mappings. It is instead part of the scene graph architecture that handles visual parameters and rendering.\n\n**Constitutive or Kinematic Laws:*\n- The **LightManager** does not involve any constitutive laws (stress-strain relationships) or kinematic laws related to deformation or motion. Instead, it deals with lighting effects such as ambient light contributions and shadow management.\n\n**Numerical Methods or Discretization Choices:*\n- The component does not encode numerical methods relevant for FEM simulations like spatial discretization (meshing), time integration schemes, or iterative solvers. Its functionality is more related to OpenGL rendering techniques such as Variance Shadow Mapping (VSM) for soft shadows.\n\n**Variational / Lagrangian Mechanics Framework:*\n- There is no direct connection between the **LightManager** and variational principles or Lagrangian mechanics used in FEM formulations. It operates at a higher level of abstraction, focusing on visual effects rather than physical simulation details.\n\n### Data Fields and Methods:\n- The **shadowsEnabled** field (\\(d_{\\text{shadowsEnabled}}\")) is a boolean that enables or disables shadow casting in the scene (default = false).\n- The **softShadowsEnabled** field (\\(d_{\\text{softShadowsEnabled}}\")) is another boolean that, when enabled along with shadows, applies Variance Shadow Mapping for soft shadows (default = false).\n- The **ambient** field (\\(d_{\\text{ambient}}\")) specifies the ambient light contribution as an RGBAColor vector (default = [0.0f, 0.0f, 0.0f, 0.0f]).\n- The **debugDraw** field (\\(d_{\\text{drawIsEnabled}}\")) is a boolean that enables or disables the drawing of lights' shadow textures for debugging purposes (default = false).\n\n### Methods:\n- Methods such as `init`, `bwdInit`, `reinit`, `doInitVisual`, and others are inherited from **VisualManager** and handle initialization, scene rendering, and visual parameter management.\n\nIn summary, the **LightManager** is a component designed for managing lighting effects in SOFA's OpenGL scenes, focusing on visual representation rather than physical simulation equations or operators.",
"abstract": "The LightManager manages lighting effects in SOFA's OpenGL scenes, including hard and soft shadows using Variance Shadow Mapping (VSM). It centralizes light management and works with the Light class for visual representation.",
"sheet": "# LightManager\n\n## Overview\nThe LightManager is a component within the `sofa::gl::component::shader` namespace that manages lighting effects in SOFA's OpenGL scenes. It handles both hard and soft shadows using Variance Shadow Mapping (VSM) and centralizes light management for visual representation. This component works in conjunction with the Light class.\n\n## Parameters and Data\nThe significant Data fields exposed by the LightManager include:\n- **shadowsEnabled**: A boolean field (`d_shadowsEnabled`) to enable or disable shadow casting in the scene (default is false).\n- **softShadowsEnabled**: Another boolean field (`d_softShadowsEnabled`) to enable Variance Shadow Mapping for soft shadows when shadows are enabled (also default is false).\n- **ambient**: An RGBAColor field (`d_ambient`) to set ambient light contribution, typically used as a background lighting effect (default value is [0.0f, 0.0f, 0.0f, 0.0f]).\n- **debugDraw**: A boolean field (`d_drawIsEnabled`) for enabling or disabling the drawing of lights' shadow textures (useful for debugging and default is false).\n\n## Dependencies and Connections\nThe LightManager typically requires interaction with the `Light` class to manage specific light sources. It fits into the scene graph as part of the visual representation pipeline, inheriting from **VisualManager**.\n\n## Practical Notes\n- Ensure that shadows are enabled before enabling soft shadows for Variance Shadow Mapping (VSM) to take effect.\n- The ambient field can be used to set a background lighting contribution, which is useful for enhancing scene visibility and realism."
}