Cook non-determinism in UMaterialInterface::bIncludedInBaseGame

One source of non-determinism in the cooked output is UMaterialInterface::Serialize function updating the bIncludedInBaseGame field. If the material being serialized has an object in a different package as archetype (eg a level being cooked, and archetype in a blueprint), then:

  • if blueprint is cooked first, by the time the level is cooked, the bIncludedInBaseGame in level’s object and archetype will both be true, and delta-serialization would not serialize the value
  • if level is cooked first, the bIncludedInBaseGame for level’s object and the archetype will be different, and delta-serialization would serialize the field

Now, I don’t really understand the purpose of this field - it’s only used in a UMaterialInstance::IsStaticPermutationAllowedForCandidateParent function, and even then only if bEnableRestrictiveMaterialInstanceParents is true; the bEnableRestrictiveMaterialInstanceParents is initialized to false and never written. This makes me think the field can be removed safely?

If not, I believe the correct way to handle that would be to serialize it manually in the Serialize function, and then mark it as transient to make the default property serialization ignore it.

Hi Andrew,

Apologies for the delay in response.

I think your assessment is correct reading through the code, but I also believe your assessment of the method to handle it locally rather than remove entirely would be the way to go. If you remove it entirely it can crash during deserialization if the entry it’s attempting to map to is not there.

Typically we follow a deprecation path for all these items, and increment e.g. FUE5ReleaseStreamObjectVersion and dummy the data, similar to how you’ve described, however if you did that in your local stream, you would end up with a nightmare issue of the UE5 GUID not matching Epics. You could implement your own, but really I think that should be only if you need to make a lot more serialization changes.

I think your proposed changes to handle this manually would be the best approach right now, so I think go with that and please let me know if you need further assistance.

Please note: Epic is on summer break for the next two weeks, so I hope this unblocks you in the meantime, and if any further issues I will address upon my return.

Cheers

Jon

Thanks for the confirmation!