PredefinedVDF

PredefinedVDF

#Overview

name: PredefinedVDF

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 PredefinedVDF is to store a mapping between predefined Volume Distribution Functions (VDFs) in MaterialX and their corresponding asset paths in Unreal Engine. This setting variable is part of the MaterialX pipeline in the Interchange system, which is responsible for importing and converting MaterialX data into Unreal Engine materials.

The Unreal Engine subsystem that relies on this setting variable is the Interchange system, specifically the MaterialX pipeline module. This is evident from the file locations where the variable is referenced, which are all within the Interchange plugin’s source code.

The value of this variable is set in two ways:

  1. Through configuration files, as indicated by the config specifier in the property declaration.
  2. Programmatically in the InitPredefinedAssets() function, which is called when the Substrate system is enabled.

This variable interacts with other similar variables such as PredefinedSurfaceShaders, PredefinedBSDF, and PredefinedEDF, which together form a complete set of mappings for different types of MaterialX nodes to Unreal Engine assets.

Developers must be aware of the following when using this variable:

  1. It is part of the UMaterialXPipelineSettings class, which inherits from UDeveloperSettings.
  2. The variable is used during the MaterialX import process to map MaterialX VDF nodes to corresponding Unreal Engine assets.
  3. The mapping can be customized through the editor UI or configuration files.

Best practices when using this variable include:

  1. Ensure that all referenced assets are properly loaded before using the MaterialX pipeline.
  2. When adding or modifying entries, make sure the asset paths are valid and point to appropriate VDF implementations in Unreal Engine.
  3. Consider the performance implications of loading many predefined assets, especially for large projects.
  4. Keep the mapping up-to-date with any changes in the MaterialX standard or Unreal Engine’s material system.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Plugins/Interchange/Runtime/Config/BaseInterchange.ini:64, 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:138

Scope (from outer to inner):

file
function     void FInterchangeMaterialXPipelineSettingsCustomization::CustomizeDetails

Source code excerpt:

			  UE::Interchange::MaterialX::IndexEDF);

	Customize(GET_MEMBER_NAME_CHECKED(UMaterialXPipelineSettings, PredefinedVDF),
			  TEXT("MaterialXPredefined | VDF"),
			  NSLOCTEXT("InterchangeMaterialXPipelineSettingsCustomization", "MaterialXPredefined | VDF", "Volume Distribution Functions"),
			  UE::Interchange::MaterialX::IndexVDF);
}

bool FInterchangeMaterialXPipelineSettingsCustomization::OnShouldFilterAssetEnum(const FAssetData& InAssetData, uint8 EnumType, uint8 EnumValue)

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

Scope (from outer to inner):

file
function     UInterchangeMaterialXPipeline::UInterchangeMaterialXPipeline

Source code excerpt:

	}

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

void UInterchangeMaterialXPipeline::AdjustSettingsForContext(EInterchangePipelineContext ImportType, TObjectPtr<UObject> ReimportAsset)

#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:848

Scope (from outer to inner):

file
function     void UMaterialXPipelineSettings::InitPredefinedAssets

Source code excerpt:

				else if(ShadersSettings.IsType<EInterchangeMaterialXVDF>())
				{
					PredefinedVDF.Add(ShadersSettings.Get<EInterchangeMaterialXVDF>(), FSoftObjectPath{ Mapping.Get<2>() });
				}
			}
		}
	}
}
#endif // WITH_EDITOR

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

Scope (from outer to inner):

file
function     FString UMaterialXPipelineSettings::GetAssetPathString

Source code excerpt:

	else if(EnumValue.IsType<EInterchangeMaterialXVDF>())
	{
		return FindAssetPathString(PredefinedVDF, EnumValue.Get<EInterchangeMaterialXVDF>());
	}

	return {};
}

#if WITH_EDITOR

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

Scope (from outer to inner):

file
class        class UMaterialXPipelineSettings : public UDeveloperSettings

Source code excerpt:


	UPROPERTY(EditAnywhere, config, Category = "MaterialXPredefined | VDF", meta = (DisplayName = "MaterialX Predefined VDF"))
	TMap<EInterchangeMaterialXVDF, FSoftObjectPath> PredefinedVDF;

#if WITH_EDITOR
	/** Init the Predefined with Substrate assets, since the default value is set in BaseInterchange.ini and we have no way in the config file to conditionally init a property*/
	void InitPredefinedAssets();

private: