BaseMaterialName

BaseMaterialName

#Overview

name: BaseMaterialName

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

#Summary

#Usage in the C++ source code

The purpose of BaseMaterialName is to specify the base material to be used as a template when importing materials, particularly in the context of FBX asset import in Unreal Engine 5.

This setting variable is primarily used by the FBX import system and related UI components in Unreal Engine. It is part of the UFbxTextureImportData class, which is a subclass of UFbxAssetImportData. The main subsystems and modules that rely on this variable include:

  1. DatasmithImporter plugin
  2. Mutable plugin
  3. Interchange Editor module
  4. DetailCustomizations module
  5. MaterialEditor module
  6. UnrealEd module

The value of this variable is typically set through the FBX import UI in the editor. It can be modified by users when importing FBX assets or when adjusting import settings.

BaseMaterialName interacts with several other variables and settings, such as:

  1. bUseBaseMaterial: Determines whether the base material should be used during import.
  2. bImportMaterials: Indicates whether materials should be imported at all.
  3. MaterialImportMethod: Enum that determines how materials are imported (e.g., create new materials, create instanced materials).

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

  1. It is a FSoftObjectPath type, which means it stores a reference to a material asset.
  2. The referenced material should be a valid UMaterialInterface.
  3. It is used in conjunction with other import settings to determine how materials are created during FBX import.

Best practices when using this variable include:

  1. Ensure the referenced base material is appropriate for the type of asset being imported.
  2. Use it in conjunction with the bUseBaseMaterial flag to control whether instanced materials are created.
  3. Be aware of how it interacts with other material import settings to achieve the desired import result.
  4. When programmatically setting this value, ensure the referenced material exists to avoid import errors.
  5. Consider the performance implications of using instanced materials versus creating new materials for large imports.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:699, section: [/Script/UnrealEd.FbxTextureImportData]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Enterprise/DatasmithImporter/Source/DatasmithImporter/Private/Utility/DatasmithImporterUtils.cpp:1163

Scope (from outer to inner):

file
function     TArray<FDatasmithImporterUtils::FFunctionAndMaterialsThatUseIt> FDatasmithImporterUtils::GetOrderedListOfMaterialsReferencedByMaterials

Source code excerpt:

		const TSharedPtr<IDatasmithUEPbrMaterialElement> UEPbrMaterialElement = StaticCastSharedPtr<IDatasmithUEPbrMaterialElement>(BaseMaterialElement);

		FString BaseMaterialName = BaseMaterialElement->GetName();
		uint32 BaseMaterialHash = GetTypeHash(BaseMaterialName);
		MaterialNameMap.FindOrAddByHash(BaseMaterialHash, MoveTemp(BaseMaterialName)) = UEPbrMaterialElement;

		for (int32 MaterialExpressionIndex = 0; MaterialExpressionIndex < UEPbrMaterialElement->GetExpressionsCount(); ++MaterialExpressionIndex)
		{
			if (UEPbrMaterialElement->GetExpression(MaterialExpressionIndex)->IsSubType(EDatasmithMaterialExpressionType::FunctionCall))
			{
				const FString FunctionPathName(StaticCast<IDatasmithMaterialExpressionFunctionCall*>(UEPbrMaterialElement->GetExpression(MaterialExpressionIndex))->GetFunctionPathName());

#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/SCustomizableObjectEditorViewport.cpp:692

Scope (from outer to inner):

file
function     void SCustomizableObjectEditorViewportTabBody::GenerateUVSectionOptions

Source code excerpt:

					const FSkelMeshRenderSection& Section = MeshRes->LODRenderData[LODIndex].RenderSections[SectionIndex];

					FString BaseMaterialName = FString::Printf(TEXT("Section %i"), SectionIndex);

					if (Materials.IsValidIndex(Section.MaterialIndex))
					{
						if (UMaterialInterface* MaterialInterface = Materials[Section.MaterialIndex])
						{
							if (const UMaterial* BaseMaterial = MaterialInterface->GetBaseMaterial())
							{
								BaseMaterialName += " - " + BaseMaterial->GetName();
							}
						}
					}

					UVSectionOptionString.Add(MakeShared<FString>(BaseMaterialName));

					FSection SectionOption;
					SectionOption.ComponentIndex = ComponentIndex;
					SectionOption.SectionIndex = SectionIndex;
					SectionOption.LODIndex = LODIndex;

#Loc: <Workspace>/Engine/Plugins/Interchange/Editor/Source/InterchangeEditor/Private/InterchangeFbxAssetImportDataConverter.cpp:642

Scope (from outer to inner):

file
namespace    UE::Interchange::Private
function     UAssetImportData* ConvertToInterchange

Source code excerpt:

				break;
		}
		if (FbxImportUI->TextureImportData->BaseMaterialName.IsAsset())
		{
			GenericAssetPipeline->MaterialPipeline->MaterialImport = EInterchangeMaterialImportOption::ImportAsMaterialInstances;
			GenericAssetPipeline->MaterialPipeline->ParentMaterial = FbxImportUI->TextureImportData->BaseMaterialName;
		}
		else
		{
			GenericAssetPipeline->MaterialPipeline->MaterialImport = EInterchangeMaterialImportOption::ImportAsMaterials;
			GenericAssetPipeline->MaterialPipeline->ParentMaterial.Reset();
		}

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:648

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::CustomizeDetails

Source code excerpt:

			if(Handle->GetProperty()->GetOwner<UObject>() == UFbxTextureImportData::StaticClass())
			{
				if (Handle->GetProperty()->GetFName() == GET_MEMBER_NAME_CHECKED(UFbxTextureImportData, BaseMaterialName))
				{
					if (ImportUI->bImportMaterials && ImportUI->TextureImportData->bUseBaseMaterial)
					{
						ConstructBaseMaterialUI(Handle, MaterialCategory);
					}
				}

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:750

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::ConstructMaterialImportMethod

Source code excerpt:

void FFbxImportUIDetails::ConstructMaterialImportMethod(TSharedPtr<IPropertyHandle> ImportMaterialPropHandle, IDetailCategoryBuilder& MaterialCategory)
{
	if(ImportUI->TextureImportData->BaseMaterialName.IsValid())
	{
		//When we load the UI the first time we set this boolean to true in case the BaseMaterialName is valid.
		ImportUI->TextureImportData->bUseBaseMaterial = true;
	}

	const UEnum* MaterialImportMethodEnum = StaticEnum< EMaterialImportMethod >();
	SelectedMaterialImportMethod = ImportUI->bImportMaterials
		? (ImportUI->TextureImportData->bUseBaseMaterial ? EMaterialImportMethod::CreateNewInstancedMaterials : EMaterialImportMethod::CreateNewMaterials) 

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:790

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::ConstructBaseMaterialUI

Source code excerpt:

	IDetailPropertyRow &MaterialPropertyRow = MaterialCategory.AddProperty(Handle);
	Handle->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FFbxImportUIDetails::BaseMaterialChanged));
	UMaterialInterface *MaterialInstanceProperty = Cast<UMaterialInterface>(ImportUI->TextureImportData->BaseMaterialName.TryLoad());
	if (MaterialInstanceProperty == nullptr)
	{
		return;
	}
	UMaterial *Material = MaterialInstanceProperty->GetMaterial();
	if (Material == nullptr)

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:1292

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::OnMaterialImportMethodChanged

Source code excerpt:

		//Reset the base material and the UseBaseMaterial flag to hide the base material name property
		ImportUI->TextureImportData->bUseBaseMaterial = false;
		ImportUI->TextureImportData->BaseMaterialName.Reset();
		break;
	case EMaterialImportMethod::CreateNewInstancedMaterials:
		ImportUI->bImportMaterials = true;
		ImportUI->TextureImportData->bUseBaseMaterial = true;
		break;
	case EMaterialImportMethod::DoNotCreateMaterialString:

#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/FbxImportUIDetails.cpp:1302

Scope (from outer to inner):

file
function     void FFbxImportUIDetails::OnMaterialImportMethodChanged

Source code excerpt:

		//Reset the base material and the UseBaseMaterial flag to hide the base material name property
		ImportUI->TextureImportData->bUseBaseMaterial = false;
		ImportUI->TextureImportData->BaseMaterialName.Reset();
		break;
	default:
		break;
	}
	RefreshCustomDetail();
}

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:6529

Scope (from outer to inner):

file
function     void FMaterialEditor::CreateDerivedMaterialInstancesPreviews

Source code excerpt:


				// Provide a special name for landscape MIC's to improve UX, so user will be able to tell which combination is not compiling.
				FString BaseMaterialName = Instance->Parent ? Instance->Parent->GetName() : Instance->GetName();
				FString LayerNames = FString::JoinBy(LandscapeMaterial->GetEditorOnlyStaticParameters().TerrainLayerWeightParameters,
					TEXT(","),
					[](const FStaticTerrainLayerWeightParameter& x) -> FString { return x.LayerName.ToString(); });

				DisplayName = FString::Format(TEXT("{0}({1})"), {*BaseMaterialName, *LayerNames});
			}
			else
			{
				DisplayName = Instance->GetName();
			}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Factories/FbxTextureImportData.h:27

Scope (from outer to inner):

file
class        class UFbxTextureImportData : public UFbxAssetImportData

Source code excerpt:

	/** Base material to instance from when importing materials. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, config, Category = Material, meta = (ImportType = "Mesh", AllowedClasses = "/Script/Engine.MaterialInterface"))
	FSoftObjectPath BaseMaterialName;

	/** transient, ImportUI customize helper to store if we must show or not the BaseMaterialName property. */
	bool bUseBaseMaterial;

	UPROPERTY(BlueprintReadWrite, config, Category = Material, meta = (ImportType = "Mesh"))
	FString BaseColorName;

	UPROPERTY(BlueprintReadWrite, config, Category = Material, meta = (ImportType = "Mesh"))

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Fbx/FbxMainImport.cpp:388

Scope (from outer to inner):

file
namespace    UnFbx
function     void ApplyImportUIToImportOptions

Source code excerpt:

		InOutImportOptions.bInvertNormalMap			= ImportUI->TextureImportData->bInvertNormalMaps;
		InOutImportOptions.MaterialSearchLocation	= ImportUI->TextureImportData->MaterialSearchLocation;
		UMaterialInterface* BaseMaterialInterface	= Cast<UMaterialInterface>(ImportUI->TextureImportData->BaseMaterialName.TryLoad());
		if (BaseMaterialInterface) {
			InOutImportOptions.BaseMaterial			= BaseMaterialInterface;
			InOutImportOptions.BaseColorName		= ImportUI->TextureImportData->BaseColorName;
			InOutImportOptions.BaseDiffuseTextureName = ImportUI->TextureImportData->BaseDiffuseTextureName;
			InOutImportOptions.BaseNormalTextureName = ImportUI->TextureImportData->BaseNormalTextureName;
			InOutImportOptions.BaseEmmisiveTextureName = ImportUI->TextureImportData->BaseEmmisiveTextureName;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/SkinWeightsUtilities.cpp:197

Scope (from outer to inner):

file
function     bool FSkinWeightsUtilities::ImportAlternateSkinWeight

Source code excerpt:

		{
			FbxFactory->ImportUI->TextureImportData->MaterialSearchLocation = EMaterialSearchLocation::DoNotSearch;
			FbxFactory->ImportUI->TextureImportData->BaseMaterialName.Reset();
		}

		TArray<FString> ImportFilePaths;
		ImportFilePaths.Add(AbsoluteFilePath);

		UAssetImportTask* Task = NewObject<UAssetImportTask>();