MixedReality-GraphicsTools-Unity
MixedReality-GraphicsTools-Unity copied to clipboard
MeshOutline that works with depth sorting
Describe the problem
It would be really neat to be able to use properly sorted depth with a mesh outline, in order to render hands using a nice outline, like so:
However, it gets wonky when other objects are involved:
Describe the solution you'd like
Out-of-the-box support for mesh outlines that respect depth.
Describe alternatives you've considered
A depth pre-pass/multi-pass shader should be able to do this.
You might be able to solve the issue in the bottom screenshot by rendering the hand at the end of the frame (in the overlay queue or manually with a URP render object feature).
But I agree this should work better out-of-the-box. We'll see if we can come up with a solution!
Related issue: https://github.com/microsoft/MixedRealityToolkit-Unity/issues/9630
Current plan is to add a checkbox to the inspector to automatically enable stencil based workflows.
To mention one important architectural requirement as discussed:
The solution should work without restricting the design of the scene, specifically it should not add requirements to the materials used in the scene.
One way to achieve this may to move the stencil testing functionality shown in the above screenshot on left-hand side (on Gray material) could be moved to a tertiary invisible materials, added by MeshOutline. The primary material of the body could then be untouched whatever it may be.
Totally agree @NorbertNemec, we'll make sure to add an option for a third material in charge of stencil writing.