Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::MaterialData Struct Reference

CPU-side material description consumed by renderer material upload code. More...

#include <MaterialData.h>

Public Member Functions

 MaterialData ()=default
 Creates a material with default values and the normals debug pipeline.
 MaterialData (Rendering::PipelineNames pipe)
 Creates a material for a specific pipeline.
 MaterialData (Rendering::PipelineNames pipe, uint32_t baseColorTexIdx, const glm::vec4 &baseColorFac)
 Creates a material with a pipeline, base-color texture, and base-color factor.
bool hasBaseColorTexture () const
 Checks whether a base-color texture descriptor index is present.
bool hasNormalTexture () const
 Checks whether a normal texture descriptor index is present.
bool hasMetallicRoughnessTexture () const
 Checks whether a metallic-roughness texture descriptor index is present.
bool hasEmissiveTexture () const
 Checks whether an emissive texture descriptor index is present.
bool hasLightmapTexture () const
 Checks whether a lightmap texture descriptor index is present.
bool isAlphaMasked () const
 Checks whether the material is configured for alpha masking.
MaterialData & withBaseColorTexture (uint32_t idx)
 Sets the base-color texture descriptor index.
MaterialData & withNormalTexture (uint32_t idx)
 Sets the normal texture descriptor index.
MaterialData & withMetallicRoughnessTexture (uint32_t idx)
 Sets the metallic-roughness texture descriptor index.
MaterialData & withEmissiveTexture (uint32_t idx)
 Sets the emissive texture descriptor index.
MaterialData & withLightmapTexture (uint32_t idx)
 Sets the lightmap texture descriptor index.
MaterialData & withBaseColorFactor (const glm::vec4 &fac)
 Sets the linear RGBA base-color multiplier.
MaterialData & withEmissiveFactor (const glm::vec3 &fac)
 Sets the linear RGB emissive multiplier.
MaterialData & withRoughness (float r)
 Sets the scalar roughness value.
MaterialData & withMetallic (float m)
 Sets the scalar metallic value.
MaterialData & withNormalScale (float s)
 Sets the normal map scale.
MaterialData & withShScale (float s)
 Sets the spherical harmonics lighting multiplier.
MaterialData & withAmbientTerm (float a)
 Sets the ambient lighting term.
MaterialData & withDebugMode (uint32_t d)
 Sets the material debug mode selector.
MaterialData & withToneMapping (uint32_t t)
 Sets the material tone-mapping mode.
MaterialData & withAlphaCutoff (float cutoff)
 Sets the alpha-mask cutoff threshold.
MaterialData & withNormalMapBC5 (bool bc5)
 Selects BC5/RG normal map decoding.

Public Attributes

Rendering::PipelineNames pipeline = Rendering::PipelineNames::NORMALS_SHADER
 Graphics pipeline used to interpret this material.
uint32_t baseColorTextureIndex = 0xFFFFFFFF
 Base-color texture descriptor index, or 0xFFFFFFFF when absent.
uint32_t normalTextureIndex = 0xFFFFFFFF
 Normal texture descriptor index, or 0xFFFFFFFF when absent.
uint32_t roughnessMetallicTextureIndex = 0xFFFFFFFF
 Metallic-roughness texture descriptor index, or 0xFFFFFFFF when absent.
uint32_t emissiveTextureIndex = 0xFFFFFFFF
 Emissive texture descriptor index, or 0xFFFFFFFF when absent.
uint32_t lightmapTextureIndex = 0xFFFFFFFF
 Lightmap texture descriptor index, or 0xFFFFFFFF when absent.
glm::vec4 baseColorFactor = glm::vec4(1.0f)
 Linear RGBA base-color multiplier.
glm::vec3 emissiveFactor = glm::vec3(0.0f)
float roughnessFactor = 1.0f
 Scalar roughness used when no metallic-roughness texture is present.
float metallicFactor = 0.0f
 Scalar metallic value used when no metallic-roughness texture is present.
float normalScale = 1.0f
 Scale applied to sampled tangent-space normals.
float shScale = 1.0f
 Spherical harmonics lighting multiplier.
float ambientTerm = 0.0f
 Ambient lighting term mixed with probe or spherical harmonics lighting.
uint32_t debugMode = 0
 Material debug mode selector.
uint32_t toneMapping = 1
 Material tone-mapping mode: 0=None, 1=Reinhard, 2=ACES.
bool normalMapBC5 = false
 True when the normal map stores X and Y in BC5/RG format and reconstructs Z.
float alphaCutoff = 1.0f
 Alpha-mask discard threshold. Values below 1.0f mark the material as masked.

Detailed Description

CPU-side material description consumed by renderer material upload code.

MaterialData stores the pipeline selector, texture descriptor indices, scalar factors, and shader options for one material component. Texture index fields use 0xFFFFFFFF when the texture is absent. When stored on Engine::Assets::Material, texture handles and paths are resolved before these direct descriptor indices are used as fallback values.

The fluent with*() functions mutate the struct and return *this. They do not change the selected pipeline.

Definition at line 22 of file MaterialData.h.

Constructor & Destructor Documentation

◆ MaterialData() [1/3]

Engine::Core::MaterialData::MaterialData ( )
default

Creates a material with default values and the normals debug pipeline.

Referenced by withAlphaCutoff(), withAmbientTerm(), withBaseColorFactor(), withBaseColorTexture(), withDebugMode(), withEmissiveFactor(), withEmissiveTexture(), withLightmapTexture(), withMetallic(), withMetallicRoughnessTexture(), withNormalMapBC5(), withNormalScale(), withNormalTexture(), withRoughness(), withShScale(), and withToneMapping().

Here is the caller graph for this function:

◆ MaterialData() [2/3]

Engine::Core::MaterialData::MaterialData ( Rendering::PipelineNames pipe)
inlineexplicit

Creates a material for a specific pipeline.

Parameters
pipePipeline used to render the material.

Definition at line 67 of file MaterialData.h.

References pipeline.

◆ MaterialData() [3/3]

Engine::Core::MaterialData::MaterialData ( Rendering::PipelineNames pipe,
uint32_t baseColorTexIdx,
const glm::vec4 & baseColorFac )
inline

Creates a material with a pipeline, base-color texture, and base-color factor.

Parameters
pipePipeline used to render the material.
baseColorTexIdxBase-color texture descriptor index, or 0xFFFFFFFF when absent.
baseColorFacLinear RGBA base-color multiplier.

Definition at line 76 of file MaterialData.h.

References baseColorFactor, baseColorTextureIndex, and pipeline.

Member Function Documentation

◆ hasBaseColorTexture()

bool Engine::Core::MaterialData::hasBaseColorTexture ( ) const
inlinenodiscard

Checks whether a base-color texture descriptor index is present.

Returns
True when MaterialData::baseColorTextureIndex is not 0xFFFFFFFF.

Definition at line 85 of file MaterialData.h.

References baseColorTextureIndex.

◆ hasEmissiveTexture()

bool Engine::Core::MaterialData::hasEmissiveTexture ( ) const
inlinenodiscard

Checks whether an emissive texture descriptor index is present.

Returns
True when MaterialData::emissiveTextureIndex is not 0xFFFFFFFF.

Definition at line 103 of file MaterialData.h.

References emissiveTextureIndex.

◆ hasLightmapTexture()

bool Engine::Core::MaterialData::hasLightmapTexture ( ) const
inlinenodiscard

Checks whether a lightmap texture descriptor index is present.

Returns
True when MaterialData::lightmapTextureIndex is not 0xFFFFFFFF.

Definition at line 109 of file MaterialData.h.

References lightmapTextureIndex.

◆ hasMetallicRoughnessTexture()

bool Engine::Core::MaterialData::hasMetallicRoughnessTexture ( ) const
inlinenodiscard

Checks whether a metallic-roughness texture descriptor index is present.

Returns
True when MaterialData::roughnessMetallicTextureIndex is not 0xFFFFFFFF.

Definition at line 97 of file MaterialData.h.

References roughnessMetallicTextureIndex.

◆ hasNormalTexture()

bool Engine::Core::MaterialData::hasNormalTexture ( ) const
inlinenodiscard

Checks whether a normal texture descriptor index is present.

Returns
True when MaterialData::normalTextureIndex is not 0xFFFFFFFF.

Definition at line 91 of file MaterialData.h.

References normalTextureIndex.

◆ isAlphaMasked()

bool Engine::Core::MaterialData::isAlphaMasked ( ) const
inlinenodiscard

Checks whether the material is configured for alpha masking.

Returns
True when MaterialData::alphaCutoff is less than 1.0f.

Definition at line 115 of file MaterialData.h.

References alphaCutoff.

◆ withAlphaCutoff()

MaterialData & Engine::Core::MaterialData::withAlphaCutoff ( float cutoff)
inline

Sets the alpha-mask cutoff threshold.

Parameters
cutoffFragment alpha threshold used by alpha-mask pipelines.
Returns
Reference to this material for chaining.

This function does not switch MaterialData::pipeline to an alpha-mask pipeline.

Definition at line 223 of file MaterialData.h.

References alphaCutoff, and MaterialData().

Here is the call graph for this function:

◆ withAmbientTerm()

MaterialData & Engine::Core::MaterialData::withAmbientTerm ( float a)
inline

Sets the ambient lighting term.

Parameters
aAmbient term mixed with probe or spherical harmonics lighting.
Returns
Reference to this material for chaining.

Definition at line 199 of file MaterialData.h.

References ambientTerm, and MaterialData().

Here is the call graph for this function:

◆ withBaseColorFactor()

MaterialData & Engine::Core::MaterialData::withBaseColorFactor ( const glm::vec4 & fac)
inline

Sets the linear RGBA base-color multiplier.

Parameters
facBase-color factor.
Returns
Reference to this material for chaining.

Definition at line 157 of file MaterialData.h.

References baseColorFactor, and MaterialData().

Here is the call graph for this function:

◆ withBaseColorTexture()

MaterialData & Engine::Core::MaterialData::withBaseColorTexture ( uint32_t idx)
inline

Sets the base-color texture descriptor index.

Parameters
idxTexture descriptor index, or 0xFFFFFFFF to mark the texture absent.
Returns
Reference to this material for chaining.

Definition at line 122 of file MaterialData.h.

References baseColorTextureIndex, and MaterialData().

Here is the call graph for this function:

◆ withDebugMode()

MaterialData & Engine::Core::MaterialData::withDebugMode ( uint32_t d)
inline

Sets the material debug mode selector.

Parameters
dDebug mode value consumed by material shaders that read material-level debug state.
Returns
Reference to this material for chaining.

Definition at line 206 of file MaterialData.h.

References debugMode, and MaterialData().

Here is the call graph for this function:

◆ withEmissiveFactor()

MaterialData & Engine::Core::MaterialData::withEmissiveFactor ( const glm::vec3 & fac)
inline

Sets the linear RGB emissive multiplier.

Parameters
facEmissive factor.
Returns
Reference to this material for chaining.

Definition at line 164 of file MaterialData.h.

References emissiveFactor, and MaterialData().

Here is the call graph for this function:

◆ withEmissiveTexture()

MaterialData & Engine::Core::MaterialData::withEmissiveTexture ( uint32_t idx)
inline

Sets the emissive texture descriptor index.

Parameters
idxTexture descriptor index, or 0xFFFFFFFF to mark the texture absent.
Returns
Reference to this material for chaining.

Definition at line 143 of file MaterialData.h.

References emissiveTextureIndex, and MaterialData().

Here is the call graph for this function:

◆ withLightmapTexture()

MaterialData & Engine::Core::MaterialData::withLightmapTexture ( uint32_t idx)
inline

Sets the lightmap texture descriptor index.

Parameters
idxTexture descriptor index, or 0xFFFFFFFF to mark the texture absent.
Returns
Reference to this material for chaining.

Definition at line 150 of file MaterialData.h.

References lightmapTextureIndex, and MaterialData().

Here is the call graph for this function:

◆ withMetallic()

MaterialData & Engine::Core::MaterialData::withMetallic ( float m)
inline

Sets the scalar metallic value.

Parameters
mMetallic value used when no metallic-roughness texture is present.
Returns
Reference to this material for chaining.

Definition at line 178 of file MaterialData.h.

References MaterialData(), and metallicFactor.

Here is the call graph for this function:

◆ withMetallicRoughnessTexture()

MaterialData & Engine::Core::MaterialData::withMetallicRoughnessTexture ( uint32_t idx)
inline

Sets the metallic-roughness texture descriptor index.

Parameters
idxTexture descriptor index, or 0xFFFFFFFF to mark the texture absent.
Returns
Reference to this material for chaining.

Definition at line 136 of file MaterialData.h.

References MaterialData(), and roughnessMetallicTextureIndex.

Here is the call graph for this function:

◆ withNormalMapBC5()

MaterialData & Engine::Core::MaterialData::withNormalMapBC5 ( bool bc5)
inline

Selects BC5/RG normal map decoding.

Parameters
bc5True when the normal map stores X and Y channels only and reconstructs Z in the shader.
Returns
Reference to this material for chaining.

Definition at line 230 of file MaterialData.h.

References MaterialData(), and normalMapBC5.

Here is the call graph for this function:

◆ withNormalScale()

MaterialData & Engine::Core::MaterialData::withNormalScale ( float s)
inline

Sets the normal map scale.

Parameters
sScale applied to sampled tangent-space normals.
Returns
Reference to this material for chaining.

Definition at line 185 of file MaterialData.h.

References MaterialData(), and normalScale.

Here is the call graph for this function:

◆ withNormalTexture()

MaterialData & Engine::Core::MaterialData::withNormalTexture ( uint32_t idx)
inline

Sets the normal texture descriptor index.

Parameters
idxTexture descriptor index, or 0xFFFFFFFF to mark the texture absent.
Returns
Reference to this material for chaining.

Definition at line 129 of file MaterialData.h.

References MaterialData(), and normalTextureIndex.

Here is the call graph for this function:

◆ withRoughness()

MaterialData & Engine::Core::MaterialData::withRoughness ( float r)
inline

Sets the scalar roughness value.

Parameters
rRoughness value used when no metallic-roughness texture is present.
Returns
Reference to this material for chaining.

Definition at line 171 of file MaterialData.h.

References MaterialData(), and roughnessFactor.

Here is the call graph for this function:

◆ withShScale()

MaterialData & Engine::Core::MaterialData::withShScale ( float s)
inline

Sets the spherical harmonics lighting multiplier.

Parameters
sSpherical harmonics scale.
Returns
Reference to this material for chaining.

Definition at line 192 of file MaterialData.h.

References MaterialData(), and shScale.

Here is the call graph for this function:

◆ withToneMapping()

MaterialData & Engine::Core::MaterialData::withToneMapping ( uint32_t t)
inline

Sets the material tone-mapping mode.

Parameters
tTone-mapping mode: 0=None, 1=Reinhard, 2=ACES.
Returns
Reference to this material for chaining.

Definition at line 213 of file MaterialData.h.

References MaterialData(), and toneMapping.

Here is the call graph for this function:

Member Data Documentation

◆ alphaCutoff

float Engine::Core::MaterialData::alphaCutoff = 1.0f

Alpha-mask discard threshold. Values below 1.0f mark the material as masked.

Definition at line 56 of file MaterialData.h.

Referenced by isAlphaMasked(), and withAlphaCutoff().

◆ ambientTerm

float Engine::Core::MaterialData::ambientTerm = 0.0f

Ambient lighting term mixed with probe or spherical harmonics lighting.

Definition at line 51 of file MaterialData.h.

Referenced by withAmbientTerm().

◆ baseColorFactor

glm::vec4 Engine::Core::MaterialData::baseColorFactor = glm::vec4(1.0f)

Linear RGBA base-color multiplier.

Definition at line 42 of file MaterialData.h.

Referenced by MaterialData(), and withBaseColorFactor().

◆ baseColorTextureIndex

uint32_t Engine::Core::MaterialData::baseColorTextureIndex = 0xFFFFFFFF

Base-color texture descriptor index, or 0xFFFFFFFF when absent.

Definition at line 32 of file MaterialData.h.

Referenced by hasBaseColorTexture(), MaterialData(), and withBaseColorTexture().

◆ debugMode

uint32_t Engine::Core::MaterialData::debugMode = 0

Material debug mode selector.

Definition at line 52 of file MaterialData.h.

Referenced by withDebugMode().

◆ emissiveFactor

glm::vec3 Engine::Core::MaterialData::emissiveFactor = glm::vec3(0.0f)

Linear RGB emissive multiplier.

Definition at line 43 of file MaterialData.h.

Referenced by withEmissiveFactor().

◆ emissiveTextureIndex

uint32_t Engine::Core::MaterialData::emissiveTextureIndex = 0xFFFFFFFF

Emissive texture descriptor index, or 0xFFFFFFFF when absent.

Definition at line 38 of file MaterialData.h.

Referenced by hasEmissiveTexture(), and withEmissiveTexture().

◆ lightmapTextureIndex

uint32_t Engine::Core::MaterialData::lightmapTextureIndex = 0xFFFFFFFF

Lightmap texture descriptor index, or 0xFFFFFFFF when absent.

Definition at line 40 of file MaterialData.h.

Referenced by hasLightmapTexture(), and withLightmapTexture().

◆ metallicFactor

float Engine::Core::MaterialData::metallicFactor = 0.0f

Scalar metallic value used when no metallic-roughness texture is present.

Definition at line 47 of file MaterialData.h.

Referenced by withMetallic().

◆ normalMapBC5

bool Engine::Core::MaterialData::normalMapBC5 = false

True when the normal map stores X and Y in BC5/RG format and reconstructs Z.

Definition at line 55 of file MaterialData.h.

Referenced by withNormalMapBC5().

◆ normalScale

float Engine::Core::MaterialData::normalScale = 1.0f

Scale applied to sampled tangent-space normals.

Definition at line 48 of file MaterialData.h.

Referenced by withNormalScale().

◆ normalTextureIndex

uint32_t Engine::Core::MaterialData::normalTextureIndex = 0xFFFFFFFF

Normal texture descriptor index, or 0xFFFFFFFF when absent.

Definition at line 34 of file MaterialData.h.

Referenced by hasNormalTexture(), and withNormalTexture().

◆ pipeline

Graphics pipeline used to interpret this material.

Use a pipeline that matches the fields and textures set on the material. The default renders with the normals debug shader.

Definition at line 29 of file MaterialData.h.

Referenced by MaterialData(), and MaterialData().

◆ roughnessFactor

float Engine::Core::MaterialData::roughnessFactor = 1.0f

Scalar roughness used when no metallic-roughness texture is present.

Definition at line 45 of file MaterialData.h.

Referenced by withRoughness().

◆ roughnessMetallicTextureIndex

uint32_t Engine::Core::MaterialData::roughnessMetallicTextureIndex = 0xFFFFFFFF

Metallic-roughness texture descriptor index, or 0xFFFFFFFF when absent.

Definition at line 36 of file MaterialData.h.

Referenced by hasMetallicRoughnessTexture(), and withMetallicRoughnessTexture().

◆ shScale

float Engine::Core::MaterialData::shScale = 1.0f

Spherical harmonics lighting multiplier.

Definition at line 50 of file MaterialData.h.

Referenced by withShScale().

◆ toneMapping

uint32_t Engine::Core::MaterialData::toneMapping = 1

Material tone-mapping mode: 0=None, 1=Reinhard, 2=ACES.

Definition at line 53 of file MaterialData.h.

Referenced by withToneMapping().


The documentation for this struct was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Material/MaterialData.h