|
Monad Engine da02fba2
> Undercity Codex_
|
Shader + uniform storage that defines how a surface is rendered. More...
#include <Material.h>
Public Member Functions | |
| void | SetShaderProgram (const std::shared_ptr< ShaderProgram > &shaderProgram) |
| Assign the GLSL program this material will use when drawn. | |
| void | Bind () |
| Upload all stored parameters to the active ShaderProgram. | |
| ShaderProgram * | GetShaderProgram () |
| Returns the shader program assigned to this material. | |
Uniform Parameter Setters | |
Store a named uniform value. Uploaded to the GPU in Bind(). | |
| void | SetParam (const std::string &name, float value) |
| Set a float uniform. | |
| void | SetParam (const std::string &name, float v0, float v1) |
| Set a vec2 uniform. | |
| void | SetParam (const std::string &name, const vec3 &value) |
| Set a vec3 uniform. | |
| void | SetParam (const std::string &name, const vec4 &value) |
| Set a vec4 uniform. | |
| void | SetParam (const std::string &name, const std::shared_ptr< Texture > &texture) |
| Set a sampler2D uniform. | |
| void | SetParam (const std::string &name, const std::vector< glm::mat4 > &matrices) |
| Set a mat4[] uniform (e.g. bone palette). | |
Static Public Member Functions | |
| static std::shared_ptr< Material > | Load (const str &path) |
| Load a material from a descriptor file. | |
Shader + uniform storage that defines how a surface is rendered.
Parameters are stored in typed maps and uploaded to the GPU lazily during Material::Bind(). Between frames, SetParam() calls simply overwrite the stored values without touching the GPU.
Definition at line 53 of file Material.h.
| void mnd::Material::Bind | ( | ) |
Upload all stored parameters to the active ShaderProgram.
Called automatically by RenderQueue::Draw() before each draw call. Binds textures to consecutive texture units starting from 0.
Definition at line 176 of file Material.cpp.
References LOG_WARN.
| ShaderProgram * mnd::Material::GetShaderProgram | ( | ) |
Returns the shader program assigned to this material.
Definition at line 14 of file Material.cpp.
Load a material from a descriptor file.
| path | Path to the material asset file. |
Definition at line 54 of file Material.cpp.
References mnd::GraphicsAPI::CreateShaderProgram(), mnd::Engine::GetFileSystem(), mnd::Engine::GetGraphicsAPI(), mnd::Engine::GetInstance(), mnd::Texture::Load(), mnd::FileSystem::LoadAssetFileText(), and LOG_ERROR.
Referenced by mnd::MeshComponent::LoadProperties().
| void mnd::Material::SetParam | ( | const std::string & | name, |
| const std::shared_ptr< Texture > & | texture | ||
| ) |
Set a sampler2D uniform.
Definition at line 44 of file Material.cpp.
| void mnd::Material::SetParam | ( | const std::string & | name, |
| const std::vector< glm::mat4 > & | matrices | ||
| ) |
Set a mat4[] uniform (e.g. bone palette).
Definition at line 49 of file Material.cpp.
| void mnd::Material::SetParam | ( | const std::string & | name, |
| const vec3 & | value | ||
| ) |
Set a vec3 uniform.
Definition at line 34 of file Material.cpp.
| void mnd::Material::SetParam | ( | const std::string & | name, |
| const vec4 & | value | ||
| ) |
Set a vec4 uniform.
Definition at line 39 of file Material.cpp.
| void mnd::Material::SetParam | ( | const std::string & | name, |
| float | v0, | ||
| float | v1 | ||
| ) |
Set a vec2 uniform.
Definition at line 29 of file Material.cpp.
| void mnd::Material::SetParam | ( | const std::string & | name, |
| float | value | ||
| ) |
Set a float uniform.
Definition at line 24 of file Material.cpp.
| void mnd::Material::SetShaderProgram | ( | const std::shared_ptr< ShaderProgram > & | shaderProgram | ) |
Assign the GLSL program this material will use when drawn.
| shaderProgram | Compiled shader; falls back to the default if unset. |
Definition at line 19 of file Material.cpp.