Nanite flickering issue

I have a flickering issue when I try to replace the material of a mesh at runtime with a masked material.

The problem only occurs when Nanite is enabled on the mesh. It seems to be related to the compilation of the pipeline states,

as it happens during the first material switch, and to reproduce it again I need to close and reopen the application.

It is also reproducible only on PC.

I also tried disabling asynchronous compilation using

r.AsyncPipelineCompile = 0, but that didn’t solve it. I’ve attached the test project that reproduces the issue in 5.6, but it also happened in 5.5.

In the map there is a blueprint actor containing a cylinder mesh, and by pressing the “K” key, the mesh material is switched.

The flicker occurs for a couple of frames both in PIE and in a Win64 build.

Is this a known issue?

Thanks in advance

Simone

Hello there,

It appears that the cause of this is PSO Precache missing the shader, and this would be intended behaviour for that system.

When Precache misses, the proxy is either delayed until the PSO is render or rendered with the default material. By default, the former is chosen, and that is causing the object to disappear briefly.

There are a few possible solutions in 5.6 that I’ll list below.

Firstly, switching to the alternative proxy method may help, but in brief testing, there’s still a flash of the default material.

Secondly, the older FileCache PSO system is still fully functional and works alongside Precache. r.ShaderPipelineCache.ExcludePrecachePSO=1 should cause the FileCache to only cache PSOs missed by PreCache.

Thirdly, if the material is already used in the world, it won’t flash the default material as the Precache has already handled that PSO. Precache collects data in CollectPSOPrecacheData, and this function can be overridden to provide the other material and as an addition entry to the Precache Data. This should cause Precache to schedule it for compilation alongside the applied material once the objects PostLoad is called.

I hope that helps.

Best regards,

Chris

My apologies. As an edit to this: this wasn’t working in Package, and after some more investigation, it doesn’t work without some additional work. I had a use still knocking around that had triggered the mask material inclusion in Precache. The Precache system doesn’t pick up on non-used materials like this. It’s a clever enough system to require the material used by an LOD and that LOD be used for it to precache.

I’ll leave the reply complete below for reference, but do note that it does not work.

Unedited:

Just an update that may work for your use case. Precache should pick up on all MaterialSlots in the mesh, and adding a new material slot with the masked texture seems to give the behaviour without modification to the engine or the components.

[Image Removed]Element 1 is not used by the mesh in any way.

Best regards,

Chris