Invalid parameters GUID

I noticed that during material instances loading a lot of parameter GUIDs are invalid (0,0,0,0).

This may be a problem because the rebinding occurs only if the name and/or the GUID is valid.

If the GUID is invalid and the param name has changed in base material, the overridden value is lost.

I tried to find the function that sets invalid GUIDs and found them: UMaterialInstance::Set***ParameterValueInternal.

The issue happens only if the material instance is saved without it being loaded at least once (since the GUID fix happens in UpdateParameterSet_WithCachedData.

I was wondering if a good way to fix this may be to add in UMaterialInstance::Set***ParameterValueInternal functions a BaseMaterial->FindExpressionByName (to find the first expression with the overridden param name) and set the ParameterValue->ExpressionGUID value to GetParameterExpressionId.

Probably UMaterialEditingLibrary::UpdateMaterialInstance may fix GUIDs too, but maybe it would be better to avoid requiring every functions to call it after the Set***Parameter.

Steps to Reproduce
Create a new UMaterialInstanceConstant and call one of the Set***ParameterValue (such as SetVectorParameterValueInternal). Look at param GUID.

A simple example is to look at vector params of ArrowMaterialYellow in UEngine::InitializeObjectReferences

Hi there,

Thanks for reporting this, I managed to reproduce the issue, and have created a bug report for this.

When I get the public tracking link back from Epic, I will post it here.

My suggested fix for this issue is just to add an UpdateParameter() call in every Set*ParameterValueInternal function. This is the method that handles the fix-up during PostLoad.

I’ve attached a git diff / patch file with the fix.

Regards,

Lance Chaney

Public bug tracker link here: UE-317188

A full UpdateParameters call to fix a single GUID for each new parameter value set won’t be a bit too expensive?

The code doesn’t seem especially complex or expensive and is only run in editor, and only when the parameter is first set. Using UpdateParameters simplifies and centralizes the logic for this. But it is up to Epic whether or not to take this suggested fix, or implement something else.