MaterialParents
MaterialParents
#Overview
name: MaterialParents
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of MaterialParents is to manage and store a mapping between predefined glTF material identifiers and their corresponding parent material assets in Unreal Engine 5. This variable is primarily used in the context of the Interchange system, specifically for handling glTF material imports and customizations.
MaterialParents is mainly relied upon by the Interchange subsystem, particularly within the glTF pipeline module. It is used in both the Editor and Runtime components of the Interchange plugin.
The value of this variable is typically set through the UGLTFPipelineSettings class, which inherits from UDeveloperSettings. This allows the variable to be configured in the project settings.
MaterialParents interacts with other variables and functions within the glTF pipeline, such as ExpectedMaterialInstanceIdentifiers and GenerateExpectedParametersList(). It’s also used in conjunction with material instance creation and validation processes.
Developers must be aware of the following when using this variable:
- It’s part of the “PredefinedglTFMaterialLibrary” category in the project settings.
- The variable is hidden in certain UI customizations, suggesting it might not be intended for direct user manipulation in all contexts.
- It plays a crucial role in mapping imported glTF materials to existing Unreal Engine materials.
Best practices when using this variable include:
- Ensure that all expected material identifiers are properly mapped to valid parent materials.
- Regularly validate the MaterialParents map using the ValidateMaterialInstancesAndParameters() function to catch any misconfigurations.
- When extending the glTF import pipeline, consider how changes might affect the MaterialParents mapping and update accordingly.
- Be cautious when modifying this variable directly, as it’s central to the glTF material import process and could affect the entire pipeline if misconfigured.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Plugins/Interchange/Runtime/Config/BaseInterchange.ini:58, section: [/Script/InterchangePipelines.GLTFPipelineSettings]
- INI Section:
/Script/InterchangePipelines.GLTFPipelineSettings
- Raw value:
(("MI_Default_Opaque", "/Interchange/gltf/MaterialInstances/MI_Default_Opaque.MI_Default_Opaque"), ("MI_Default_Mask", "/Interchange/gltf/MaterialInstances/MI_Default_Mask.MI_Default_Mask"), ("MI_Default_Blend", "/Interchange/gltf/MaterialInstances/MI_Default_Blend.MI_Default_Blend"), ("MI_Unlit_Opaque", "/Interchange/gltf/MaterialInstances/MI_Unlit_Opaque.MI_Unlit_Opaque"), ("MI_Unlit_Mask", "/Interchange/gltf/MaterialInstances/MI_Unlit_Mask.MI_Unlit_Mask"), ("MI_Unlit_Blend", "/Interchange/gltf/MaterialInstances/MI_Unlit_Blend.MI_Unlit_Blend"), ("MI_ClearCoat_Opaque", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Opaque.MI_ClearCoat_Opaque"), ("MI_ClearCoat_Mask", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Mask.MI_ClearCoat_Mask"), ("MI_ClearCoat_Blend", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Blend.MI_ClearCoat_Blend"), ("MI_Sheen_Opaque", "/Interchange/gltf/MaterialInstances/MI_Sheen_Opaque.MI_Sheen_Opaque"), ("MI_Sheen_Mask", "/Interchange/gltf/MaterialInstances/MI_Sheen_Mask.MI_Sheen_Mask"), ("MI_Sheen_Blend", "/Interchange/gltf/MaterialInstances/MI_Sheen_Blend.MI_Sheen_Blend"), ("MI_Transmission", "/Interchange/gltf/MaterialInstances/MI_Transmission.MI_Transmission"), ("MI_SpecularGlossiness_Opaque", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Opaque.MI_SpecularGlossiness_Opaque"), ("MI_SpecularGlossiness_Mask", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Mask.MI_SpecularGlossiness_Mask"), ("MI_SpecularGlossiness_Blend", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Blend.MI_SpecularGlossiness_Blend"), ("MI_Default_Opaque_DS", "/Interchange/gltf/MaterialInstances/MI_Default_Opaque_DS.MI_Default_Opaque_DS"), ("MI_Default_Mask_DS", "/Interchange/gltf/MaterialInstances/MI_Default_Mask_DS.MI_Default_Mask_DS"), ("MI_Default_Blend_DS", "/Interchange/gltf/MaterialInstances/MI_Default_Blend_DS.MI_Default_Blend_DS"), ("MI_Unlit_Opaque_DS", "/Interchange/gltf/MaterialInstances/MI_Unlit_Opaque_DS.MI_Unlit_Opaque_DS"), ("MI_Unlit_Mask_DS", "/Interchange/gltf/MaterialInstances/MI_Unlit_Mask_DS.MI_Unlit_Mask_DS"), ("MI_Unlit_Blend_DS", "/Interchange/gltf/MaterialInstances/MI_Unlit_Blend_DS.MI_Unlit_Blend_DS"), ("MI_ClearCoat_Opaque_DS", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Opaque_DS.MI_ClearCoat_Opaque_DS"), ("MI_ClearCoat_Mask_DS", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Mask_DS.MI_ClearCoat_Mask_DS"), ("MI_ClearCoat_Blend_DS", "/Interchange/gltf/MaterialInstances/MI_ClearCoat_Blend_DS.MI_ClearCoat_Blend_DS"), ("MI_Sheen_Opaque_DS", "/Interchange/gltf/MaterialInstances/MI_Sheen_Opaque_DS.MI_Sheen_Opaque_DS"), ("MI_Sheen_Mask_DS", "/Interchange/gltf/MaterialInstances/MI_Sheen_Mask_DS.MI_Sheen_Mask_DS"), ("MI_Sheen_Blend_DS", "/Interchange/gltf/MaterialInstances/MI_Sheen_Blend_DS.MI_Sheen_Blend_DS"), ("MI_Transmission_DS", "/Interchange/gltf/MaterialInstances/MI_Transmission_DS.MI_Transmission_DS"), ("MI_SpecularGlossiness_Opaque_DS", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Opaque_DS.MI_SpecularGlossiness_Opaque_DS"), ("MI_SpecularGlossiness_Mask_DS", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Mask_DS.MI_SpecularGlossiness_Mask_DS"), ("MI_SpecularGlossiness_Blend_DS", "/Interchange/gltf/MaterialInstances/MI_SpecularGlossiness_Blend_DS.MI_SpecularGlossiness_Blend_DS"))
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Interchange/Editor/Source/Pipelines/Private/InterchangeGLTFPipelineCustomizations.cpp:87
Scope (from outer to inner):
file
function void FInterchangeGLTFPipelineSettingsCustomization::CustomizeDetails
Source code excerpt:
}
TSharedRef< IPropertyHandle > PairingsHandle = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UGLTFPipelineSettings, MaterialParents));
if (!PairingsHandle->IsValidHandle())
{
return;
}
DetailBuilder.HideProperty(PairingsHandle);
#Loc: <Workspace>/Engine/Plugins/Interchange/Editor/Source/Pipelines/Private/InterchangeGLTFPipelineCustomizations.cpp:133
Scope (from outer to inner):
file
function void FInterchangeGLTFPipelineSettingsCustomization::CustomizeDetails
Source code excerpt:
IDetailCategoryBuilder& GLTFPredefinedMaterialLibraryCategory = DetailBuilder.EditCategory("PredefinedglTFMaterialLibrary", FText::FromString("Predefined glTF Material Library"));
DetailBuilder.HideCategory(GET_MEMBER_NAME_CHECKED(UGLTFPipelineSettings, MaterialParents));
}
#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeglTFPipeline.cpp:36
Scope (from outer to inner):
file
function TArray<FString> UGLTFPipelineSettings::ValidateMaterialInstancesAndParameters
Source code excerpt:
TArray<FString> ExpectedIdentifiers = ExpectedMaterialInstanceIdentifiers;
TArray<FString> IdentifiersUsed;
MaterialParents.GetKeys(IdentifiersUsed);
for (const FString& Identifier : IdentifiersUsed)
{
ExpectedIdentifiers.Remove(Identifier);
}
for (const FString& ExpectedIdentifier : ExpectedIdentifiers)
{
#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeglTFPipeline.cpp:46
Scope (from outer to inner):
file
function TArray<FString> UGLTFPipelineSettings::ValidateMaterialInstancesAndParameters
Source code excerpt:
}
for (const TPair<FString, FSoftObjectPath>& MaterialParent : MaterialParents)
{
TSet<FString> ExpectedParameters = GenerateExpectedParametersList(MaterialParent.Key);
if (UMaterialInstance* ParentMaterialInstance = Cast<UMaterialInstance>(MaterialParent.Value.TryLoad()))
{
TArray<FGuid> ParameterIds;
#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeglTFPipeline.cpp:208
Scope (from outer to inner):
file
function void UGLTFPipelineSettings::BuildMaterialInstance
Source code excerpt:
FString Parent;
if (const FSoftObjectPath* ObjectPath = MaterialParents.Find(ParentIdentifier))
{
Parent = ObjectPath->GetAssetPathString();
}
else
{
UE_LOG(LogInterchangePipeline, Warning, TEXT("[Interchange] Failed to load MaterialParent for ParentIdentifier: %s"), *ParentIdentifier);
#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Public/InterchangeglTFPipeline.h:23
Scope (from outer to inner):
file
class class UGLTFPipelineSettings : public UDeveloperSettings
Source code excerpt:
public:
UPROPERTY(EditAnywhere, config, Category = "PredefinedglTFMaterialLibrary", meta = (DisplayName = "Predefined glTF Material Library"))
TMap<FString, FSoftObjectPath> MaterialParents;
TArray<FString> ValidateMaterialInstancesAndParameters() const;
void BuildMaterialInstance(const UInterchangeShaderGraphNode* ShaderGraphNode, UInterchangeMaterialInstanceFactoryNode* materialInstanceNode);
bool IsMaterialParentsEditible() { return bMaterialParentsEditible; }
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Materials/MaterialInstance.cpp:1200
Scope (from outer to inner):
file
function void UMaterialInstance::LogMaterialsAndTextures
Source code excerpt:
const UMaterialInterface* CurrentMaterialInterface = this;
{
TSet<const UMaterialInterface*> MaterialParents;
// Walk up the parent chain to the materials to use.
while (CurrentMaterialInterface && !MaterialParents.Contains(CurrentMaterialInterface))
{
MaterialParents.Add(CurrentMaterialInterface);
const UMaterialInstance* CurrentMaterialInstance = Cast<const UMaterialInstance>(CurrentMaterialInterface);
const UMaterial* CurrentMaterial = Cast<const UMaterial>(CurrentMaterialInterface);
// The parent material is the first parent of this class.
if (!MaterialToUse && CurrentMaterial)