See licensee description of the issue:
The problem appears when I have two instanced materials with the same number of parameters. I've noticed that ShaderMapId has MaterialLayersParameterIDs where all LayerIDs are set to 00000000-0000-0000-0000-000000000000. Because of this hash calculated as a DDC key is the same for both different materials and then both materials are using the same shader (which is incorrect). This happens because all StateIds for UMaterialFunctionInstance are initially set to 0 and are never properly generated. I can fix this when I recreate the guid for UMaterialFunctionInstance doing something like this:
void UMaterialFunctionInstance::PostLoad() { Super::PostLoad(); // Here is my change if (!StateId.IsValid()) { StateId = FGuid::NewGuid(); } if (Parent) { Parent->ConditionalPostLoad(); } }
or just set StateId = FGuid::NewGuid();
in a UMaterialFunctionInstance constructor.
Unfortunately, this causes a constant shader compiling during each editor restart. Maybe You guys already have a solution for this problem or can give me some hint on how to fix this properly?
TBC
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-117285 in the post.
1 |
Component | UE - Graphics Features |
---|---|
Affects Versions | 4.26.2, 4.27 |
Target Fix | 5.0 |
Created | Jun 3, 2021 |
---|---|
Resolved | Oct 14, 2021 |
Updated | Nov 30, 2021 |