Quick answer: Add a Render Objects renderer feature to your URP Renderer. Filter by LayerMask. Configure Stencil State (Reference, Pass = Replace, etc.). Shader Graph itself can’t write stencil; the feature does.
Stencil shader trick (mask out a region, render inside-only) requires writing the stencil. Shader Graph doesn’t expose those toggles. Render Objects feature fills the gap.
The Symptom
Stencil-based effect (portal, mirror, mask) doesn’t mask anything. Either the writer doesn’t set the stencil, or the reader doesn’t respect it.
The Fix
Render Objects feature for stencil writes.
URP Renderer Asset:
+ Render Objects (Mask Writer):
Render Pass Event: Before Rendering Opaques
Filter:
Queue: Opaque
Layer Mask: MaskGeometry
Overrides:
Stencil:
Override Stencil: true
Reference Value: 1
Compare Function: Always
Pass Operation: Replace
Fail Operation: Keep
Objects on the MaskGeometry layer now write 1 to the stencil where they render.
Read the stencil in another feature for the masked rendering.
+ Render Objects (Inside Mask Renderer):
Filter: Layer Mask: InsideMaskOnly
Overrides:
Stencil:
Override Stencil: true
Reference Value: 1
Compare Function: Equal
Pass Operation: Keep
Objects render only where stencil = 1.
Verifying
Frame Debugger → Render Objects passes appear in order. Stencil state in the RenderState panel shows your overrides. Final composite shows masked region.
“Render Objects feature owns the stencil. Shader Graph just renders.”
Related Issues
For Renderer Feature blit, see blit pass event. For Render Graph URP 17, see Render Graph URP 17.
Feature writes. Feature reads. Mask works.