OglShader
Set custom shader for the current visual context. Utility to use shader for a visual model in OpenGL. This class is used to implement shader into Sofa, for visual rendering or for special treatment that needs shader mechanism. The 3 kinds of shaders can be defined : vertex, triangle and fragment. Geometry shader is only available with Nvidia's >8 series and Ati's >2K series.
`OglShader` sets custom shaders for the current visual context in SOFA, enabling advanced graphical effects through vertex, triangle, fragment, and geometry shaders.
- module
- Sofa.GL.Component.Shader
- namespace
- sofa::gl::component::shader
- include
- sofa/gl/component/shader/OglShader.h
- inherits
-
- Shader
- VisualModel
- description
The OglShader class in the SOFA framework is primarily focused on graphical rendering and does not directly contribute to the governing equations or operators typically found in FEM simulations such as mass matrix $ M $, stiffness matrix $ K $, internal force $ f_{int} $, residual $ R $, etc. Instead, its role is to enhance visual output through custom shader programs written in OpenGL Shading Language (GLSL). The class facilitates the definition and management of vertex, triangle, fragment, and geometry shaders within the SOFA simulation environment.
Governing Equations/Operators:
- No Direct Contribution:
OglShaderdoes not directly implement or contribute to any specific FEM operators like mass matrix $ M $, stiffness matrix $ K $, internal force vector $ f_{int} $, or residual $ R $. Instead, it focuses on visual rendering enhancements.
Constitutive or Kinematic Laws Involved:
- None: The class does not involve any constitutive laws related to material behavior (such as stress-strain relationships) or kinematic laws of deformation. It is purely a graphical enhancement tool.
Role in the Global FEM Pipeline:
- Visual Rendering:
OglShaderplays a role in enhancing visual rendering by allowing users to apply custom shaders for vertex, triangle, fragment, and geometry transformations. These shaders can be used to implement special effects or treatments that require shader mechanisms.
Numerical Methods or Discretization Choices Encoded:
- None: The class does not encode any numerical methods specific to FEM discretization (such as finite element shape functions, weak form derivation, or Gauss integration). Instead, it deals with graphical transformations and rendering.
Integration into Variational/Lagrangian Mechanics Framework:
- Graphical Rendering Only:
OglShaderis a tool for enhancing visual output and does not directly integrate into the variational or Lagrangian mechanics framework used in FEM simulations. It interacts primarily with the SOFA scene graph architecture to manage shader states, set uniform values, and configure geometry shaders.
Summary:
- The
OglShaderclass is a utility for setting custom shaders within the OpenGL visual context of the SOFA simulation environment. Its primary purpose is to enhance graphical rendering through vertex, triangle, fragment, and geometry shaders, rather than contributing directly to the mathematical or physical modeling aspects of FEM simulations.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
turnOn |
bool | |
Turn On the shader? |
passive |
bool | |
Will this shader be activated manually or automatically? |
geometryInputType |
int | |
Set input types for the geometry shader |
geometryOutputType |
int | |
Set output types for the geometry shader |
geometryVerticesOut |
int | |
Set max number of vertices in output for the geometry shader |
tessellationOuterLevel |
GLfloat | |
For tessellation without control shader: default outer level (edge subdivisions) |
tessellationInnerLevel |
GLfloat | |
For tessellation without control shader: default inner level (face subdivisions) |
indexActiveShader |
unsigned int | |
Set current active shader |
backfaceWriting |
bool | |
it enables writing to gl_BackColor inside a GLSL vertex shader |
clampVertexColor |
bool | |
clamp the vertex color between 0 and 1 |
Methods
void
doInitVisual
(const core::visual::VisualParams * )
virtual
void
init
()
virtual
void
reinit
()
virtual
void
parse
(core::objectmodel::BaseObjectDescription * arg)
virtual
void
start
()
virtual
void
stop
()
virtual
bool
isActive
()
virtual
unsigned int
getNumberOfShaders
()
unsigned int
getCurrentIndex
()
void
setCurrentIndex
(const unsigned int index)
void
addDefineMacro
(const unsigned int index, const int & name, const int & value)
void
setTexture
(const unsigned int index, const char * name, unsigned short unit)
void
setInt
(const unsigned int index, const char * name, int i)
void
setInt2
(const unsigned int index, const char * name, int i1, int i2)
void
setInt3
(const unsigned int index, const char * name, int i1, int i2, int i3)
void
setInt4
(const unsigned int index, const char * name, int i1, int i2, int i3, int i4)
void
setFloat
(const unsigned int index, const char * name, float f1)
void
setFloat2
(const unsigned int index, const char * name, float f1, float f2)
void
setFloat3
(const unsigned int index, const char * name, float f1, float f2, float f3)
void
setFloat4
(const unsigned int index, const char * name, float f1, float f2, float f3, float f4)
void
setIntVector
(const unsigned int index, const char * name, int count, const GLint * i)
void
setIntVector2
(const unsigned int index, const char * name, int count, const GLint * i)
void
setIntVector3
(const unsigned int index, const char * name, int count, const GLint * i)
void
setIntVector4
(const unsigned int index, const char * name, int count, const GLint * i)
void
setFloatVector
(const unsigned int index, const char * name, int count, const float * f)
void
setFloatVector2
(const unsigned int index, const char * name, int count, const float * f)
void
setFloatVector3
(const unsigned int index, const char * name, int count, const float * f)
void
setFloatVector4
(const unsigned int index, const char * name, int count, const float * f)
void
setMatrix2
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix3
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix4
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix2x3
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix3x2
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix2x4
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix4x2
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix3x4
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
void
setMatrix4x3
(const unsigned int index, const char * name, int count, bool transpose, const float * f)
GLint
getAttribute
(const unsigned int index, const char * name)
GLint
getUniform
(const unsigned int index, const char * name)
GLint
getGeometryInputType
(const unsigned int index)
void
setGeometryInputType
(const unsigned int index, GLint v)
GLint
getGeometryOutputType
(const unsigned int index)
void
setGeometryOutputType
(const unsigned int index, GLint v)
GLint
getGeometryVerticesOut
(const unsigned int index)
void
setGeometryVerticesOut
(const unsigned int index, GLint v)
bool
insertInNode
(core::objectmodel::BaseNode * node)
virtual
bool
removeInNode
(core::objectmodel::BaseNode * node)
virtual
{
"name": "OglShader",
"namespace": "sofa::gl::component::shader",
"module": "Sofa.GL.Component.Shader",
"include": "sofa/gl/component/shader/OglShader.h",
"doc": "Set custom shader for the current visual context.\n\nUtility to use shader for a visual model in OpenGL.\n This class is used to implement shader into Sofa, for visual rendering\n or for special treatment that needs shader mechanism.\n The 3 kinds of shaders can be defined : vertex, triangle and fragment.\n Geometry shader is only available with Nvidia's >8 series\n and Ati's >2K series.",
"inherits": [
"Shader",
"VisualModel"
],
"templates": [],
"data_fields": [
{
"name": "turnOn",
"type": "bool",
"xmlname": "turnOn",
"help": "Turn On the shader?"
},
{
"name": "passive",
"type": "bool",
"xmlname": "passive",
"help": "Will this shader be activated manually or automatically?"
},
{
"name": "geometryInputType",
"type": "int",
"xmlname": "geometryInputType",
"help": "Set input types for the geometry shader"
},
{
"name": "geometryOutputType",
"type": "int",
"xmlname": "geometryOutputType",
"help": "Set output types for the geometry shader"
},
{
"name": "geometryVerticesOut",
"type": "int",
"xmlname": "geometryVerticesOut",
"help": "Set max number of vertices in output for the geometry shader"
},
{
"name": "tessellationOuterLevel",
"type": "GLfloat",
"xmlname": "tessellationOuterLevel",
"help": "For tessellation without control shader: default outer level (edge subdivisions)"
},
{
"name": "tessellationInnerLevel",
"type": "GLfloat",
"xmlname": "tessellationInnerLevel",
"help": "For tessellation without control shader: default inner level (face subdivisions)"
},
{
"name": "indexActiveShader",
"type": "unsigned int",
"xmlname": "indexActiveShader",
"help": "Set current active shader"
},
{
"name": "backfaceWriting",
"type": "bool",
"xmlname": "backfaceWriting",
"help": "it enables writing to gl_BackColor inside a GLSL vertex shader"
},
{
"name": "clampVertexColor",
"type": "bool",
"xmlname": "clampVertexColor",
"help": "clamp the vertex color between 0 and 1"
}
],
"links": [],
"methods": [
{
"name": "doInitVisual",
"return_type": "void",
"params": [
{
"name": "",
"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": "reinit",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "parse",
"return_type": "void",
"params": [
{
"name": "arg",
"type": "core::objectmodel::BaseObjectDescription *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "start",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "stop",
"return_type": "void",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isActive",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getNumberOfShaders",
"return_type": "unsigned int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getCurrentIndex",
"return_type": "unsigned int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setCurrentIndex",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "addDefineMacro",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const int &"
},
{
"name": "value",
"type": "const int &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setTexture",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "unit",
"type": "unsigned short"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setInt",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "i",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setInt2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "i1",
"type": "int"
},
{
"name": "i2",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setInt3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "i1",
"type": "int"
},
{
"name": "i2",
"type": "int"
},
{
"name": "i3",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setInt4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "i1",
"type": "int"
},
{
"name": "i2",
"type": "int"
},
{
"name": "i3",
"type": "int"
},
{
"name": "i4",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloat",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "f1",
"type": "float"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloat2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "f1",
"type": "float"
},
{
"name": "f2",
"type": "float"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloat3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "f1",
"type": "float"
},
{
"name": "f2",
"type": "float"
},
{
"name": "f3",
"type": "float"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloat4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "f1",
"type": "float"
},
{
"name": "f2",
"type": "float"
},
{
"name": "f3",
"type": "float"
},
{
"name": "f4",
"type": "float"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setIntVector",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "i",
"type": "const GLint *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setIntVector2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "i",
"type": "const GLint *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setIntVector3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "i",
"type": "const GLint *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setIntVector4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "i",
"type": "const GLint *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloatVector",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloatVector2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloatVector3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setFloatVector4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix2x3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix3x2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix2x4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix4x2",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix3x4",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setMatrix4x3",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
},
{
"name": "count",
"type": "int"
},
{
"name": "transpose",
"type": "bool"
},
{
"name": "f",
"type": "const float *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getAttribute",
"return_type": "GLint",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getUniform",
"return_type": "GLint",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "name",
"type": "const char *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getGeometryInputType",
"return_type": "GLint",
"params": [
{
"name": "index",
"type": "const unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setGeometryInputType",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "v",
"type": "GLint"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getGeometryOutputType",
"return_type": "GLint",
"params": [
{
"name": "index",
"type": "const unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setGeometryOutputType",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "v",
"type": "GLint"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getGeometryVerticesOut",
"return_type": "GLint",
"params": [
{
"name": "index",
"type": "const unsigned int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "setGeometryVerticesOut",
"return_type": "void",
"params": [
{
"name": "index",
"type": "const unsigned int"
},
{
"name": "v",
"type": "GLint"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "insertInNode",
"return_type": "bool",
"params": [
{
"name": "node",
"type": "core::objectmodel::BaseNode *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "removeInNode",
"return_type": "bool",
"params": [
{
"name": "node",
"type": "core::objectmodel::BaseNode *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `OglShader` class in the SOFA framework is part of the Sofa.GL.Component.Shader module and serves as a utility for setting custom shaders within the OpenGL visual context. It inherits from the Shader and VisualModel classes, indicating its role in defining and managing shader programs that enhance or modify the visual rendering process.\n\n**Role and Purpose:**\n`OglShader` allows users to define vertex, triangle, and fragment shaders for a given visual model. It can also handle geometry shaders (available on specific hardware) for more complex transformations of geometric primitives. This class is essential for integrating advanced graphical effects or special treatments that require shader mechanisms into the SOFA simulation environment.\n\n**Interactions with Other Components:**\nThe `OglShader` interacts primarily through its virtual methods (`init`, `reinit`, `parse`, etc.) to integrate seamlessly with other components in the scene graph architecture. It also provides public methods for setting various parameters (e.g., texture, uniform values) and managing shader states (e.g., activation, index management).\n\n**Practical Usage Guidance:**\nThe key data fields of `OglShader` include:\n- **turnOn**: A boolean to enable or disable the shader.\n- **passive**: Controls whether the shader is activated manually or automatically.\n- **geometryInputType**, **geometryOutputType**, and **geometryVerticesOut**: Configure geometry shaders by setting input types, output types, and maximum vertices in the output.\n- **tessellationOuterLevel** and **tessellationInnerLevel**: Define tessellation parameters for subdividing edges and faces.\n- **indexActiveShader**: Sets the currently active shader index from among multiple defined shaders.\n\nThe class offers a wide range of methods to set various types of uniform variables (integers, floats, vectors, matrices) in the shaders. Additionally, it provides methods to manage geometry shader parameters and handle insertion/removal within the SOFA scene graph.",
"maths": "The `OglShader` class in the SOFA framework is primarily focused on graphical rendering and does not directly contribute to the governing equations or operators typically found in FEM simulations such as mass matrix \\( M \\), stiffness matrix \\( K \\), internal force \\( f_{int} \\), residual \\( R \\), etc. Instead, its role is to enhance visual output through custom shader programs written in OpenGL Shading Language (GLSL). The class facilitates the definition and management of vertex, triangle, fragment, and geometry shaders within the SOFA simulation environment.\n\n### Governing Equations/Operators:\n- **No Direct Contribution**: `OglShader` does not directly implement or contribute to any specific FEM operators like mass matrix \\( M \\), stiffness matrix \\( K \\), internal force vector \\( f_{int} \\), or residual \\( R \\). Instead, it focuses on visual rendering enhancements.\n\n### Constitutive or Kinematic Laws Involved:\n- **None**: The class does not involve any constitutive laws related to material behavior (such as stress-strain relationships) or kinematic laws of deformation. It is purely a graphical enhancement tool.\n\n### Role in the Global FEM Pipeline:\n- **Visual Rendering**: `OglShader` plays a role in enhancing visual rendering by allowing users to apply custom shaders for vertex, triangle, fragment, and geometry transformations. These shaders can be used to implement special effects or treatments that require shader mechanisms.\n\n### Numerical Methods or Discretization Choices Encoded:\n- **None**: The class does not encode any numerical methods specific to FEM discretization (such as finite element shape functions, weak form derivation, or Gauss integration). Instead, it deals with graphical transformations and rendering.\n\n### Integration into Variational/Lagrangian Mechanics Framework:\n- **Graphical Rendering Only**: `OglShader` is a tool for enhancing visual output and does not directly integrate into the variational or Lagrangian mechanics framework used in FEM simulations. It interacts primarily with the SOFA scene graph architecture to manage shader states, set uniform values, and configure geometry shaders.\n\n### Summary:\n- The `OglShader` class is a utility for setting custom shaders within the OpenGL visual context of the SOFA simulation environment. Its primary purpose is to enhance graphical rendering through vertex, triangle, fragment, and geometry shaders, rather than contributing directly to the mathematical or physical modeling aspects of FEM simulations.",
"abstract": "`OglShader` sets custom shaders for the current visual context in SOFA, enabling advanced graphical effects through vertex, triangle, fragment, and geometry shaders.",
"sheet": "# OglShader\n\n## Overview\n`OglShader` is a utility class that allows users to define and manage custom shaders within the OpenGL visual context of the SOFA framework. It supports vertex, triangle, fragment, and geometry shaders for enhancing graphical rendering.\n\n## Parameters and Data\n- **turnOn**: A boolean field to enable or disable the shader (`bool`, default: `false`).\n- **passive**: Controls whether the shader is activated manually or automatically (`bool`, default: `true`).\n- **geometryInputType**: Sets input types for the geometry shader (`int`, default: `0`).\n- **geometryOutputType**: Sets output types for the geometry shader (`int`, default: `0`).\n- **geometryVerticesOut**: Sets the maximum number of vertices in the output for the geometry shader (`int`, default: `1`).\n- **tessellationOuterLevel**: Defines the outer level (edge subdivisions) for tessellation without a control shader (`GLfloat`, default: `1.0f`).\n- **tessellationInnerLevel**: Defines the inner level (face subdivisions) for tessellation without a control shader (`GLfloat`, default: `1.0f`).\n- **indexActiveShader**: Sets the current active shader index from among multiple defined shaders (`unsigned int`, default: `0`).\n- **backfaceWriting**: Enables writing to `gl_BackColor` inside a GLSL vertex shader (`bool`, default: `false`).\n- **clampVertexColor**: Clamps the vertex color between 0 and 1 (`bool`, default: `false`).\n\n## Practical Notes\n- Geometry shaders are only available on specific hardware (Nvidia >8 series, Ati >2K series).\n- The shader can be activated manually or automatically based on the `passive` parameter.\n- Tessellation parameters (`tessellationOuterLevel`, `tessellationInnerLevel`) control edge and face subdivisions for tessellation without a control shader."
}