![]() |
Skylicht Engine
|
Represents a programmable shader, including uniforms, UI, resources, instancing and platform-specific options. More...
#include <Material/Shader/CShader.h>
Classes | |
| struct | SUniformUI |
| Structure for describing a UI element for a uniform. Used for editor integration and presentation. More... | |
| struct | SResource |
| Structure describing a shader resource (texture, cube map, etc.). More... | |
| struct | SShader |
| Structure for storing shader source file names. More... | |
| struct | SShaderInstancing |
| Structure for instancing shader information. More... | |
| struct | SAttributeMapping |
| Structure for mapping UI attributes to uniforms. More... | |
Public Types | |
| enum | EUIControlType { UITexture = 0 , UIColor , UIFloat , UIFloat2 , UIFloat3 , UIFloat4 , UIGroup , UINone , UICount } |
| Enum for UI control types in material editor. | |
| enum | EResourceType { Texture = 0 , CubeTexture , ReflectionProbe , ShadowMap , TransformTexture , VertexPositionTexture , VertexNormalTexture , LastFrame , RTT0 , RTT1 , RTT2 , RTT3 , RTT4 , RTT5 , RTT6 , RTT7 , ResourceCount } |
| Enum for resource types used in shaders. | |
Public Member Functions | |
| CShader () | |
| Constructor. Initializes internal structures and built-in callbacks. | |
| virtual | ~CShader () |
| Destructor. Releases resources, UI, callbacks and instancing shaders. | |
| void | clear () |
| Clear all internal data (resources, uniforms, UI, etc.). | |
| void | initShader (io::IXMLReader *xmlReader, const char *source, const char *shaderFolder) |
| Initialize shader from XML definition. | |
| const std::string & | getName () |
| Get the name of the shader. | |
| const std::string & | getSource () |
| Get the source file path of the shader. | |
| const std::string & | getSoftwareSkinningName () |
| Get the name of the software skinning fallback shader. | |
| bool | isSkinning () |
| Returns true if the shader supports skinning. | |
| bool | isCustomShadowDepthWrite () |
| Returns true if a custom shadow depth write shader is defined. | |
| bool | isCustomShadowDistanceWrite () |
| Returns true if a custom shadow distance write shader is defined. | |
| CShader * | getSoftwareSkinningShader () |
| Get the software skinning fallback shader. | |
| CShader * | getInstancingShader (video::E_VERTEX_TYPE vtxType) |
| Get the instancing shader for a specific vertex type. | |
| std::string | getInstancingVertex (video::E_VERTEX_TYPE vtxType) |
| Get the vertex type name for instancing for a specific vertex type. | |
| bool | isSupportInstancing (video::E_VERTEX_TYPE vtxType) |
| Returns true if instancing is supported for the given vertex type. | |
| void | setInstancing (video::E_VERTEX_TYPE vtxType, IShaderInstancing *instancing) |
| Set a custom instancing logic for a specific vertex type. | |
| IShaderInstancing * | getInstancing (video::E_VERTEX_TYPE vtxType) |
| Get the custom instancing logic for a specific vertex type. | |
| void | setShadowDepthWriteShader (const char *name) |
| Set the custom shadow depth write shader by name. | |
| void | setShadowDistanceWriteShader (const char *name) |
| Set the custom shadow distance write shader by name. | |
| CShader * | getShadowDepthWriteShader () |
| Get the custom shadow depth write shader. | |
| CShader * | getShadowDistanceWriteShader () |
| Get the custom shadow distance write shader. | |
| int | getAttributeMappingCount () |
| Get the number of attribute mappings for editor integration. | |
| SAttributeMapping & | getAttributeMapping (int id) |
| Get an attribute mapping by index. | |
| int | getNumResource () |
| Get the number of texture resources bind in shader. | |
| int | getNumVS () |
| Get the number of vertex shader uniforms. | |
| int | getNumFS () |
| Get the number of fragment shader uniforms. | |
| SResource * | getResouceInfo (int id) |
| Get a shader resource info by index. | |
| SUniform * | getVSUniformID (int id) |
| Get a vertex shader uniform by index. | |
| SUniform * | getFSUniformID (int id) |
| Get a fragment shader uniform by index. | |
| int | getNumUI () |
| Get the number of UI elements. | |
| SUniformUI * | getUniformUI (int id) |
| Get a UI element by index. | |
| std::vector< std::string > & | getDependents () |
| Get the list of dependent shader paths. | |
| SUniformUI * | getUniformUIByName (const char *name) |
| Get a UI element by uniform name. | |
| SUniformUI * | getUniformUIByName (const char *name, SUniformUI *group) |
| Get a UI element by uniform name within a UI group. | |
| SUniform * | getVSUniform (const char *name) |
| Get a vertex shader uniform by name. | |
| SUniform * | getFSUniform (const char *name) |
| Get a fragment shader uniform by name. | |
| bool | isDeferred () |
| Returns true if this shader is used for deferred rendering. | |
| bool | isOpaque () |
| Returns true if this shader is an opaque base shader. | |
| E_MATERIAL_TYPE | getBaseMaterial () |
| Get the base material type of this shader. | |
| virtual void | OnSetConstants (video::IMaterialRendererServices *services, s32 userData, bool updateTransform) |
| Callback to set shader constants (uniforms) for rendering. | |
| template<class T> | |
| IShaderCallback * | addCallback () |
| Add a custom callback to the shader for setting constants. | |
| template<class T> | |
| T * | getCallback () |
| Get a custom callback of a specific type. | |
| void | buildShader () |
| Build the shader by compiling vertex and fragment sources and registering with the engine. | |
| void | buildUIUniform () |
| Build UI uniform bindings for editor integration. | |
| bool | isDrawDepthShadow () |
| Returns true if this shader renders depth for shadows. | |
| Public Member Functions inherited from Skylicht::CBaseShaderCallback | |
| void | setMaterialRenderID (int id) |
| int | getMaterialRenderID () |
| void | offsetUV (core::vector2df &uv, float speedX, float speedY) |
| bool | isOpenGLFamily () |
| void | setColor (IMaterialRenderer *matRender, int colorID, bool vertexConstant, const SColorf &c, float intensity) |
| void | setWorldDirection (IMaterialRenderer *matRender, int directionID, bool vertexConstant, const core::vector3df &dir, int count=4) |
| void | setWorldInvPosition (IMaterialRenderer *matRender, int posID, const core::vector3df &pos, bool vertexConstant=true) |
| void | setWorldPosition (IMaterialRenderer *matRender, int posID, const core::vector3df &pos, bool vertexConstant=true) |
| Public Member Functions inherited from irr::video::IShaderConstantSetCallBack | |
| virtual void | OnSetMaterial (const SMaterial &material) |
| Called to let the callBack know the used material (optional method). | |
| Public Member Functions inherited from irr::IReferenceCounted | |
| IReferenceCounted () | |
| Constructor. | |
| virtual | ~IReferenceCounted () |
| Destructor. | |
| void | grab () const |
| Grabs the object. Increments the reference counter by one. | |
| bool | drop () const |
| Drops the object. Decrements the reference counter by one. | |
| s32 | getReferenceCount () const |
| Get the reference count. | |
| const c8 * | getDebugName () const |
| Returns the debug name of the object. | |
Protected Member Functions | |
| void | parseUniform (io::IXMLReader *xmlReader) |
| Parse uniform definitions from XML. | |
| void | parseUniformUI (io::IXMLReader *xmlReader) |
| Parse UI uniform definitions from XML. | |
| void | parseResources (io::IXMLReader *xmlReader) |
| Parse resource definitions from XML. | |
| void | parseUI (io::IXMLReader *xmlReader, SUniformUI *parent) |
| Parse UI group hierarchy from XML. | |
| E_MATERIAL_TYPE | getBaseShaderByName (const char *name) |
| Get the base shader type by its name string (SOLID, TRANSPARENT, etc.). | |
| EUniformType | getUniformType (const char *name) |
| Get the uniform type enum from its name string. | |
| std::string | getVSShaderFileName () |
| Get the full path to the vertex shader source file (GLSL/HLSL). | |
| std::string | getFSShaderFileName () |
| Get the full path to the fragment/pixel shader source file (GLSL/HLSL). | |
| void | buildUIUniform (SUniformUI *ui) |
| Recursively build UI uniform bindings for a UI element. | |
| bool | isUniformAvaiable (SUniform &uniform) |
| Check if a uniform is available on the current graphics API. | |
| bool | setUniform (SUniform &uniform, IMaterialRenderer *matRender, bool vertexShader, bool updateTransform) |
| Try to set a uniform value for rendering. | |
| void | deleteAllUI () |
| Delete all UI elements. | |
| void | deleteAllResource () |
| Delete all shader resources. | |
| Protected Member Functions inherited from irr::IReferenceCounted | |
| void | setDebugName (const c8 *newName) |
| Sets the debug name of the object. | |
Protected Attributes | |
| std::string | m_name |
| Shader name. | |
| core::array< SUniform > | m_vsUniforms |
| Vertex shader uniforms. | |
| core::array< SUniform > | m_fsUniforms |
| Pixel / fragment shader uniforms. | |
| core::array< SUniformUI * > | m_ui |
| UI elements. | |
| core::array< SResource * > | m_resources |
| Shader texture resources. | |
| core::array< SAttributeMapping > | m_attributeMapping |
| UI to uniform mapping. | |
| std::vector< IShaderCallback * > | m_callbacks |
| Shader callbacks. | |
| std::vector< std::string > | m_dependents |
| Dependent shader paths. | |
| SUniform * | m_listVSUniforms |
| Pointer to VS uniforms (m_vsUniforms). | |
| SUniform * | m_listFSUniforms |
| Pointer to FS uniforms (m_fsUniforms). | |
| int | m_numVSUniform |
| Count of VS uniforms. | |
| int | m_numFSUniform |
| Count of FS uniforms. | |
| SShader | m_glsl |
| GLSL shader source. | |
| SShader | m_hlsl |
| HLSL shader source. | |
| E_MATERIAL_TYPE | m_baseShader |
| Base material type(opaque, transparent, etc.). | |
| bool | m_deferred |
| Is shader for deferred rendering. | |
| bool | m_skinning |
| Is shader for skinning. | |
| bool | m_shadow |
| Is shader for shadow rendering. | |
| std::string | m_softwareSkinningShaderName |
| Fallback software skinning shader name. | |
| CShader * | m_softwareSkinningShader |
| Fallback software skinning shader. | |
| std::string | m_shadowDepthShaderName |
| Custom shadow depth shader name for directional light. | |
| std::string | m_shadowDistanceShaderName |
| Custom shadow distance shader name for point light. | |
| CShader * | m_shadowDepthShader |
| Custom shadow depth shader. | |
| CShader * | m_shadowDistanceShader |
| Custom shadow distance shader. | |
| SShaderInstancing * | m_shaderInstancing [video::EVT_UNKNOWN+1] |
| Instancing shader info by vertex type. | |
| std::string | m_source |
| Source file path. | |
| Protected Attributes inherited from Skylicht::CBaseShaderCallback | |
| int | m_materialRenderID |
| bool | m_initCallback |
Represents a programmable shader, including uniforms, UI, resources, instancing and platform-specific options.
Handles parsing from XML, managing uniform parameters, callbacks, shadow/deferred settings, and integration with both OpenGL and DirectX. See documentation page: Shader information structure.
|
inline |
Add a custom callback to the shader for setting constants.
| T | The callback class, must inherit IShaderCallback. |
|
protected |
Recursively build UI uniform bindings for a UI element.
| ui | Pointer to SUniformUI element. |
|
inline |
Get an attribute mapping by index.
| id | Index of the mapping. |
|
inline |
Get the number of attribute mappings for editor integration.
|
inline |
Get the base material type of this shader.
|
protected |
Get the base shader type by its name string (SOLID, TRANSPARENT, etc.).
| name | Name string. |
|
inline |
Get a custom callback of a specific type.
| T | The callback class type. |
|
inline |
Get the list of dependent shader paths.
|
protected |
Get the full path to the fragment/pixel shader source file (GLSL/HLSL).
| SUniform * Skylicht::CShader::getFSUniform | ( | const char * | name | ) |
|
inline |
| IShaderInstancing * Skylicht::CShader::getInstancing | ( | video::E_VERTEX_TYPE | vtxType | ) |
Get the custom instancing logic for a specific vertex type.
| vtxType | Vertex type. |
| CShader * Skylicht::CShader::getInstancingShader | ( | video::E_VERTEX_TYPE | vtxType | ) |
Get the instancing shader for a specific vertex type.
| vtxType | Vertex type. |
| std::string Skylicht::CShader::getInstancingVertex | ( | video::E_VERTEX_TYPE | vtxType | ) |
Get the vertex type name for instancing for a specific vertex type.
| vtxType | Vertex type. |
|
inline |
Get the name of the shader.
|
inline |
Get the number of fragment shader uniforms.
|
inline |
Get the number of texture resources bind in shader.
|
inline |
|
inline |
Get the number of vertex shader uniforms.
|
inline |
| CShader * Skylicht::CShader::getShadowDepthWriteShader | ( | ) |
Get the custom shadow depth write shader.
| CShader * Skylicht::CShader::getShadowDistanceWriteShader | ( | ) |
Get the custom shadow distance write shader.
|
inline |
Get the name of the software skinning fallback shader.
| CShader * Skylicht::CShader::getSoftwareSkinningShader | ( | ) |
Get the software skinning fallback shader.
|
inline |
Get the source file path of the shader.
|
protected |
Get the uniform type enum from its name string.
| name | Uniform name. |
|
inline |
| SUniformUI * Skylicht::CShader::getUniformUIByName | ( | const char * | name | ) |
| SUniformUI * Skylicht::CShader::getUniformUIByName | ( | const char * | name, |
| SUniformUI * | group ) |
Get a UI element by uniform name within a UI group.
| name | Uniform name. |
| group | UI group parent. |
|
protected |
Get the full path to the vertex shader source file (GLSL/HLSL).
| SUniform * Skylicht::CShader::getVSUniform | ( | const char * | name | ) |
|
inline |
| void Skylicht::CShader::initShader | ( | io::IXMLReader * | xmlReader, |
| const char * | source, | ||
| const char * | shaderFolder ) |
Initialize shader from XML definition.
| xmlReader | XML reader object pointing to shader definition. |
| source | Shader source file path. |
| shaderFolder | Folder containing shader files. |
| bool Skylicht::CShader::isSupportInstancing | ( | video::E_VERTEX_TYPE | vtxType | ) |
Returns true if instancing is supported for the given vertex type.
| vtxType | Vertex type. |
|
protected |
Check if a uniform is available on the current graphics API.
| uniform | Reference to SUniform. |
|
virtual |
Callback to set shader constants (uniforms) for rendering.
| services | Renderer services. |
| userData | User data. |
| updateTransform | True to update transforms. |
Implements irr::video::IShaderConstantSetCallBack.
|
protected |
Parse resource definitions from XML.
| xmlReader | XML reader object. |
|
protected |
|
protected |
Parse uniform definitions from XML.
| xmlReader | XML reader object. |
|
protected |
Parse UI uniform definitions from XML.
| xmlReader | XML reader object. |
| void Skylicht::CShader::setInstancing | ( | video::E_VERTEX_TYPE | vtxType, |
| IShaderInstancing * | instancing ) |
Set a custom instancing logic for a specific vertex type.
| vtxType | Vertex type. |
| instancing | Pointer to IShaderInstancing implementation. |
| void Skylicht::CShader::setShadowDepthWriteShader | ( | const char * | name | ) |
Set the custom shadow depth write shader by name.
| name | Shader name. |
| void Skylicht::CShader::setShadowDistanceWriteShader | ( | const char * | name | ) |
Set the custom shadow distance write shader by name.
| name | Shader name. |
|
protected |
Try to set a uniform value for rendering.
| uniform | Reference to SUniform. |
| matRender | Material renderer. |
| vertexShader | True for vertex shader, false for pixel shader. |
| updateTransform | True to update transforms. This is because the object's transform is sometimes unchanged, meaning there's no need to update it. |