Open 3D Engine Atom Gem API Reference  22.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
AZ::RPI::MaterialAsset Class Reference

#include <MaterialAsset.h>

Inherits AssetData, Handler, Handler, and Handler.

Public Member Functions

 AZ_RTTI (MaterialAsset, "{522C7BE0-501D-463E-92C6-15184A2B7AD8}", AZ::Data::AssetData)
 
 AZ_CLASS_ALLOCATOR (MaterialAsset, SystemAllocator, 0)
 
const Data::Asset< MaterialTypeAsset > & GetMaterialTypeAsset () const
 Returns the MaterialTypeAsset.
 
const ShaderCollectionGetShaderCollection () const
 Returns the collection of all shaders that this material could run.
 
const MaterialFunctorList & GetMaterialFunctors () const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetMaterialSrgLayout (const SupervariantIndex &supervariantIndex) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetMaterialSrgLayout (const AZ::Name &supervariantName) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetMaterialSrgLayout () const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetObjectSrgLayout (const SupervariantIndex &supervariantIndex) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetObjectSrgLayout (const AZ::Name &supervariantName) const
 
const RHI::Ptr< RHI::ShaderResourceGroupLayout > & GetObjectSrgLayout () const
 
const MaterialPropertiesLayoutGetMaterialPropertiesLayout () const
 Returns a layout that includes a list of MaterialPropertyDescriptors for each material property.
 
const AZStd::vector< MaterialPropertyValue > & GetPropertyValues ()
 
bool WasPreFinalized () const
 Returns true if material was created in a finalize state, as opposed to being finalized after loading from disk.
 
const AZStd::vector< AZStd::pair< Name, MaterialPropertyValue > > & GetRawPropertyValues () const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 

Static Public Attributes

static const char * DisplayName
 
static const char * Group
 
static const char * Extension
 
static constexpr uint32_t UnspecifiedMaterialTypeVersion = static_cast<uint32_t>(-1)
 

Friends

class MaterialVersionUpdates
 
class MaterialAssetCreator
 
class MaterialAssetHandler
 

Detailed Description

MaterialAsset defines a single material, which can be used to create a Material instance for rendering at runtime. Use a MaterialAssetCreator to create a MaterialAsset.

Member Function Documentation

◆ GetMaterialFunctors()

const MaterialFunctorList& AZ::RPI::MaterialAsset::GetMaterialFunctors ( ) const

The material may contain any number of MaterialFunctors. Material functors provide custom logic and calculations to configure shaders, render states, and more. See MaterialFunctor.h for details.

◆ GetMaterialSrgLayout() [1/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetMaterialSrgLayout ( ) const

Just like the original GetMaterialSrgLayout() where it uses the index of the default supervariant. See the definition of DefaultSupervariantIndex.

◆ GetMaterialSrgLayout() [2/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetMaterialSrgLayout ( const AZ::Name &  supervariantName) const

Same as above but accepts the supervariant name. There's a minor penalty when using this function because it will discover the index from the name.

◆ GetMaterialSrgLayout() [3/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetMaterialSrgLayout ( const SupervariantIndex supervariantIndex) const

Returns the shader resource group layout that has per-material frequency, which indicates most of the topology for a material's shaders. All shaders in a material will have the same per-material SRG layout.

Parameters
supervariantIndexsupervariant index to get the layout from.

◆ GetObjectSrgLayout() [1/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetObjectSrgLayout ( ) const

Just like the original GetObjectSrgLayout() where it uses the index of the default supervariant. See the definition of DefaultSupervariantIndex.

◆ GetObjectSrgLayout() [2/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetObjectSrgLayout ( const AZ::Name &  supervariantName) const

Same as above but accepts the supervariant name. There's a minor penalty when using this function because it will discover the index from the name.

◆ GetObjectSrgLayout() [3/3]

const RHI::Ptr<RHI::ShaderResourceGroupLayout>& AZ::RPI::MaterialAsset::GetObjectSrgLayout ( const SupervariantIndex supervariantIndex) const

Returns the shader resource group layout that has per-object frequency. What constitutes an "object" is an agreement between the FeatureProcessor and the shaders, but an example might be world-transform for a model. All shaders in a material will have the same per-object SRG layout.

Parameters
supervariantIndexsupervariant index to get the layout from.

◆ GetPropertyValues()

const AZStd::vector<MaterialPropertyValue>& AZ::RPI::MaterialAsset::GetPropertyValues ( )

Returns the list of values for all properties in this material. The entries in this list align with the entries in the MaterialPropertiesLayout. Each AZStd::any is guaranteed to have a value of type that matches the corresponding MaterialPropertyDescriptor. For images, the value will be of type ImageBinding.

Note that even though material source data files contain only override values and inherit the rest from their parent material, they all get flattened at build time so every MaterialAsset has the full set of values.

Calling GetPropertyValues() will automatically finalize the material asset if it isn't finalized already. The MaterialTypeAsset must be loaded and ready.

◆ GetRawPropertyValues()

const AZStd::vector<AZStd::pair<Name, MaterialPropertyValue> >& AZ::RPI::MaterialAsset::GetRawPropertyValues ( ) const

Returns the list of raw values for all properties in this material, as listed in the source .material file(s), before the material asset was Finalized.

The MaterialAsset can be created in a "half-baked" state (see MaterialUtils::BuildersShouldFinalizeMaterialAssets) where minimal processing has been done because it did not yet have access to the MaterialTypeAsset. In that case, the list will be populated with values copied from the source .material file with little or no validation or other processing. It includes all parent .material files, with properties listed in low-to-high priority order. This list will be empty however if the asset was finalized at build-time (i.e. WasPreFinalized() returns true).


The documentation for this class was generated from the following file: