Material flicker in package game

Hi,

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:

  • diabled texture streaming
  • disabled anti aliasing
  • UseAsOccluder set to false
  • increasing bounds to 1.1

the flickering changes if I move the mouse.

Any help is appreciated!

Thanks

this looks like simple z-fighting. Probably you have 2 polygons which overlaps each other on this floor.

Or 2 floor meshes.

There is just one mesh at this position and it does not happen in PIE. It also does not happen if I am not using any texture at all.

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.

That what I already said - Probably you have 2 polygons which overlaps each other

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.

oh. so you use SetMaterial for a simple Static Mesh actor? What material? Some simple material/instance or dynamic material?

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());

Well, that explains something. At least that generated meshes has some issues with applying materials at runtime )

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.

it could be that this one mesh has duplicate surfaces.

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