Light
A directional light illuminating the scene with parallel rays of light (can cast shadows). Utility to cast Light into a Opengl scene. This class must be used in a scene with one LightManager object. This abstract class defines lights (i.e basically id and color) The inherited lights are: - Directional light (direction); - Positional light (position); - Spot light (position, direction, cutoff...).
The `Light` component illuminates the SOFA scene with directional, positional, or spot lights that can cast shadows, requiring a `LightManager` object for proper functioning.
- module
- Sofa.GL.Component.Shader
- namespace
- sofa::gl::component::shader
- include
- sofa/gl/component/shader/Light.h
- inherits
-
- VisualModel
- description
The Light component in the SOFA framework does not contribute directly to the governing equations or operators related to mechanics, such as mass matrix $M$, stiffness matrix $K$, internal force $oldsymbol{f}_{int}$, residual $oldsymbol{R}$, etc. It is primarily a visual and rendering component used to illuminate the scene with different types of light sources (directional, positional, or spotlight) and manage shadow effects.
Governing Equations / Operators
- Light Component: The
Lightclass does not involve any governing equations related to continuum mechanics or variational formulations. Its primary role is to provide illumination and visual effects through different types of light sources.
Constitutive or Kinematic Laws Involved
- Constitutive Law: None, as this component focuses on rendering rather than mechanical behavior.
Role in the Global FEM Pipeline
- The
Lightcomponent does not participate directly in the global FEM pipeline involving assembly, time integration, nonlinear solve, linear solve, constraint handling, or mapping. Instead, it interacts with shaders and visual representations to enhance the visual realism of simulations.
Numerical Methods or Discretization Choices
- Rendering: The
Lightcomponent does not involve numerical methods or discretization choices related to FEM simulation. It utilizes OpenGL for rendering purposes and handles shadow calculations based on specified parameters (e.g., shadow texture size, soft shadows).
Integration into Variational / Lagrangian Mechanics Framework
- The
Lightclass is an abstract base class that defines basic properties of lights such as color, position, direction, and various shadowing parameters. It does not fit into the broader variational or Lagrangian mechanics framework but rather complements it by providing visual effects.
Interactions with Other Components
- VisualModel Inheritance: The
Lightclass inherits fromVisualModel, which is responsible for managing visual representations of objects within SOFA scenes. - Dependency on LightManager: Each
Lightinstance requires aLightManagerto function properly, as it manages multiple light sources in the scene and handles shadow calculations. This ensures that all lights are managed consistently and integrated into the rendering pipeline.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
d_color |
sofa::type::RGBAColor | |
Set the color of the light. (default=[1.0,1.0,1.0,1.0]) |
d_shadowTextureSize |
GLuint | |
[Shadowing] Set size for shadow texture |
d_drawSource |
bool | |
Draw Light Source |
d_zNear |
float | |
[Shadowing] Light's ZNear |
d_zFar |
float | |
[Shadowing] Light's ZFar |
d_shadowsEnabled |
bool | |
[Shadowing] Enable Shadow from this light |
d_softShadows |
bool | |
[Shadowing] Turn on Soft Shadow from this light |
d_shadowFactor |
float | |
[Shadowing] Shadow Factor (decrease/increase darkness) |
d_VSMLightBleeding |
float | |
[Shadowing] (VSM only) Light bleeding parameter |
d_VSMMinVariance |
float | |
[Shadowing] (VSM only) Minimum variance parameter |
d_textureUnit |
unsigned short | |
[Shadowing] Texture unit for the generated shadow texture |
Methods
void
computeShadowMapSize
()
void
blurDepthTexture
()
void
setID
(const GLint & id)
void
doInitVisual
(const core::visual::VisualParams * vparams)
virtual
void
init
()
virtual
void
drawLight
(const core::visual::VisualParams * vparams)
virtual
void
reinit
()
virtual
void
doUpdateVisual
(const core::visual::VisualParams * vparams)
virtual
void
drawSource
(const sofa::core::visual::VisualParams * )
virtual
GLfloat
getZNear
()
GLfloat
getZFar
()
void
preDrawShadow
(core::visual::VisualParams * vp)
virtual
void
postDrawShadow
()
virtual
GLuint
getShadowMapSize
()
virtual
const GLfloat *
getOpenGLProjectionMatrix
()
const GLfloat *
getOpenGLModelViewMatrix
()
GLuint
getDepthTexture
()
virtual
GLuint
getColorTexture
()
virtual
const sofa::type::Vec3
getPosition
()
virtual
unsigned short
getShadowTextureUnit
()
virtual
void
setShadowTextureUnit
(const unsigned short unit)
virtual
type::Vec3
getDirection
()
virtual
float
getShadowFactor
()
virtual
float
getVSMLightBleeding
()
virtual
float
getVSMMinVariance
()
virtual
LightType
getLightType
()
virtual
{
"name": "Light",
"namespace": "sofa::gl::component::shader",
"module": "Sofa.GL.Component.Shader",
"include": "sofa/gl/component/shader/Light.h",
"doc": "A directional light illuminating the scene with parallel rays of light (can cast shadows).\n\nUtility to cast Light into a Opengl scene.\n This class must be used in a scene with one LightManager object.\n This abstract class defines lights (i.e basically id and color)\n The inherited lights are:\n - Directional light (direction);\n - Positional light (position);\n - Spot light (position, direction, cutoff...).",
"inherits": [
"VisualModel"
],
"templates": [],
"data_fields": [
{
"name": "d_color",
"type": "sofa::type::RGBAColor",
"xmlname": "color",
"help": "Set the color of the light. (default=[1.0,1.0,1.0,1.0])"
},
{
"name": "d_shadowTextureSize",
"type": "GLuint",
"xmlname": "shadowTextureSize",
"help": "[Shadowing] Set size for shadow texture "
},
{
"name": "d_drawSource",
"type": "bool",
"xmlname": "drawSource",
"help": "Draw Light Source"
},
{
"name": "d_zNear",
"type": "float",
"xmlname": "zNear",
"help": "[Shadowing] Light's ZNear"
},
{
"name": "d_zFar",
"type": "float",
"xmlname": "zFar",
"help": "[Shadowing] Light's ZFar"
},
{
"name": "d_shadowsEnabled",
"type": "bool",
"xmlname": "shadowsEnabled",
"help": "[Shadowing] Enable Shadow from this light"
},
{
"name": "d_softShadows",
"type": "bool",
"xmlname": "softShadows",
"help": "[Shadowing] Turn on Soft Shadow from this light"
},
{
"name": "d_shadowFactor",
"type": "float",
"xmlname": "shadowFactor",
"help": "[Shadowing] Shadow Factor (decrease/increase darkness)"
},
{
"name": "d_VSMLightBleeding",
"type": "float",
"xmlname": "VSMLightBleeding",
"help": "[Shadowing] (VSM only) Light bleeding parameter"
},
{
"name": "d_VSMMinVariance",
"type": "float",
"xmlname": "VSMMinVariance",
"help": "[Shadowing] (VSM only) Minimum variance parameter"
},
{
"name": "d_textureUnit",
"type": "unsigned short",
"xmlname": "textureUnit",
"help": "[Shadowing] Texture unit for the generated shadow texture"
}
],
"links": [],
"methods": [
{
"name": "computeShadowMapSize",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "blurDepthTexture",
"return_type": "void",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "setID",
"return_type": "void",
"params": [
{
"name": "id",
"type": "const GLint &"
}
],
"is_virtual": false,
"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": "init",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "drawLight",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"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": "doUpdateVisual",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "drawSource",
"return_type": "void",
"params": [
{
"name": "",
"type": "const sofa::core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": true,
"is_static": false,
"access": "public"
},
{
"name": "getZNear",
"return_type": "GLfloat",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getZFar",
"return_type": "GLfloat",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "preDrawShadow",
"return_type": "void",
"params": [
{
"name": "vp",
"type": "core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "postDrawShadow",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getShadowMapSize",
"return_type": "GLuint",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getOpenGLProjectionMatrix",
"return_type": "const GLfloat *",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getOpenGLModelViewMatrix",
"return_type": "const GLfloat *",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getDepthTexture",
"return_type": "GLuint",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getColorTexture",
"return_type": "GLuint",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getPosition",
"return_type": "const sofa::type::Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getShadowTextureUnit",
"return_type": "unsigned short",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setShadowTextureUnit",
"return_type": "void",
"params": [
{
"name": "unit",
"type": "const unsigned short"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getDirection",
"return_type": "type::Vec3",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getShadowFactor",
"return_type": "float",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getVSMLightBleeding",
"return_type": "float",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getVSMMinVariance",
"return_type": "float",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getLightType",
"return_type": "LightType",
"params": [],
"is_virtual": true,
"is_pure_virtual": true,
"is_static": false,
"access": "public"
}
],
"description": "The `Light` component in the SOFA framework is part of the `sofa::gl::component::shader` namespace and is used to illuminate the scene with directional, parallel rays of light that can cast shadows. This abstract class defines basic properties of lights such as color, position (for positional or spot lights), direction (for directional or spot lights), and various shadowing parameters. It must be used in conjunction with a `LightManager` object within the scene.\n\n**Role and Purpose:**\nThe primary role of `Light` is to provide illumination and visual effects through different types of light sources (directional, positional, or spotlight) for rendering purposes. This component interacts with shaders to apply lighting effects on the objects in the scene.\n\n**Interactions with Other Components:**\n- **VisualModel Inheritance**: The `Light` class inherits from `VisualModel`, which is responsible for managing visual representations of objects within SOFA scenes.\n- **Dependency on LightManager**: Each `Light` instance requires a `LightManager` to function properly, as it manages multiple light sources in the scene and handles shadow calculations.\n\n**Data Fields:**\nThe following fields can be configured via XML or programmatically:\n- `color`: Sets the color of the light (default is white).\n- `shadowTextureSize`: Defines the size for the shadow texture.\n- `drawSource`: Determines if the light source should be visualized in the scene.\n- `zNear` and `zFar`: Define near and far clipping planes for shadows.\n- `shadowsEnabled`, `softShadows`, and other shadow-related parameters control shadow effects, including soft shadows, shadow factors, variance shadow map (VSM) parameters, etc.\n\n**Usage Guidance:**\nThe `Light` component is used to enhance the visual realism of simulations by adding dynamic lighting. Users can configure various parameters to achieve desired visual effects. To use it effectively, ensure a `LightManager` is present in the scene and configure light properties via XML or programmatically.",
"maths": "The `Light` component in the SOFA framework does not contribute directly to the governing equations or operators related to mechanics, such as mass matrix $M$, stiffness matrix $K$, internal force $\boldsymbol{f}_{int}$, residual $\boldsymbol{R}$, etc. It is primarily a visual and rendering component used to illuminate the scene with different types of light sources (directional, positional, or spotlight) and manage shadow effects.\n\n### Governing Equations / Operators\n- **Light Component**: The `Light` class does not involve any governing equations related to continuum mechanics or variational formulations. Its primary role is to provide illumination and visual effects through different types of light sources.\n\n### Constitutive or Kinematic Laws Involved\n- **Constitutive Law**: None, as this component focuses on rendering rather than mechanical behavior.\n\n### Role in the Global FEM Pipeline\n- The `Light` component does not participate directly in the global FEM pipeline involving assembly, time integration, nonlinear solve, linear solve, constraint handling, or mapping. Instead, it interacts with shaders and visual representations to enhance the visual realism of simulations.\n\n### Numerical Methods or Discretization Choices\n- **Rendering**: The `Light` component does not involve numerical methods or discretization choices related to FEM simulation. It utilizes OpenGL for rendering purposes and handles shadow calculations based on specified parameters (e.g., shadow texture size, soft shadows).\n\n### Integration into Variational / Lagrangian Mechanics Framework\n- The `Light` class is an abstract base class that defines basic properties of lights such as color, position, direction, and various shadowing parameters. It does not fit into the broader variational or Lagrangian mechanics framework but rather complements it by providing visual effects.\n\n### Interactions with Other Components\n- **VisualModel Inheritance**: The `Light` class inherits from `VisualModel`, which is responsible for managing visual representations of objects within SOFA scenes.\n- **Dependency on LightManager**: Each `Light` instance requires a `LightManager` to function properly, as it manages multiple light sources in the scene and handles shadow calculations. This ensures that all lights are managed consistently and integrated into the rendering pipeline.",
"abstract": "The `Light` component illuminates the SOFA scene with directional, positional, or spot lights that can cast shadows, requiring a `LightManager` object for proper functioning.",
"sheet": "# Light\n\n## Overview\nThe `Light` component is part of the `sofa::gl::component::shader` namespace and provides illumination through different types of light sources (directional, positional, or spotlight) that can cast shadows. This abstract class must be used in conjunction with a `LightManager` object within the scene.\n\n## Parameters and Data\nThe following fields control various aspects of the light:\n- **color**: Sets the color of the light (default is white).\n- **shadowTextureSize**: Defines the size for the shadow texture.\n- **drawSource**: Determines if the light source should be visualized in the scene.\n- **zNear** and **zFar**: Define near and far clipping planes for shadows.\n- **shadowsEnabled**, **softShadows**, **shadowFactor**, **VSMLightBleeding**, **VSMMinVariance**: Control shadow effects, including soft shadows, shadow factors, and variance shadow map (VSM) parameters.\n\n## Dependencies and Connections\nThe `Light` component requires a `LightManager` object to function properly. It interacts with shaders to apply lighting effects on the objects in the scene."
}