Fading meshes using visibility when inside a mesh with material alpha

Hi, I’m having an issue when using mesh visibility, material alpha and material needDepthPrePass together.

In order to avoid the XY problem I’ll explain what I’m trying to achieve. I have a mesh that has a translucent material and contains other fully opaque meshes. I want the outer material to look like a silhouette but I still want to see the items inside clearly.

When I transition between views I show and hide inner meshes by changing their visibility but when they are obscured by the outer mesh they pop in or out of existence rather than nicely fading.

Here is an example of what’s happening

Here is why I’m using needDepthPrePass to stop the outer mesh looking messy

Maybe @sebavan or @Evgeni_Popov will have some ideas.

You could use smthg like this to ensure your “container” mesh is always rendered after everything else:

sphere.renderingGroupId = 2;
scene.setRenderingAutoClearDepthStencil(2, false, false, false)
1 Like

Amazing thank you!