[HOWTO] Object Outline Postprocess material with occlusion (stencil based)

Built this for someone on the RealtimeVFX Discord earlier, thought I’d share it here for posterity:

In this example, when this postprocess material is added to your scene or camera, any mesh with Custom Depth enabled and Stencil Value = 5 will get a red outline.


Works perfectly!

TIP: Remember set “Custom Depth-Stencil Pass” to “Enabled with Stencil” in Project Settings → Rendering.