#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. | |
PropertyGroup * | AddPropertyGroup (AZStd::string_view propertyGroupId) |
MaterialPropertySourceData * | AddProperty (AZStd::string_view propertyId) |
const PropertyLayout & | GetPropertyLayout () const |
Return the PropertyLayout containing the tree of property groups and property definitions. | |
const PropertyGroup * | FindPropertyGroup (AZStd::string_view propertyGroupId) const |
PropertyGroup * | FindPropertyGroup (AZStd::string_view propertyGroupId) |
const MaterialPropertySourceData * | FindProperty (AZStd::string_view propertyId) const |
MaterialPropertySourceData * | FindProperty (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< ShaderVariantReferenceData > | m_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, MaterialPipelineState > | m_pipelineData |
UvNameMap | m_uvNameMap |
Static Public Attributes | |
static constexpr const char | Extension [] = "materialtype" |
static constexpr AZ::u32 | IntermediateMaterialTypeSubId = 0 |
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.
using AZ::RPI::MaterialTypeSourceData::EnumeratePropertiesCallback = AZStd::function<bool( const MaterialPropertySourceData*, const MaterialNameContext& )> |
Call back function type used with the numeration functions. Return false to terminate the traversal.
using AZ::RPI::MaterialTypeSourceData::EnumeratePropertyGroupsCallback = AZStd::function<bool(const PropertyGroupStack&)> |
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.
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.
|
strong |
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. |
MaterialPropertySourceData * AZ::RPI::MaterialTypeSourceData::AddProperty | ( | AZStd::string_view | propertyId | ) |
Add a new property to a PropertyGroup.
propertyId | The ID of the new property, like "layerBlend.factor" or "layer2.roughness.texture". The indicated property group must already exist. |
PropertyGroup * AZ::RPI::MaterialTypeSourceData::AddPropertyGroup | ( | AZStd::string_view | propertyGroupId | ) |
Add a new PropertyGroup for containing properties or other PropertyGroups.
propertyGroupId | The 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. |
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.
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.
const MaterialPropertySourceData * AZ::RPI::MaterialTypeSourceData::FindProperty | ( | AZStd::string_view | propertyId | ) | const |
Find the definition for a property with the given ID.
propertyId | The full ID of a property to find, like "baseColor.texture". |
const PropertyGroup * AZ::RPI::MaterialTypeSourceData::FindPropertyGroup | ( | AZStd::string_view | propertyGroupId | ) | const |
Find the PropertyGroup with the given ID.
propertyGroupId | The full ID of a property group to find, like "levelA.levelB.levelC". |
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.
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()).
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()).
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.