Different Method of Highlighting Occluded Meshes?

I’ve done some digging on stencil meshes and how to properly show the silhouette of an object behind other objects. There are some topics on it, but none of the solutions I have found do what I really want.

I’m really close to a solution https://playground.babylonjs.com/#R6Q40J#2, but this creates a small ring artifact on the part of the mesh I want to highlight. Would there be a better way to do this that would not cause that artifact?

One idea I was testing was trying to make a custom Material for the meshes that will be highlighted and to scale them down, but was struggling to get the correct depth values displaying on that material. You can see those sections commented out.

Anybody have any ideas how to do this better, I have a feeling it will include the stencil pass which I have limited knowledge about and am trying to understand better.

1 Like

Figured out what was causing the artifacts, I had to resize the depth textures when the scene resized.

1 Like

I actually think this method is better, that way you can keep the color of the occluded mesh and dont have to use a post pass of any kind.