PredefinedSurfaceShaders

PredefinedSurfaceShaders

#Overview

name: PredefinedSurfaceShaders

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 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PredefinedSurfaceShaders is to store a mapping between predefined MaterialX surface shaders and their corresponding asset paths in Unreal Engine 5. This variable is part of the MaterialX pipeline settings, which is used for importing and processing MaterialX files in Unreal Engine.

This setting variable is primarily used by the Interchange system, specifically within the MaterialX pipeline. It’s referenced in the Interchange Editor plugin and the Interchange Runtime module.

The value of this variable is set in the UMaterialXPipelineSettings class, which inherits from UDeveloperSettings. It’s defined as a TMap that associates EInterchangeMaterialXShaders enum values with FSoftObjectPath objects.

PredefinedSurfaceShaders interacts with other similar variables like PredefinedBSDF, PredefinedEDF, and PredefinedVDF, which together form a set of predefined shader mappings for different MaterialX shader types.

Developers should be aware that:

  1. This variable is used to map MaterialX shader types to corresponding Unreal Engine assets.
  2. It’s part of the configuration for the MaterialX import pipeline.
  3. The variable is used in the process of loading required packages for the MaterialX pipeline.

Best practices when using this variable include:

  1. Ensure that the mapped asset paths are valid and point to appropriate shader assets.
  2. Keep the predefined shader mappings up-to-date with any changes in the MaterialX standard or Unreal Engine’s shader system.
  3. When customizing the MaterialX import process, consider how changes to this variable might affect the overall pipeline.
  4. Use the provided customization functions (like CustomizeDetails) when modifying these settings in the editor.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Plugins/Interchange/Runtime/Config/BaseInterchange.ini:61, section: [/Script/InterchangePipelines.MaterialXPipelineSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Interchange/Editor/Source/Pipelines/Private/InterchangeMaterialXPipelineCustomizations.cpp:123

Scope (from outer to inner):

file
function     void FInterchangeMaterialXPipelineSettingsCustomization::CustomizeDetails

Source code excerpt:

	};

	Customize(GET_MEMBER_NAME_CHECKED(UMaterialXPipelineSettings, PredefinedSurfaceShaders),
			  TEXT("MaterialXPredefined | Surface Shaders"),
			  NSLOCTEXT("InterchangeMaterialXPipelineSettingsCustomization", "MaterialXPredefined | SurfaceShaders", "Surface Shaders"),
			  UE::Interchange::MaterialX::IndexSurfaceShaders);

	Customize(GET_MEMBER_NAME_CHECKED(UMaterialXPipelineSettings, PredefinedBSDF),
			  TEXT("MaterialXPredefined | BSDF"),

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeMaterialXPipeline.cpp:661

Scope (from outer to inner):

file
function     UInterchangeMaterialXPipeline::UInterchangeMaterialXPipeline

Source code excerpt:



	for (const TPair<EInterchangeMaterialXShaders, FSoftObjectPath>& Entry : MaterialXSettings->PredefinedSurfaceShaders)
	{
		PathToEnumMapping.FindOrAdd(Entry.Value.GetAssetPathString(), EInterchangeMaterialXSettings{ TInPlaceType<EInterchangeMaterialXShaders>{}, Entry.Key });
	}

	for(const TPair<EInterchangeMaterialXBSDF, FSoftObjectPath>& Entry : MaterialXSettings->PredefinedBSDF)
	{

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeMaterialXPipeline.cpp:792

Scope (from outer to inner):

file
function     bool UMaterialXPipelineSettings::AreRequiredPackagesLoaded

Source code excerpt:

	};

	return ArePackagesLoaded(PredefinedSurfaceShaders) && ArePackagesLoaded(PredefinedBSDF) && ArePackagesLoaded(PredefinedEDF) && ArePackagesLoaded(PredefinedVDF);
}

#if WITH_EDITOR
void UMaterialXPipelineSettings::InitPredefinedAssets()
{
	if(bIsSubstrateEnabled)

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeMaterialXPipeline.cpp:836

Scope (from outer to inner):

file
function     void UMaterialXPipelineSettings::InitPredefinedAssets

Source code excerpt:

				if(ShadersSettings.IsType<EInterchangeMaterialXShaders>())
				{
					PredefinedSurfaceShaders.Add(ShadersSettings.Get<EInterchangeMaterialXShaders>(), FSoftObjectPath{ Mapping.Get<2>() });
				}
				else if(ShadersSettings.IsType<EInterchangeMaterialXBSDF>())
				{
					PredefinedBSDF.Add(ShadersSettings.Get<EInterchangeMaterialXBSDF>(), FSoftObjectPath{ Mapping.Get<2>() });
				}
				else if(ShadersSettings.IsType<EInterchangeMaterialXEDF>())

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Private/InterchangeMaterialXPipeline.cpp:870

Scope (from outer to inner):

file
function     FString UMaterialXPipelineSettings::GetAssetPathString

Source code excerpt:

	if(EnumValue.IsType<EInterchangeMaterialXShaders>())
	{
		return FindAssetPathString(PredefinedSurfaceShaders, EnumValue.Get<EInterchangeMaterialXShaders>());
	}
	else if(EnumValue.IsType<EInterchangeMaterialXBSDF>())
	{
		return FindAssetPathString(PredefinedBSDF, EnumValue.Get<EInterchangeMaterialXBSDF>());
	}
	else if(EnumValue.IsType<EInterchangeMaterialXEDF>())

#Loc: <Workspace>/Engine/Plugins/Interchange/Runtime/Source/Pipelines/Public/InterchangeMaterialXPipeline.h:46

Scope (from outer to inner):

file
class        class UMaterialXPipelineSettings : public UDeveloperSettings

Source code excerpt:


	UPROPERTY(EditAnywhere, config, Category = "MaterialXPredefined | Surface Shaders", meta = (DisplayName = "MaterialX Predefined Surface Shaders"))
	TMap<EInterchangeMaterialXShaders, FSoftObjectPath> PredefinedSurfaceShaders;

	UPROPERTY(EditAnywhere, config, Category = "MaterialXPredefined | BSDF", meta = (DisplayName = "MaterialX Predefined BSDF"))
	TMap<EInterchangeMaterialXBSDF, FSoftObjectPath> PredefinedBSDF;

	UPROPERTY(EditAnywhere, config, Category = "MaterialXPredefined | EDF", meta = (DisplayName = "MaterialX Predefined EDF"))
	TMap<EInterchangeMaterialXEDF, FSoftObjectPath> PredefinedEDF;