Inverted Normal Studio

Sharp Stencil Shadows

Documentation for Sharp Stencil Shadows, a URP renderer feature for hard, pixel-exact stencil shadow volumes.

Receivers and Materials

Home › Guides

Which surfaces receive shadows

Opaque surfaces receive shadows. Transparent surfaces don't: they render after the shadows are resolved.

Receivers in each lighting mode

Overlay

Every opaque pixel inside a shadow is darkened, regardless of its shader. A material's Receive Shadows setting is ignored.

URP Lighting

Shadows reach receivers through URP's own shadow inputs, so they need a shader that reads them: URP Lit, Simple Lit, Complex Lit, Shader Graph lit materials, and custom shaders using URP's shadow functions. Receive Shadows is respected.

Unlit and Baked Lit

Unlit and Baked Lit materials have no realtime lighting, so they receive shadows in Overlay but not in URP Lighting.

The Sharp Stencil Shadows/Lit shader

The asset's one custom receiver shader. It is URP Lit with the same properties, keywords, and inspector, plus support for colored glass shadows.

When you need it

  • Colored and partial point and spot light shadows from transparent casters (Local Light Transmittance). URP's own lit shaders can only take a single, binary shadow value per point or spot light. See Transparent and Translucent Casters.
  • Point and spot light shadows on classic Deferred without giving those lights a URP Shadow Type. See Lights.

When it helps

  • Colored glass shadows from the sun (Colored Transmittance). The shader tints only direct sunlight, leaving ambient light, other lights, reflections, and emission unchanged. Stock shaders get an approximation. See Colored transmittance for the sun.

Everything else works the same with stock URP shaders.

Switching a material to it

Set the material's Shader to Sharp Stencil Shadows/Lit. Its settings carry over, and switching back to Universal Render Pipeline/Lit restores the original.

Differences from URP Lit

  • Its forward pass is forward-only (UniversalForwardOnly), so on Deferred and Deferred+ renderers it is shaded in the forward pass after the G-buffer. Its other passes are URP Lit's.
  • Transparent materials using it render the same as URP Lit.
  • It contains code adapted from URP. See Legal and Disclosures.

Shadows on the casters themselves

Casters also receive shadows from other casters. Each caster's own volume is cleared from its visible surface (self-shadow cancellation), so it only shows shadows cast onto it.

Cancellation applies to opaque, depth-writing, backface-culled casters with any shader, including Shader Graph and custom shaders. It is skipped for:

  • Shadows Only renderers
  • Skinned Mesh Renderers drawn at a Mesh LOD level above 0, and meshes drawn at such a level that have any submesh skipped here
  • alpha-clipped and transparent materials, which shadow themselves through the caster atlas in Textured mode
  • double-sided materials, and materials with depth writes off

These casters still cast, but their unlit side can show a faceted extra shadow.

Cancellation redraws the caster's mesh as it is imported or skinned. Shaders that move vertices, such as wind or vertex displacement, can leave part of the self-shadow uncancelled.

Terminator shadow fade

In Overlay, a caster's surface already looks dark where it turns away from the light, so another shadow there would darken it twice. Terminator Shadow Fade fades shadows out over that range of surface angles (default 0.2, about 11.5°). Lower values give a harder cutoff. Higher values also soften shadows on surfaces lit at grazing angles.

It applies to caster surfaces eligible for self-shadow cancellation. Other receivers, such as renderers with Cast Shadows off, keep full-strength shadows. URP Lighting doesn't need it, because shadows only remove light.

Fog

Shadows fade into Unity's scene fog (Linear, Exponential, Exponential Squared) the same way the shadowed surface does. In Overlay mode this needs scene depth: while fog is on, the feature requests URP's depth texture, adding a depth copy if the camera has none. Renderers in Tile-Only Mode can't provide it, so their shadows stay unfogged, with one diagnostic.

Fog applied after opaques, such as post-processing or volumetric fog, already covers the shadows.