|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <Material.hpp>
Public Member Functions | |
| Material () | |
| ~Material () override | |
| void | Bind () |
| Binds shader, all set textures, and uploads the packed material CB for a forward draw. | |
| void | BindTexturesAndCB () |
| Binds textures and uploads the material CB for the deferred geometry pass, skipping the shader bind. | |
| float | GetAlphaCutoff () const |
| float | GetAO () const |
| Texture * | GetAOTexture () const |
| Math::Color | GetDiffuseColor () const |
| Texture * | GetDiffuseTexture () const |
| Math::Color | GetEmissiveColor () const |
| float | GetEmissiveIntensity () const |
| Texture * | GetEmissiveTexture () const |
| float | GetMetallic () const |
| Texture * | GetMetallicTexture () const |
| float | GetNormalIntensity () const |
| Texture * | GetNormalTexture () const |
| Math::Vector2D | GetOffset () const |
| float | GetOpacity () const |
| MaterialRenderMode | GetRenderMode () const |
| float | GetRoughness () const |
| Texture * | GetRoughnessTexture () const |
| RenderEngine::Shader * | GetShader () const |
| float | GetShininess () const |
| Math::Color | GetSpecularColor () const |
| Texture * | GetSpecularTexture () const |
| Math::Vector2D | GetTiling () const |
| bool | HasAOTexture () const |
| bool | HasDiffuseTexture () const |
| bool | HasEmissiveTexture () const |
| bool | HasMetallicTexture () const |
| bool | HasNormalTexture () const |
| bool | HasRoughnessTexture () const |
| bool | HasSpecularTexture () const |
| void | Initialize () |
| Lazily allocates the material's constant buffer on first use. | |
| bool | IsForwardRendered () const |
| True when this material must skip the GBuffer and render in the forward transparent pass. | |
| bool | IsTwoSided () const |
| void | SetAlphaCutoff (float cutoff) |
| void | SetAO (float ao) |
| void | SetAOTexture (const std::string &path) |
| void | SetAOTexture (Texture *texture) |
| void | SetDiffuseColor (float r, float g, float b, float a=1.0f) |
| void | SetDiffuseColor (Math::Color color) |
| void | SetDiffuseColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
| void | SetDiffuseTexture (const std::string &path) |
| void | SetDiffuseTexture (Texture *texture) |
| void | SetEmissiveColor (float r, float g, float b) |
| void | SetEmissiveColor (Math::Color color) |
| void | SetEmissiveColor (uint8_t r, uint8_t g, uint8_t b) |
| void | SetEmissiveIntensity (float intensity) |
| void | SetEmissiveTexture (const std::string &path) |
| void | SetEmissiveTexture (Texture *texture) |
| void | SetMetallic (float metallic) |
| void | SetMetallicTexture (const std::string &path) |
| void | SetMetallicTexture (Texture *texture) |
| void | SetNormalIntensity (float intensity) |
| void | SetNormalTexture (const std::string &path) |
| void | SetNormalTexture (Texture *texture) |
| void | SetOffset (float x, float y) |
| void | SetOffset (Math::Vector2D offset) |
| void | SetOpacity (float opacity) |
| void | SetRenderMode (MaterialRenderMode mode) |
| void | SetRoughness (float roughness) |
| void | SetRoughnessTexture (const std::string &path) |
| void | SetRoughnessTexture (Texture *texture) |
| void | SetShader (const std::string &shaderPath) |
| void | SetShader (RenderEngine::Shader *shader) |
| void | SetShininess (float shininess) |
| void | SetSpecularColor (Math::Color color) |
| void | SetSpecularColor (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
| void | SetSpecularTexture (const std::string &path) |
| void | SetSpecularTexture (Texture *texture) |
| void | SetTiling (float x, float y) |
| void | SetTiling (Math::Vector2D tiling) |
| void | SetTwoSided (bool twoSided) |
| Public Member Functions inherited from Sleak::Object | |
| Object (const std::string &name="Object") | |
| virtual | ~Object ()=default |
| const std::string & | GetName () const |
| uint64_t | GetUniqueID () const |
| void | SetName (const std::string &value) |
PBR-ish surface properties, textures, and GPU buffer for a drawable; shared across any mesh that references it.
A Material describes how a surface responds to light: a base color, metallic, roughness, ambient occlusion, emissive, and opacity, plus up to seven texture maps that override those scalars per texel. It owns its own GPU constant buffer and rebuilds it when properties change.
Materials are meant to be shared. Wrap one in a RefPtr and hand the same RefPtr to every MaterialComponent that should use it; changing a property updates every object drawn with it. Each texture setter comes in two forms, one taking an owned Texture* and one taking a file path the material loads for you.
SetRenderMode() decides how transparency is handled: MaterialRenderMode::Opaque and ::Cutout render in the normal (deferred, where the backend supports it) path, while ::Transparent forces the material into a forward pass. IsForwardRendered() reports which side a material falls on.
Definition at line 87 of file Material.hpp.
| Sleak::Material::Material | ( | ) |
Definition at line 8 of file Material.cpp.
|
overridedefault |
| void Sleak::Material::Bind | ( | ) |
Binds shader, all set textures, and uploads the packed material CB for a forward draw.
Definition at line 25 of file Material.cpp.
| void Sleak::Material::BindTexturesAndCB | ( | ) |
Binds textures and uploads the material CB for the deferred geometry pass, skipping the shader bind.
Bind only textures and material CB (skips shader bind). Used by the deferred geometry pass which overrides the shader.
Definition at line 108 of file Material.cpp.
| float Sleak::Material::GetAlphaCutoff | ( | ) | const |
Definition at line 363 of file Material.cpp.
| float Sleak::Material::GetAO | ( | ) | const |
Definition at line 339 of file Material.cpp.
| Texture * Sleak::Material::GetAOTexture | ( | ) | const |
Definition at line 241 of file Material.cpp.
| Math::Color Sleak::Material::GetDiffuseColor | ( | ) | const |
Definition at line 285 of file Material.cpp.
| Texture * Sleak::Material::GetDiffuseTexture | ( | ) | const |
Definition at line 149 of file Material.cpp.
| Math::Color Sleak::Material::GetEmissiveColor | ( | ) | const |
Definition at line 315 of file Material.cpp.
| float Sleak::Material::GetEmissiveIntensity | ( | ) | const |
Definition at line 351 of file Material.cpp.
| Texture * Sleak::Material::GetEmissiveTexture | ( | ) | const |
Definition at line 258 of file Material.cpp.
| float Sleak::Material::GetMetallic | ( | ) | const |
Definition at line 329 of file Material.cpp.
| Texture * Sleak::Material::GetMetallicTexture | ( | ) | const |
Definition at line 222 of file Material.cpp.
| float Sleak::Material::GetNormalIntensity | ( | ) | const |
Definition at line 345 of file Material.cpp.
| Texture * Sleak::Material::GetNormalTexture | ( | ) | const |
Definition at line 167 of file Material.cpp.
| Math::Vector2D Sleak::Material::GetOffset | ( | ) | const |
Definition at line 389 of file Material.cpp.
| float Sleak::Material::GetOpacity | ( | ) | const |
Definition at line 357 of file Material.cpp.
| MaterialRenderMode Sleak::Material::GetRenderMode | ( | ) | const |
Definition at line 397 of file Material.cpp.
| float Sleak::Material::GetRoughness | ( | ) | const |
Definition at line 335 of file Material.cpp.
| Texture * Sleak::Material::GetRoughnessTexture | ( | ) | const |
Definition at line 203 of file Material.cpp.
| RenderEngine::Shader * Sleak::Material::GetShader | ( | ) | const |
Definition at line 136 of file Material.cpp.
| float Sleak::Material::GetShininess | ( | ) | const |
Definition at line 323 of file Material.cpp.
| Math::Color Sleak::Material::GetSpecularColor | ( | ) | const |
Definition at line 296 of file Material.cpp.
| Texture * Sleak::Material::GetSpecularTexture | ( | ) | const |
Definition at line 185 of file Material.cpp.
| Math::Vector2D Sleak::Material::GetTiling | ( | ) | const |
Definition at line 375 of file Material.cpp.
| bool Sleak::Material::HasAOTexture | ( | ) | const |
Definition at line 245 of file Material.cpp.
| bool Sleak::Material::HasDiffuseTexture | ( | ) | const |
Definition at line 154 of file Material.cpp.
| bool Sleak::Material::HasEmissiveTexture | ( | ) | const |
Definition at line 264 of file Material.cpp.
| bool Sleak::Material::HasMetallicTexture | ( | ) | const |
Definition at line 228 of file Material.cpp.
| bool Sleak::Material::HasNormalTexture | ( | ) | const |
Definition at line 172 of file Material.cpp.
| bool Sleak::Material::HasRoughnessTexture | ( | ) | const |
Definition at line 209 of file Material.cpp.
| bool Sleak::Material::HasSpecularTexture | ( | ) | const |
Definition at line 190 of file Material.cpp.
| void Sleak::Material::Initialize | ( | ) |
Lazily allocates the material's constant buffer on first use.
Definition at line 13 of file Material.cpp.
| bool Sleak::Material::IsForwardRendered | ( | ) | const |
True when this material must skip the GBuffer and render in the forward transparent pass.
True if this material must be rendered in a forward pass (transparent, alpha-blended). Opaque and cutout materials return false.
Definition at line 102 of file Material.cpp.
| bool Sleak::Material::IsTwoSided | ( | ) | const |
Definition at line 405 of file Material.cpp.
| void Sleak::Material::SetAlphaCutoff | ( | float | cutoff | ) |
Definition at line 359 of file Material.cpp.
| void Sleak::Material::SetAO | ( | float | ao | ) |
Definition at line 337 of file Material.cpp.
| void Sleak::Material::SetAOTexture | ( | const std::string & | path | ) |
Definition at line 236 of file Material.cpp.
| void Sleak::Material::SetAOTexture | ( | Texture * | texture | ) |
Definition at line 232 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0f ) |
Definition at line 277 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | Math::Color | color | ) |
Definition at line 268 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| uint8_t | a = 255 ) |
Definition at line 272 of file Material.cpp.
| void Sleak::Material::SetDiffuseTexture | ( | const std::string & | path | ) |
Definition at line 144 of file Material.cpp.
| void Sleak::Material::SetDiffuseTexture | ( | Texture * | texture | ) |
Definition at line 140 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | float | r, |
| float | g, | ||
| float | b ) |
Definition at line 308 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | Math::Color | color | ) |
Definition at line 300 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Definition at line 304 of file Material.cpp.
| void Sleak::Material::SetEmissiveIntensity | ( | float | intensity | ) |
Definition at line 347 of file Material.cpp.
| void Sleak::Material::SetEmissiveTexture | ( | const std::string & | path | ) |
Definition at line 253 of file Material.cpp.
| void Sleak::Material::SetEmissiveTexture | ( | Texture * | texture | ) |
Definition at line 249 of file Material.cpp.
| void Sleak::Material::SetMetallic | ( | float | metallic | ) |
Definition at line 325 of file Material.cpp.
| void Sleak::Material::SetMetallicTexture | ( | const std::string & | path | ) |
Definition at line 217 of file Material.cpp.
| void Sleak::Material::SetMetallicTexture | ( | Texture * | texture | ) |
Definition at line 213 of file Material.cpp.
| void Sleak::Material::SetNormalIntensity | ( | float | intensity | ) |
Definition at line 341 of file Material.cpp.
| void Sleak::Material::SetNormalTexture | ( | const std::string & | path | ) |
Definition at line 162 of file Material.cpp.
| void Sleak::Material::SetNormalTexture | ( | Texture * | texture | ) |
Definition at line 158 of file Material.cpp.
| void Sleak::Material::SetOffset | ( | float | x, |
| float | y ) |
Definition at line 379 of file Material.cpp.
| void Sleak::Material::SetOffset | ( | Math::Vector2D | offset | ) |
Definition at line 384 of file Material.cpp.
| void Sleak::Material::SetOpacity | ( | float | opacity | ) |
Definition at line 355 of file Material.cpp.
| void Sleak::Material::SetRenderMode | ( | MaterialRenderMode | mode | ) |
Definition at line 393 of file Material.cpp.
| void Sleak::Material::SetRoughness | ( | float | roughness | ) |
Definition at line 331 of file Material.cpp.
| void Sleak::Material::SetRoughnessTexture | ( | const std::string & | path | ) |
Definition at line 198 of file Material.cpp.
| void Sleak::Material::SetRoughnessTexture | ( | Texture * | texture | ) |
Definition at line 194 of file Material.cpp.
| void Sleak::Material::SetShader | ( | const std::string & | shaderPath | ) |
Definition at line 129 of file Material.cpp.
| void Sleak::Material::SetShader | ( | RenderEngine::Shader * | shader | ) |
Definition at line 125 of file Material.cpp.
| void Sleak::Material::SetShininess | ( | float | shininess | ) |
Definition at line 319 of file Material.cpp.
| void Sleak::Material::SetSpecularColor | ( | Math::Color | color | ) |
Definition at line 287 of file Material.cpp.
| void Sleak::Material::SetSpecularColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| uint8_t | a = 255 ) |
Definition at line 291 of file Material.cpp.
| void Sleak::Material::SetSpecularTexture | ( | const std::string & | path | ) |
Definition at line 180 of file Material.cpp.
| void Sleak::Material::SetSpecularTexture | ( | Texture * | texture | ) |
Definition at line 176 of file Material.cpp.
| void Sleak::Material::SetTiling | ( | float | x, |
| float | y ) |
Definition at line 365 of file Material.cpp.
| void Sleak::Material::SetTiling | ( | Math::Vector2D | tiling | ) |
Definition at line 370 of file Material.cpp.
| void Sleak::Material::SetTwoSided | ( | bool | twoSided | ) |
Definition at line 401 of file Material.cpp.