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::MaterialTypeSourceData Class Referencefinal

#include <MaterialTypeSourceData.h>

Classes

struct  GroupDefinition
 
struct  MaterialPipelineState
 
struct  PropertyGroup
 
struct  PropertyLayout
 
struct  ShaderVariantReferenceData
 
struct  VersionUpdateDefinition
 

Public Types

enum class  Format { Invalid , Abstract , Direct }
 
using PropertyList = AZStd::vector< AZStd::unique_ptr< MaterialPropertySourceData > >
 
using VersionUpdateActions = AZStd::vector< MaterialVersionUpdate::Action::ActionDefinition >
 
using VersionUpdates = AZStd::vector< VersionUpdateDefinition >
 
using UvNameMap = AZStd::map< AZStd::string, AZStd::string >
 
using PropertyGroupStack = AZStd::vector< const PropertyGroup * >
 Describes a path in the hierarchy of property groups, with the top level group at the beginning and a leaf-most group at the end.
 
using EnumeratePropertyGroupsCallback = AZStd::function< bool(const PropertyGroupStack &)>
 
using EnumeratePropertiesCallback = AZStd::function< bool(const MaterialPropertySourceData *, const MaterialNameContext &)>
 

Public Member Functions

 AZ_TYPE_INFO (AZ::RPI::MaterialTypeSourceData, "{14085B6F-42E8-447D-9833-E1E45C2510B2}")
 
 AZ_CLASS_ALLOCATOR (MaterialTypeSourceData, SystemAllocator)
 
void ResolveUvEnums ()
 Copy over UV custom names to the properties enum values.
 
PropertyGroupAddPropertyGroup (AZStd::string_view propertyGroupId)
 
MaterialPropertySourceDataAddProperty (AZStd::string_view propertyId)
 
const PropertyLayoutGetPropertyLayout () const
 Return the PropertyLayout containing the tree of property groups and property definitions.
 
const PropertyGroupFindPropertyGroup (AZStd::string_view propertyGroupId) const
 
PropertyGroupFindPropertyGroup (AZStd::string_view propertyGroupId)
 
const MaterialPropertySourceDataFindProperty (AZStd::string_view propertyId) const
 
MaterialPropertySourceDataFindProperty (AZStd::string_view propertyId)
 
void SortProperties ()
 Sort child groups and properties by name.
 
bool EnumeratePropertyGroups (const EnumeratePropertyGroupsCallback &callback) const
 
bool EnumerateProperties (const EnumeratePropertiesCallback &callback) const
 
Outcome< Data::Asset< MaterialTypeAsset > > CreateMaterialTypeAsset (Data::AssetId assetId, AZStd::string_view materialTypeSourceFilePath="", bool elevateWarnings=true) const
 Create a MaterialTypeAsset for use at runtime. This is only valid for material types with the "direct" format (see GetFormat()).
 
bool UpgradeLegacyFormat ()
 
Format GetFormat () const
 See enum Format.
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static AZStd::vector< AZStd::string_view > TokenizeId (AZStd::string_view id)
 Tokenizes an ID string like "itemA.itemB.itemC" into a vector like ["itemA", "itemB", "itemC"].
 
static AZStd::vector< AZStd::string_view > SplitId (AZStd::string_view id)
 Splits an ID string like "itemA.itemB.itemC" into a vector like ["itemA.itemB", "itemC"].
 
static MaterialNameContext MakeMaterialNameContext (const MaterialTypeSourceData::PropertyGroupStack &propertyGroupStack)
 Returns a MaterialNameContext for a specific path through the property group hierarchy.
 

Public Attributes

AZStd::string m_description
 
uint32_t m_version = 1
 Version 1 is the default and should not contain any version update.
 
VersionUpdates m_versionUpdates
 
AZStd::string m_lightingModel
 
AZStd::string m_materialShaderCode
 
AZStd::vector< ShaderVariantReferenceDatam_shaderCollection
 A list of specific shaders that will be used to render the material.
 
AZStd::vector< Ptr< MaterialFunctorSourceDataHolder > > m_materialFunctorSourceData
 Material functors provide custom logic and calculations to configure shaders, render states, and more. See MaterialFunctor.h for details.
 
AZStd::unordered_map< Name, MaterialPipelineStatem_pipelineData
 
UvNameMap m_uvNameMap
 

Static Public Attributes

static constexpr const char Extension [] = "materialtype"
 
static constexpr AZ::u32 IntermediateMaterialTypeSubId = 0
 

Detailed Description

This is a simple data structure for serializing in/out .materialtype source files. The .materialtype file has two slightly different formats: "abstract" and "direct". See enum Format below.

Member Typedef Documentation

◆ EnumeratePropertiesCallback

Call back function type used with the numeration functions. Return false to terminate the traversal.

◆ EnumeratePropertyGroupsCallback

Call back function type used with the enumeration functions. The PropertyGroupStack contains the stack of property groups at the current point in the traversal. Return false to terminate the traversal.

◆ UvNameMap

using AZ::RPI::MaterialTypeSourceData::UvNameMap = AZStd::map<AZStd::string, AZStd::string>

Override names for UV input in the shaders of this material type. Using ordered map to sort names on loading.

Member Enumeration Documentation

◆ Format

The .materialtype file has two slightly different formats, in most cases users will want to author content in the abstract format, which is more convenient to work with, as it hides of lot of technical details and automatically works with mulitple render pipelines.

Enumerator
Abstract 

In the abstract format, the material type provides only material-specific shader code and a lighting model reference. The MaterialTypeBuilder will automatically adapt the material type to work in any render pipeline (Forward+, Deferred, VR, etc.), by stitching it together with the available material pipelines (see MaterialPipelineSourceData). This will produce a new intermediate material type that is not abstract, for further processing.

Direct 

In the direct format, the material type provides a complete list of the specific shaders that will be used for rendering. This circumvents the material pipeline system, and the author is responsible for adapting the material type to any desired render pipelines.

Member Function Documentation

◆ AddProperty()

MaterialPropertySourceData * AZ::RPI::MaterialTypeSourceData::AddProperty ( AZStd::string_view  propertyId)

Add a new property to a PropertyGroup.

Parameters
propertyIdThe ID of the new property, like "layerBlend.factor" or "layer2.roughness.texture". The indicated property group must already exist.
Returns
a pointer to the new MaterialPropertySourceData or null if there was a problem (an AZ_Error will be reported).

◆ AddPropertyGroup()

PropertyGroup * AZ::RPI::MaterialTypeSourceData::AddPropertyGroup ( AZStd::string_view  propertyGroupId)

Add a new PropertyGroup for containing properties or other PropertyGroups.

Parameters
propertyGroupIdThe ID of the new property group. To add as a nested PropertyGroup, use a full path ID like "levelA.levelB.levelC"; in this case a property group "levelA.levelB" must already exist.
Returns
a pointer to the new PropertyGroup or null if there was a problem (an AZ_Error will be reported).

◆ EnumerateProperties()

bool AZ::RPI::MaterialTypeSourceData::EnumerateProperties ( const EnumeratePropertiesCallback callback) const

Recursively traverses all of the properties contained in the material type, executing a callback function for each.

Returns
false if the enumeration was terminated early by the callback returning false.

◆ EnumeratePropertyGroups()

bool AZ::RPI::MaterialTypeSourceData::EnumeratePropertyGroups ( const EnumeratePropertyGroupsCallback callback) const

Recursively traverses all of the property groups contained in the material type, executing a callback function for each.

Returns
false if the enumeration was terminated early by the callback returning false.

◆ FindProperty()

const MaterialPropertySourceData * AZ::RPI::MaterialTypeSourceData::FindProperty ( AZStd::string_view  propertyId) const

Find the definition for a property with the given ID.

Parameters
propertyIdThe full ID of a property to find, like "baseColor.texture".
Returns
the found MaterialPropertySourceData or null if it doesn't exist.

◆ FindPropertyGroup()

const PropertyGroup * AZ::RPI::MaterialTypeSourceData::FindPropertyGroup ( AZStd::string_view  propertyGroupId) const

Find the PropertyGroup with the given ID.

Parameters
propertyGroupIdThe full ID of a property group to find, like "levelA.levelB.levelC".
Returns
the found PropertyGroup or null if it doesn't exist.

◆ UpgradeLegacyFormat()

bool AZ::RPI::MaterialTypeSourceData::UpgradeLegacyFormat ( )

If the data was loaded from the legacy format file (i.e. where "groups" and "properties" were separate sections), this converts to the new format where properties are listed inside property groups.

Member Data Documentation

◆ m_lightingModel

AZStd::string AZ::RPI::MaterialTypeSourceData::m_lightingModel

This indicates the name of the lighting model that this material type uses. For example, "Standard", "Enhanced", "Skin". The actual set of available lighting models is determined by the .materialpipeline. This is relevant for "abstract" material type files (see GetFormat()).

◆ m_materialShaderCode

AZStd::string AZ::RPI::MaterialTypeSourceData::m_materialShaderCode

This indicates a .azsli file that contains only material-specific shader code. The build system will automatically combine this code with .materialpipeline shader code for use in each available render pipeline. This is relevant for "abstract" material type files (see GetFormat()).

◆ m_pipelineData

AZStd::unordered_map<Name, MaterialPipelineState> AZ::RPI::MaterialTypeSourceData::m_pipelineData

Contains shaders and other data for use in specific render pipelines. To apply shaders to all render pipelines, use the @m_shaderCollection and @m_materialFunctorSourceData above.


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