I am loading pak files at runtime which contain materials. If loaded during PIE, everything looks good. Loading the materials in package game, results in black flickering of the materials. What I have tried already:
I think there are 2 things that can cause this - z-fighting and some bug with shadows.
If you really sure that there is no 2 overlapping polygons, you can try to play with lightning. Maybe try to disable all shadows and check if this bug appears.
The mesh is fine and when I use a different material, it is ok (see image). And if I add the material to the package game directly, it is also fine. Just when loaded from pak file and applied at runtime, this occurs. But it is not only the wooden material, nearly every material generates this issue - when loaded at runtime.
Yes, I use SetMaterial for a RuntimeMesh. The material from the first screenshots is M_Wood_Floor_Walnut_Worn from Epics Starter Content. I paked it in a single pak file and it is loaded using FStringAssetReference::TryLoad:
FStringAssetReference assetRef(result);
UMaterialInterface* mat = Cast<UMaterialInterface>(assetRef.TryLoad());
No, because the issue only happens when loading the material from pak file. Changing the material at runtime on the runtimemesh works for all materials directly packaged to the game.
I made some progress. I figured out, that the problem vanishes when tesselation is set to “Flat”. Before the material had “No Tesselation” active, which resulted in the reported issues. Now, with tesselation enabled, the result is as expected.
That commonly happens when you have something screwed up with tangent basis of the model. It is defined by UV0 unwrap. Improperly mirrored/flipped UVs can cause that.
To rule out, check the material in question on a mesh, that is provided as starter content(cube).
If confirmed, re-unwrap your floor mesh.
We’re currently experiencing exactly the same thing in Unreal 5.0.3 - we seem to have identified that this seems to affect 5.0.2 and 5.0.3 builds but not 5.0.1