Description

[Link Removed]

Some functions to access parameters don't take into account the newly added runtime static switch parameters. It should be straightforward to fix these up:

void UMaterialInstance::AddParameterValueInternal(const FMaterialParameterInfo& ParameterInfo, const FMaterialParameterMetadata& Meta, EMaterialSetParameterValueFlags Flags)
{
	const bool bUseAtlas = EnumHasAnyFlags(Flags, EMaterialSetParameterValueFlags::SetCurveAtlas);
	const FMaterialParameterValue& Value = Meta.Value;
	FScalarParameterAtlasInstanceData AtlasData;
	switch (Value.Type)
	{
	case EMaterialParameterType::Scalar:
#if WITH_EDITORONLY_DATA
		if (bUseAtlas)
		{
			AtlasData.bIsUsedAsAtlasPosition = Meta.bUsedAsAtlasPosition;
			AtlasData.Atlas = Meta.ScalarAtlas;
			AtlasData.Curve = Meta.ScalarCurve;
		}
#endif // WITH_EDITORONLY_DATA
		ScalarParameterValues.Emplace(ParameterInfo, Value.AsScalar(), AtlasData);
		break;
	case EMaterialParameterType::Vector: VectorParameterValues.Emplace(ParameterInfo, Value.AsLinearColor()); break;
	case EMaterialParameterType::DoubleVector: DoubleVectorParameterValues.Emplace(ParameterInfo, Value.AsVector4d()); break;
	case EMaterialParameterType::Texture: TextureParameterValues.Emplace(ParameterInfo, Value.Texture); break;
	case EMaterialParameterType::Font: FontParameterValues.Emplace(ParameterInfo, Value.Font.Value, Value.Font.Page); break;
	case EMaterialParameterType::RuntimeVirtualTexture: RuntimeVirtualTextureParameterValues.Emplace(ParameterInfo, Value.RuntimeVirtualTexture); break;
	case EMaterialParameterType::SparseVolumeTexture: SparseVolumeTextureParameterValues.Emplace(ParameterInfo, Value.SparseVolumeTexture); break;

	default: checkNoEntry();
	}
}
Steps to Reproduce

[Link Removed]

  1. Create PP material
  2. Add a static switch parameter
  3. Click `Dynamic Branch` on the static switch parameter expression
  4. Crash
Callstack
 	UnrealEditor-Engine.dll!UMaterialInstance::AddParameterValueInternal(const FMaterialParameterInfo & ParameterInfo, const FMaterialParameterMetadata & Meta, EMaterialSetParameterValueFlags Flags) Line 3536	C++
>	UnrealEditor-Engine.dll!UMaterialInstanceDynamic::CopyScalarAndVectorParameters(const UMaterialInterface & SourceMaterialToCopyFrom, ERHIFeatureLevel::Type FeatureLevel) Line 1676	C++
 	UnrealEditor-Engine.dll!UMaterialInterface::OverrideBlendableSettings(FSceneView & View, float Weight) Line 1948	C++
 	UnrealEditor-Engine.dll!FSceneView::OverridePostProcessSettings(const FPostProcessSettings & Src, float Weight) Line 1758	C++
 	UnrealEditor-Engine.dll!DoPostProcessVolume(IInterface_PostProcessVolume * Volume, UE::Math::TVector<double> ViewLocation, FSceneView * SceneView) Line 9250	C++
 	UnrealEditor-Engine.dll!UWorld::AddPostProcessingSettings(UE::Math::TVector<double> ViewLocation, FSceneView * SceneView) Line 9260	C++
 	UnrealEditor-Engine.dll!FSceneView::StartFinalPostprocessSettings(UE::Math::TVector<double> InViewLocation) Line 1884	C++
 	UnrealEditor-UnrealEd.dll!FEditorViewportClient::CalcSceneView(FSceneViewFamily * ViewFamily, const int StereoViewIndex) Line 1325	C++
 	UnrealEditor-UnrealEd.dll!FEditorViewportClient::Draw(FViewport * InViewport, FCanvas * Canvas) Line 4142	C++
 	UnrealEditor-MaterialEditor.dll!FMaterialEditorViewportClient::Draw(FViewport * InViewport, FCanvas * Canvas) Line 121	C++
 	UnrealEditor-Engine.dll!FViewport::Draw(bool bShouldPresent) Line 1854	C++
 	UnrealEditor-UnrealEd.dll!UEditorEngine::UpdateSingleViewportClient(FEditorViewportClient * InViewportClient, const bool bInAllowNonRealtimeViewportToDraw, bool bLinkedOrthoMovement) Line 2412	C++
 	UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 2124	C++
 	UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 531	C++
 	UnrealEditor-FortniteEditor.dll!UFortUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1065	C++
 	UnrealEditor.exe!FEngineLoop::Tick() Line 5823	C++
 	[Inline Frame] UnrealEditor.exe!EngineTick() Line 61	C++
 	UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 188	C++
 	UnrealEditor.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 247	C++
 	UnrealEditor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 298	C++
 	[External Code]	

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-189876 in the post.

1
Login to Vote

Fixed
ComponentUE - Rendering Architecture - Materials
Affects Versions5.2
Target Fix5.5
Fix Commit36113395
CreatedJun 28, 2023
ResolvedSep 9, 2024
UpdatedSep 18, 2024
View Jira Issue