Outline effect for Nanite meshes?

Hello everyone,

I’ve been using Nanite for quite some time now and today I found out (as stated in the docs), that Nanite meshes are not writing into custom depth/stencils. I don’t want to do a cheap fresnel outline and since Nanite does not support world position offset either, the pushed vertices method can’t be used aswell.So… does anyone have an idea on how to get a decent outline effect for Nanite objects?

Cheers

1 Like

I’m in the same boat as well, you mentioned cheap fresnel outlining? how would one do that with dynamically with nanite meshes?

Well, I use a fresnel node as an emissive output. It doesn’t play well with Lumen, though, since emission writes into final gather. It gives you a “highlighted” look, but it’s not what I am after, personally.

I came up with a hacky workaround for this problem. Instead of using the nanite mesh, I ended up duplicating my mesh in the content browser and disable nanite for that one. I then auto-reduced this mesh to an appropiate tri count and assigned a translucent unlit material with 0 opacity to it (make sure to enable custom depth for that material). Just overlay the duplicated mesh on your nanite mesh and voilâ: You can now have that “proxy” mesh write into custom depth. Hope, this workaround helps!

I suggested another alternative here. Using decals instead of duplicated geometry might be better for performance and might also give more options for customisation.

How would you do outlines with decals?

Let me search real quick …

found it

Edit: watching the video, he also uses custom depth. Let me fiddle real quick

I see. Yes, as you said, this technique works for meshes that can render into custom depth. I am open to more suggestions, but so far, my solution seems to be quite successful. A few intersection errors persist, but I can live with that for the moment.

I got rid of the intersection errors by using Tom Loomans outline shader. Depth culling works a lot better here.

I ended up trying a whole bunch of stuff and the thing that seemed the most promising in regards to using decals was changing “ReceivesDecals” on the mesh and sampling the scene depth/world normal with offset inside the decal material. Using a translucent box would come with the advantage of being able to test for more scene texture data, but overall it doesn’t quite look like using the stencil buffer.
However, if you have a nanite mesh and a regular mesh in the scene, wouldn’t it be better to just to use a standard mesh by itself instead?

I am rendering the nanite mesh in the main pass (at full nanite resolution) and the standard mesh in depth pass only. Standard mesh has been reduced to ~1k tris. I only render it, when the cursor is over the mesh. It’s a simple interaction outline/highlight effect. For me, it works quite well and is efficient enough to not completely destroy the purpose of nanite.

Hello,I find a method that may work in the doc.

Try to Disable Nanite in your actor,and the mesh will render in proxy mesh or you own static mesh.Then use Nanite Pass Switch node or Nanite Override Material to define specialized behavior.I think it will better than the addition mesh method if you have few interaction actor.