We are trying to add outlines to the objects when the player is close enough to interact with them. To do this we toggle SetRenderCustomDepth(bHighlight) on the primitive component. When the component is non-nanite, it works as expected. On Nanite components, the custom depth outline is toggled randomly.
When looking at the engine code, it looks like the index of the Nanite primitive component sometimes isn’t getting included in the Input.Prims array in FRelevancePacket::ComputeRelevance
This issue isn’t present in the editor. It only happens on packaged builds
Something worth mentioning as well is that if there is an actor that has custom depth constantly enabled, the issue is fixed. Perhaps there is something to do with cached scene infos
Steps to Reproduce
Add a nanite actor in a scene and change its custom depth value at runtime
Hello,
Thank you for reaching out.
I’ve been assigned this issue, and we will be looking into Custom Depth on Nanite components being changed at runtime for you.
We have not been able to reproduce the issues described with the steps provided.
Can you please send us a minimal test project that demonstrates this, and include screenshots of the issue?
The guide for test projects:
[Content removed]
I’ve been looking more into this and it looks like there is a mismatch because the Nanite primitive is sometimes missing from the Input.Prims. When we reach FSceneRenderer::RenderCustomDepthPass() we hit an early return because View.bHasCustomDepthPrimitives is false. However, if we look at the array VisibleCustomDepthPrimitives from FNaniteVisibilityQuery, it is populated with the correct Nanite components that have their custom depth flag enabled.
Hello,
Thank you for this information. We still have not been able to replicate the disconnect between “View.bHasCustomDepthPrimitives” and “FNaniteVisibilityQuery::VisibleCustomDepthPrimitives”.
You can see how “View.bHasCustomDepthPrimitives” is populated via “FRelevancePacket::ComputeRelevance(…)” in SceneVisibility.cpp. It is a long function, so you can search for: “if (ViewRelevance.bRenderCustomDepth)”.
This function also populates an array used in “BuildNaniteCustomDepthDrawList(…)” from CustomDepthRendering.cpp. This function uses both that array and “FNaniteVisibilityQuery::VisibleCustomDepthPrimitives”.
Nanite’s VisibleCustomDepthPrimitives is populated via “PerformNaniteVisibility(…)” from NaniteVisibility.cpp.
There is a known limitation with using custom bit masks with Nanite as well in-case that is part of the problem:
[Content removed]
If you are able to reproduce the issue in a test project that you can share with us, we will be able to help debug the issue as well.
Keep in mind that we don’t receive notifications if questions or replies are edited. We recommend adding new information as a reply, to ensure it is not missed on our end.
Please let us know if this helps.