|
SleakEngine 0.1.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 RefPtr< Texture > &texture) |
| 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 RefPtr< Texture > &texture) |
| 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 RefPtr< Texture > &texture) |
| void | SetEmissiveTexture (const std::string &path) |
| void | SetEmissiveTexture (Texture *texture) |
| void | SetMetallic (float metallic) |
| void | SetMetallicTexture (const RefPtr< Texture > &texture) |
| void | SetMetallicTexture (const std::string &path) |
| void | SetMetallicTexture (Texture *texture) |
| void | SetNormalIntensity (float intensity) |
| void | SetNormalTexture (const RefPtr< Texture > &texture) |
| 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 RefPtr< Texture > &texture) |
| 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 RefPtr< Texture > &texture) |
| 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 |
| std::string | GetDebugName () const |
| Name plus unique ID, for logs where names can repeat. | |
| 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. Textures are held by RefPtr too. Each texture setter takes a RefPtr<Texture> to share one texture between materials, a raw Texture* the material adopts (do not hand the same raw pointer to two materials), or 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 90 of file Material.hpp.
| Sleak::Material::Material | ( | ) |
Definition at line 14 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 31 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 114 of file Material.cpp.
| float Sleak::Material::GetAlphaCutoff | ( | ) | const |
Definition at line 386 of file Material.cpp.
| float Sleak::Material::GetAO | ( | ) | const |
Definition at line 362 of file Material.cpp.
| Texture * Sleak::Material::GetAOTexture | ( | ) | const |
Definition at line 264 of file Material.cpp.
| Math::Color Sleak::Material::GetDiffuseColor | ( | ) | const |
Definition at line 308 of file Material.cpp.
| Texture * Sleak::Material::GetDiffuseTexture | ( | ) | const |
Definition at line 159 of file Material.cpp.
| Math::Color Sleak::Material::GetEmissiveColor | ( | ) | const |
Definition at line 338 of file Material.cpp.
| float Sleak::Material::GetEmissiveIntensity | ( | ) | const |
Definition at line 374 of file Material.cpp.
| Texture * Sleak::Material::GetEmissiveTexture | ( | ) | const |
Definition at line 283 of file Material.cpp.
| float Sleak::Material::GetMetallic | ( | ) | const |
Definition at line 352 of file Material.cpp.
| Texture * Sleak::Material::GetMetallicTexture | ( | ) | const |
Definition at line 243 of file Material.cpp.
| float Sleak::Material::GetNormalIntensity | ( | ) | const |
Definition at line 368 of file Material.cpp.
| Texture * Sleak::Material::GetNormalTexture | ( | ) | const |
Definition at line 180 of file Material.cpp.
| Math::Vector2D Sleak::Material::GetOffset | ( | ) | const |
Definition at line 412 of file Material.cpp.
| float Sleak::Material::GetOpacity | ( | ) | const |
Definition at line 380 of file Material.cpp.
| MaterialRenderMode Sleak::Material::GetRenderMode | ( | ) | const |
Definition at line 420 of file Material.cpp.
| float Sleak::Material::GetRoughness | ( | ) | const |
Definition at line 358 of file Material.cpp.
| Texture * Sleak::Material::GetRoughnessTexture | ( | ) | const |
Definition at line 222 of file Material.cpp.
| RenderEngine::Shader * Sleak::Material::GetShader | ( | ) | const |
Definition at line 142 of file Material.cpp.
| float Sleak::Material::GetShininess | ( | ) | const |
Definition at line 346 of file Material.cpp.
| Math::Color Sleak::Material::GetSpecularColor | ( | ) | const |
Definition at line 319 of file Material.cpp.
| Texture * Sleak::Material::GetSpecularTexture | ( | ) | const |
Definition at line 201 of file Material.cpp.
| Math::Vector2D Sleak::Material::GetTiling | ( | ) | const |
Definition at line 398 of file Material.cpp.
| bool Sleak::Material::HasAOTexture | ( | ) | const |
Definition at line 266 of file Material.cpp.
| bool Sleak::Material::HasDiffuseTexture | ( | ) | const |
Definition at line 163 of file Material.cpp.
| bool Sleak::Material::HasEmissiveTexture | ( | ) | const |
Definition at line 287 of file Material.cpp.
| bool Sleak::Material::HasMetallicTexture | ( | ) | const |
Definition at line 247 of file Material.cpp.
| bool Sleak::Material::HasNormalTexture | ( | ) | const |
Definition at line 184 of file Material.cpp.
| bool Sleak::Material::HasRoughnessTexture | ( | ) | const |
Definition at line 226 of file Material.cpp.
| bool Sleak::Material::HasSpecularTexture | ( | ) | const |
Definition at line 205 of file Material.cpp.
| void Sleak::Material::Initialize | ( | ) |
Lazily allocates the material's constant buffer on first use.
Definition at line 19 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 108 of file Material.cpp.
| bool Sleak::Material::IsTwoSided | ( | ) | const |
Definition at line 428 of file Material.cpp.
| void Sleak::Material::SetAlphaCutoff | ( | float | cutoff | ) |
Definition at line 382 of file Material.cpp.
| void Sleak::Material::SetAO | ( | float | ao | ) |
Definition at line 360 of file Material.cpp.
Definition at line 251 of file Material.cpp.
| void Sleak::Material::SetAOTexture | ( | const std::string & | path | ) |
Definition at line 259 of file Material.cpp.
| void Sleak::Material::SetAOTexture | ( | Texture * | texture | ) |
Definition at line 255 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0f ) |
Definition at line 300 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | Math::Color | color | ) |
Definition at line 291 of file Material.cpp.
| void Sleak::Material::SetDiffuseColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| uint8_t | a = 255 ) |
Definition at line 295 of file Material.cpp.
Definition at line 146 of file Material.cpp.
| void Sleak::Material::SetDiffuseTexture | ( | const std::string & | path | ) |
Definition at line 154 of file Material.cpp.
| void Sleak::Material::SetDiffuseTexture | ( | Texture * | texture | ) |
Definition at line 150 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | float | r, |
| float | g, | ||
| float | b ) |
Definition at line 331 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | Math::Color | color | ) |
Definition at line 323 of file Material.cpp.
| void Sleak::Material::SetEmissiveColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b ) |
Definition at line 327 of file Material.cpp.
| void Sleak::Material::SetEmissiveIntensity | ( | float | intensity | ) |
Definition at line 370 of file Material.cpp.
Definition at line 270 of file Material.cpp.
| void Sleak::Material::SetEmissiveTexture | ( | const std::string & | path | ) |
Definition at line 278 of file Material.cpp.
| void Sleak::Material::SetEmissiveTexture | ( | Texture * | texture | ) |
Definition at line 274 of file Material.cpp.
| void Sleak::Material::SetMetallic | ( | float | metallic | ) |
Definition at line 348 of file Material.cpp.
Definition at line 230 of file Material.cpp.
| void Sleak::Material::SetMetallicTexture | ( | const std::string & | path | ) |
Definition at line 238 of file Material.cpp.
| void Sleak::Material::SetMetallicTexture | ( | Texture * | texture | ) |
Definition at line 234 of file Material.cpp.
| void Sleak::Material::SetNormalIntensity | ( | float | intensity | ) |
Definition at line 364 of file Material.cpp.
Definition at line 167 of file Material.cpp.
| void Sleak::Material::SetNormalTexture | ( | const std::string & | path | ) |
Definition at line 175 of file Material.cpp.
| void Sleak::Material::SetNormalTexture | ( | Texture * | texture | ) |
Definition at line 171 of file Material.cpp.
| void Sleak::Material::SetOffset | ( | float | x, |
| float | y ) |
Definition at line 402 of file Material.cpp.
| void Sleak::Material::SetOffset | ( | Math::Vector2D | offset | ) |
Definition at line 407 of file Material.cpp.
| void Sleak::Material::SetOpacity | ( | float | opacity | ) |
Definition at line 378 of file Material.cpp.
| void Sleak::Material::SetRenderMode | ( | MaterialRenderMode | mode | ) |
Definition at line 416 of file Material.cpp.
| void Sleak::Material::SetRoughness | ( | float | roughness | ) |
Definition at line 354 of file Material.cpp.
Definition at line 209 of file Material.cpp.
| void Sleak::Material::SetRoughnessTexture | ( | const std::string & | path | ) |
Definition at line 217 of file Material.cpp.
| void Sleak::Material::SetRoughnessTexture | ( | Texture * | texture | ) |
Definition at line 213 of file Material.cpp.
| void Sleak::Material::SetShader | ( | const std::string & | shaderPath | ) |
Definition at line 135 of file Material.cpp.
| void Sleak::Material::SetShader | ( | RenderEngine::Shader * | shader | ) |
Definition at line 131 of file Material.cpp.
| void Sleak::Material::SetShininess | ( | float | shininess | ) |
Definition at line 342 of file Material.cpp.
| void Sleak::Material::SetSpecularColor | ( | Math::Color | color | ) |
Definition at line 310 of file Material.cpp.
| void Sleak::Material::SetSpecularColor | ( | uint8_t | r, |
| uint8_t | g, | ||
| uint8_t | b, | ||
| uint8_t | a = 255 ) |
Definition at line 314 of file Material.cpp.
Definition at line 188 of file Material.cpp.
| void Sleak::Material::SetSpecularTexture | ( | const std::string & | path | ) |
Definition at line 196 of file Material.cpp.
| void Sleak::Material::SetSpecularTexture | ( | Texture * | texture | ) |
Definition at line 192 of file Material.cpp.
| void Sleak::Material::SetTiling | ( | float | x, |
| float | y ) |
Definition at line 388 of file Material.cpp.
| void Sleak::Material::SetTiling | ( | Math::Vector2D | tiling | ) |
Definition at line 393 of file Material.cpp.
| void Sleak::Material::SetTwoSided | ( | bool | twoSided | ) |
Definition at line 424 of file Material.cpp.