![]() |
Skylicht Engine
|
Centralized manager for loading, caching, rebuilding, and controlling shader objects in Skylicht-Engine. More...
#include <Material/Shader/CShaderManager.h>
Public Member Functions | |
| CShaderManager () | |
| Constructor. | |
| virtual | ~CShaderManager () |
| Destructor. Releases all loaded shaders. | |
| void | releaseAll () |
| Release all loaded shaders and associated resources. | |
| void | setCurrentMeshBuffer (IMeshBuffer *buffer) |
| Set the mesh buffer to be used for current rendering. | |
| IMeshBuffer * | getCurrentMeshBuffer () |
| Get the mesh buffer currently used for rendering. | |
| void | setCurrentMaterial (SMaterial &mat) |
| Set the material to be used for current rendering. | |
| SMaterial * | getCurrentMaterial () |
| Get the material currently used for rendering. | |
| void | initGUIShader () |
| Initialize built-in GUI shaders required for Skylicht's UI rendering. | |
| void | initBasicShader () |
| Initialize basic built-in shaders for basic rendering features. | |
| void | initSGDeferredShader () |
| Initialize built-in shaders for Specular-Glossiness Deferred rendering. | |
| void | initSGForwarderShader () |
| Initialize built-in shaders for Specular-Glossiness Forward rendering. | |
| void | initMobileSGShader () |
| Initialize built-in shaders for mobile platforms. | |
| void | initPBRForwarderShader () |
| Initialize built-in shaders for Physically-Based Rendering (PBR) forward pipeline. | |
| void | initSkylichtEngineShader () |
| Initialize all core engine shaders (deferred, forward, etc.). | |
| void | initShader () |
| Initialize all shader systems (calls basic and engine shader initializers). | |
| CShader * | loadShader (const char *shaderConfig) |
| Load a shader from an XML configuration file. If the shader is already loaded, returns the cached instance. | |
| bool | rebuildShader (CShader *shader) |
| Rebuild a shader by reloading its configuration from source file. Useful for hot-reloading, debugging, or updating shaders at runtime. | |
| int | getShaderIDByName (const char *name) |
| Get the material ID of a shader by its name. | |
| CShader * | getShaderByName (const char *name) |
| Get a shader instance by its name. | |
| CShader * | getShaderByPath (const char *path) |
| Get a shader instance by its source path. | |
| CShader * | getShaderByID (int id) |
| Get a shader instance by its internal material ID. | |
| std::string | getShaderFileName (const char *fileName) |
| Get the shader file name with the appropriate extension for the current graphics API. Appends .hlsl for Direct3D, .glsl for OpenGL. | |
| int | getNumShader () |
| Get the number of loaded shader materials. | |
| CShader * | getShader (int i) |
| Get a loaded shader material by index. | |
Public Attributes | |
| core::vector2df | ShaderVec2 [10] |
| core::vector3df | ShaderVec3 [10] |
| video::SVec4 | ShaderVec4 [10] |
| f32 * | BoneMatrix |
| u32 | BoneCount |
| float | LightmapIndex |
| std::function< IShaderInstancing *(const char *)> | OnCreateInstancingVertex |
Protected Member Functions | |
| bool | buildShader (CShader *shader, io::IXMLReader *xmlReader, const char *source, const char *shaderFolder, bool rebuild) |
| Internal function to build a shader from XML, source, and folder. Handles dependency loading, instancing setup, and error logging. | |
Protected Attributes | |
| IMeshBuffer * | m_currentMeshBuffer |
| Pointer to mesh buffer currently being rendered. | |
| SMaterial * | m_currentMatRendering |
| Pointer to material currently being rendered. | |
| std::vector< CShader * > | m_listShader |
| List of loaded shaders. | |
| std::map< std::string, int > | m_listShaderID |
| Map from shader name to internal material ID. | |
Centralized manager for loading, caching, rebuilding, and controlling shader objects in Skylicht-Engine.
Handles initialization of built - in shaders for various rendering pipelines(basic, deferred, forward, mobile, PBR, etc.), manages shader instancing, uniform storage, and provides lookup functions for accessing shaders by name, path, or ID.
Allows for dynamic shader loading, rebuilding, and provides access to current rendering context (mesh / material).
Example usage :
|
protected |
Internal function to build a shader from XML, source, and folder. Handles dependency loading, instancing setup, and error logging.
| shader | Pointer to shader to build. |
| xmlReader | XML reader for shader config. |
| source | Source path. |
| shaderFolder | Shader folder path. |
| rebuild | True if rebuilding, false if initial load. |
|
inline |
Get the material currently used for rendering.
|
inline |
Get the mesh buffer currently used for rendering.
|
inline |
Get the number of loaded shader materials.
|
inline |
Get a loaded shader material by index.
| i | Index of the shader. |
| CShader * Skylicht::CShaderManager::getShaderByID | ( | int | id | ) |
Get a shader instance by its internal material ID.
| id | Internal material ID. |
| CShader * Skylicht::CShaderManager::getShaderByName | ( | const char * | name | ) |
Get a shader instance by its name.
| name | Name of the shader. |
| CShader * Skylicht::CShaderManager::getShaderByPath | ( | const char * | path | ) |
Get a shader instance by its source path.
| path | Path to shader source/config file. |
| std::string Skylicht::CShaderManager::getShaderFileName | ( | const char * | fileName | ) |
Get the shader file name with the appropriate extension for the current graphics API. Appends .hlsl for Direct3D, .glsl for OpenGL.
| fileName | Base file name. |
| int Skylicht::CShaderManager::getShaderIDByName | ( | const char * | name | ) |
Get the material ID of a shader by its name.
| name | Name of the shader. |
| CShader * Skylicht::CShaderManager::loadShader | ( | const char * | shaderConfig | ) |
Load a shader from an XML configuration file. If the shader is already loaded, returns the cached instance.
| shaderConfig | Path to shader XML file. |
| bool Skylicht::CShaderManager::rebuildShader | ( | CShader * | shader | ) |
Rebuild a shader by reloading its configuration from source file. Useful for hot-reloading, debugging, or updating shaders at runtime.
| shader | Pointer to shader to rebuild. |
|
inline |
Set the material to be used for current rendering.
| mat | Reference to material. |
|
inline |
Set the mesh buffer to be used for current rendering.
| buffer | Pointer to mesh buffer. |
| u32 Skylicht::CShaderManager::BoneCount |
Number of bones for skinning
| f32* Skylicht::CShaderManager::BoneMatrix |
Pointer to bone matrix array for skinning
| float Skylicht::CShaderManager::LightmapIndex |
Current lightmap index
| std::function<IShaderInstancing* (const char*)> Skylicht::CShaderManager::OnCreateInstancingVertex |
Callback for custom instancing implementation See documentation page : Shader information structure
| core::vector2df Skylicht::CShaderManager::ShaderVec2[10] |
Array for vec2 uniforms(max 10)
| core::vector3df Skylicht::CShaderManager::ShaderVec3[10] |
Array for vec3 uniforms(max 10)
| video::SVec4 Skylicht::CShaderManager::ShaderVec4[10] |
Array for vec4 uniforms(max 10)