Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RPI::MaterialTypeAssetCreator Class Reference

#include <MaterialTypeAssetCreator.h>

Inherits AZ::RPI::AssetCreator< MaterialTypeAsset >.

Public Member Functions

void Begin (const Data::AssetId &assetId)
 Begin creating a MaterialTypeAsset.
 
void AddShader (const AZ::Data::Asset< ShaderAsset > &shaderAsset, const ShaderVariantId &shaderVariantId={}, const AZ::Name &shaderTag={}, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void SetVersion (uint32_t version)
 Sets the version of the MaterialTypeAsset.
 
void AddVersionUpdate (const MaterialVersionUpdate &materialVersionUpdate)
 Adds a version update object into the MaterialTypeAsset.
 
void ClaimShaderOptionOwnership (const Name &shaderOptionName)
 
void BeginMaterialProperty (const Name &materialPropertyName, MaterialPropertyDataType dataType, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void ConnectMaterialPropertyToShaderInput (const Name &shaderInputName)
 Adds an output mapping from the current material property to a ShaderResourceGroup input.
 
void ConnectMaterialPropertyToShaderOptions (const Name &shaderOptionName)
 
void ConnectMaterialPropertyToShaderEnabled (const Name &shaderTag)
 
void SetMaterialPropertyEnumNames (const AZStd::vector< AZStd::string > &enumNames)
 Store the enum names if a property is an enum type.
 
void EndMaterialProperty ()
 Finishes creating a material property.
 
void SetPropertyValue (const Name &name, const Data::Asset< ImageAsset > &imageAsset, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void SetPropertyValue (const Name &name, const Data::Asset< StreamingImageAsset > &imageAsset, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void SetPropertyValue (const Name &name, const Data::Asset< AttachmentImageAsset > &imageAsset, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void SetPropertyValue (const Name &name, const MaterialPropertyValue &value, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void AddMaterialFunctor (const Ptr< MaterialFunctor > &functor, const AZ::Name &materialPipelineName=MaterialPipelineNone)
 
void AddUvName (const RHI::ShaderSemantic &shaderInput, const Name &uvName)
 Adds UV name for a shader input.
 
const MaterialPropertiesLayoutGetMaterialPropertiesLayout (const AZ::Name &materialPipelineName=MaterialPipelineNone) const
 
const RHI::ShaderResourceGroupLayoutGetMaterialShaderResourceGroupLayout () const
 
bool End (Data::Asset< MaterialTypeAsset > &result)
 
- Public Member Functions inherited from AZ::RPI::AssetCreator< MaterialTypeAsset >
void SetElevateWarnings (bool elevated)
 When true, treat all subsequent warnings as errors. Any warnings already reported will not be elevated.
 
bool GetElevateWarnings () const
 
int GetErrorCount () const
 
int GetWarningCount () const
 
bool IsFailed () const
 
void ReportError (const char *format, Args... args)
 
void ReportWarning (const char *format, Args... args)
 

Additional Inherited Members

- Protected Member Functions inherited from AZ::RPI::AssetCreator< MaterialTypeAsset >
 AZ_DISABLE_COPY_MOVE (AssetCreator)
 
void BeginCommon (const Data::AssetId &assetId)
 
bool EndCommon (Data::Asset< MaterialTypeAsset > &result)
 
bool ValidateIsReady ()
 
bool ValidateNotNull (void *pointer, const char *name)
 Reports errors when a pointer is null.
 
bool ValidateNotNull (const AZ::Data::Asset< AZ::Data::AssetData > &pointer, const char *name)
 
bool ValidateNotNull (const AZStd::intrusive_ptr< T > &pointer, const char *name)
 
- Protected Attributes inherited from AZ::RPI::AssetCreator< MaterialTypeAsset >
Data::Asset< MaterialTypeAssetm_asset
 This is the asset that subclass creators will build.
 

Detailed Description

Use a MaterialAssetCreator to create and configure a new MaterialAsset. The MaterialAsset will be based on a MaterialTypeAsset, which provides the necessary data to define the layout and behavior of the material. The MaterialAsset itself only provides property values. The MaterialAsset may optionally inherit from another 'parent' MaterialAsset, which provides the MaterialTypeAsset and default property values.

Member Function Documentation

◆ AddMaterialFunctor()

void AZ::RPI::MaterialTypeAssetCreator::AddMaterialFunctor ( const Ptr< MaterialFunctor > &  functor,
const AZ::Name &  materialPipelineName = MaterialPipelineNone 
)

Adds a MaterialFunctor. Material functors provide custom logic and calculations to configure shaders, render states, and more.See MaterialFunctor.h for details.

Parameters
materialPipelineNameIdentifies a MaterialPipelinePayload that this functor should be added to. For MaterialPipelineNone, the functor will be used for the main ShaderCollection that applies to all pipelines.

◆ AddShader()

void AZ::RPI::MaterialTypeAssetCreator::AddShader ( const AZ::Data::Asset< ShaderAsset > &  shaderAsset,
const ShaderVariantId shaderVariantId = {},
const AZ::Name &  shaderTag = {},
const AZ::Name &  materialPipelineName = MaterialPipelineNone 
)

Adds a shader to the built-in shader collection, which will be run for this material.

Parameters
shaderTagMust be unique within the material type's list of shaders.
materialPipelineNameIdentifies a specific MaterialPipelinePayload that this shader should be added to. For MaterialPipelineNone, the shader will be used for all pipelines.

◆ BeginMaterialProperty()

void AZ::RPI::MaterialTypeAssetCreator::BeginMaterialProperty ( const Name &  materialPropertyName,
MaterialPropertyDataType  dataType,
const AZ::Name &  materialPipelineName = MaterialPipelineNone 
)

Starts creating a material property. Note that EndMaterialProperty() must be called before calling SetMaterialPropertyValue(). Similarly, The property will not appear in GetMaterialPropertiesLayout() until EndMaterialProperty() is called.

Parameters
materialPipelineNameFor internal material properties, this indicates which material pipeline the property is for. For main material properties, use MaterialPipelineNone.

◆ ClaimShaderOptionOwnership()

void AZ::RPI::MaterialTypeAssetCreator::ClaimShaderOptionOwnership ( const Name &  shaderOptionName)

Indicates that this MaterialType will own the specified shader option. Material-owned shader options can be connected to material properties (either directly or through functors). They cannot be accessed externally (for example, through the Material::SetSystemShaderOption() function). Note that ConnectMaterialPropertyToShaderOptions() automatically claims ownership; so ClaimShaderOptionOwnership() only needs to be called for options used by material functors.

◆ ConnectMaterialPropertyToShaderEnabled()

void AZ::RPI::MaterialTypeAssetCreator::ConnectMaterialPropertyToShaderEnabled ( const Name &  shaderTag)

Adds an output mapping from the current material property to a Enabled flag of a specific shader.

Parameters
shaderTagThe tag name that unique identifies a shader in the material type.

◆ ConnectMaterialPropertyToShaderOptions()

void AZ::RPI::MaterialTypeAssetCreator::ConnectMaterialPropertyToShaderOptions ( const Name &  shaderOptionName)

Adds output mappings from the current material property to a shader option in multiple shaders. Will add one mapping for every ShaderAsset that has a matching shader option.

◆ GetMaterialPropertiesLayout()

const MaterialPropertiesLayout * AZ::RPI::MaterialTypeAssetCreator::GetMaterialPropertiesLayout ( const AZ::Name &  materialPipelineName = MaterialPipelineNone) const

This provides access to the MaterialPropertiesLayout while the MaterialTypeAsset is still being built. This is needed by MaterialTypeSourceData to initialize functor objects.

Parameters
materialPipelineNameFor internal material properties, this indicates which MaterialPipelinePayload's property layout to query. For main material properties, use MaterialPipelineNone.
Returns
A valid pointer when called between Begin() and End(). Otherwise, returns nullptr.

◆ GetMaterialShaderResourceGroupLayout()

const RHI::ShaderResourceGroupLayout * AZ::RPI::MaterialTypeAssetCreator::GetMaterialShaderResourceGroupLayout ( ) const

This provides access to the material ShaderResourceGroupLayout being used for the MaterialTypeAsset. This is needed by MaterialTypeSourceData to initialize functor objects. The same layout object can be retrieved from the ShaderAssets passed to the creator, but this function is provided for convenience.

Returns
A valid pointer if a ShaderAsset with a material ShaderResourceGroupLayout was added. Otherwise, returns nullptr.

◆ SetPropertyValue() [1/2]

void AZ::RPI::MaterialTypeAssetCreator::SetPropertyValue ( const Name &  name,
const Data::Asset< ImageAsset > &  imageAsset,
const AZ::Name &  materialPipelineName = MaterialPipelineNone 
)
Parameters
materialPipelineNameFor internal material properties, this indicates which MaterialPipelinePlayload's property to update. For main material properties, use MaterialPipelineNone.

◆ SetPropertyValue() [2/2]

void AZ::RPI::MaterialTypeAssetCreator::SetPropertyValue ( const Name &  name,
const MaterialPropertyValue value,
const AZ::Name &  materialPipelineName = MaterialPipelineNone 
)

Sets a property value using data in AZStd::variant-based MaterialPropertyValue. The contained data must match the data type of the property. For type Image, the value must be a Data::Asset<ImageAsset>.

Parameters
materialPipelineNameFor internal material properties, this indicates which MaterialPipelinePayload's property to update. For main material properties, use MaterialPipelineNone.

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