Hey all! I noticed that when Nanite is enabled on a static mesh, using render custom depth will no longer work on that mesh… Is there a work around for this or a setting that I am missing?
The material I am using is a basic highlight/outline material I found while following a tutorial. I will look into the custom depth material and see if I can’t sort anything out, but if anyone has any other feed back, that would be awesome!
I noticed this issue has been fixed in the 5.0 Release
Edit: My mistake. I had changed my configs and updated to 5.0. I was seeing the stencil draw and able to use it in my post process, and I assumed the issue had been fixed. However upon revisiting, it no longer worked. I believe that the nanite meshes were just not rendering with nanite. Likely due to some config I had been playing with.
Here is how to make it invisible in the scene (and invisible in the depth buffer and other buffers like normals, velocity, …) and visible in the stencil buffer only.
For a copied new mesh with disabled nanite:
UE-149879 (Unreal Engine Issues and Bug Tracker (UE-149878)) is updated to be fixed in UE5.1. Since I was playing with UE5.1 Preview 1, I tested displaying custom stencil on nanite-enabled static meshes. I can see that the custom stencil is displayed like a charm! While I don’t think we know the exact timing of UE5.1 release, we now know that it’s a solved problem.
Are you sure about this? I just tried it and stencil/custom depth are still not showing on Nanite meshes. Make sure your project has SM6 on, it’s possible you enabled Nanite but it’s not actually ‘on’.
Thanks for the note. I wasn’t aware of the SM6 setting relevance, and I turned it on in my project. UE5.1 Preview 1 showed at least what I was waiting for, so I would like to share the configurations that I tried.
I created a new project using a template from UE 5.1 Preview 1. I used the Vehicle template. There is no specific reason though.
I changed two project settings: SM6 and Custom Depth-Stencil Pass
I placed a static mesh from Content Browser. The static mesh that I picked up didn’t have nanite enabled, so I enabled it. Then, I changed two settings of the instantiated static mesh by choosing it from the viewport: enabling Render CustomDepth Pass and giving 2 (arbitrary number) to CustomDepth Stencil Value
When I did the same steps in UE5.0.3, the custom stencil wasn’t displayed. Having said that, this is a preview supposed to be unstable, and the configuration space of Unreal Engine is huge in general. So, I am not confident that what I did here is directly relevant to what you are looking for. I hope this posting still helps though.
Hey I tested it again, it definitely doesn’t work with Nanite unfortunately. You need the target RHI to also be set to DX12 for Nanite to work, to check that Nanite is working see if it will show the Nanite overview in the view modes. I guess that the reason it -appears- to be working for you is because your RHI is defaulting to DX11 and thus Nanite isn’t actually enabled in the first place.
It works in 5.1 Release and UE5.1 not support DX11 any more.
Nanite mesh does not support Custom Stencils,but its proxy mesh and the normal static mesh supports it. In some platform that not support Nanite or use disallow Nanite,The Nanite mesh will be convert to normal mesh or proxy mesh.
If it doesn’t work well,the bug is the disallow Nanite function.
The doc describes the situation in Hybrid Non-Nanite and Nanite Content Workflows chapter.
I would really have a great usage of writing to stencil buffers globally for entire CitySample demo full of nanite meshes. Copying mesh (and making it no-nanite), using Nanite Pass Switch seems to be a workaround applicable manually only to some small portion of selected actors, but it seems it is not a good way to go globally with a huge scene like that. My usecase is creating a segmentation masks, where I can controll segmentation classes by simple regexes (classes like: pedestrain, car, building, road, sky, traffic_sign etc.).
Any chance we get this feature implemented in 5.2? Or maybe to get more insights of what needs to be done to make Nanite working with stencils buffer writing. Maybe it is quite easy or moderate difficulty task - so it can be pushed by the community?