Inverted Normal Studio

Sharp Stencil Shadows

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

Troubleshooting

Home › Help and Legal

Diagnostics

With Debug > Diagnostics on (the default), the feature logs a warning to the Console for skipped casters, GPU fallbacks, and unsupported configurations. Each problem is reported once, and the message names the object or setting involved. Click a message to select its object.

Debug visualization

Debug > Debug Visualization draws the shadow volumes over the scene, to check a volume's shape, reach, and closure. Toggle it at runtime with SetDebugVisualization.

Common issues

No shadows appear

  • The feature is installed on the renderer the camera uses. Run the installer on the active URP asset.
  • The scene has a directional light that URP uses as its main light. Overlay mode needs one.
  • The URP asset's Main Light > Cast Shadows is on. Without it, Overlay draws no shadows and logs no diagnostic.
  • Casters have Cast Shadows on and are on a layer in Caster Layers.
  • The camera is a base camera, not an overlay camera or XR camera.
  • Stencil Mask is a valid option, and 0x0F or less on Deferred and Deferred+ with Overlay.
  • Check the Console for a diagnostic.

Shadows work in the Editor but not in a player build

  • URP Lighting renderers need a Screen Space Shadows feature. Select the Sharp Stencil Shadows feature on the renderer and click Add Screen Space Shadows, or run the installer again.
  • In URP Lighting, the URP asset must have Main Light > Cast Shadows on, and Additional Lights > Cast Shadows on for point and spot light shadows.
  • Non-readable meshes loaded at runtime need the StencilShadowTopology label. See The topology cache.
  • Check the build log for Sharp Stencil Shadows warnings.

Point or spot lights cast no stencil shadows

  • Lighting Mode is URP Lighting and Max Shadowed Lights is above 0.
  • The light is Realtime or Mixed and on a layer in Light Layers.
  • The light is among the nearest Max Shadowed Lights to the camera.
  • The URP asset uses Per Pixel additional lights with Cast Shadows on.
  • On classic Deferred, see Classic Deferred renderers.

Objects are shadowed twice

Set the light's Shadow Type to No Shadows. URP's own shadow is being drawn under the stencil shadow.

Some objects cast no shadow

  • The object's renderer is disabled, its Cast Shadows is Off, or its layer is outside Caster Layers.
  • It belongs to an LOD Group and isn't in the level that casts: the level the camera draws, or LOD0 with Shadow LOD set to LOD0. A group culled beyond its last level casts nothing.
  • Its shadow falls beyond the URP asset's Shadows > Max Distance.
  • It was spawned since the last discovery scan. Call ShadowCasterDiscovery.RequestRefresh().
  • Its mesh is non-readable and has no cached topology. The Console names the mesh.

A shadow keeps an old shape after a script edits its mesh

Call ShadowVolumeTopologyRegistration.Refresh(mesh) after the edit. See Meshes edited at runtime.

Holes, streaks, or leaks in a shadow

The mesh may have triangles wound backward, or seams that are not exactly coincident. Check the Console for topology warnings, fix the winding, or raise Topology Weld Tolerance slightly. See Mesh Topology. A mesh with many stacked layers can also lose its shadow in places. See Stencil Mask.

Transparent casters cast solid shadows

  • Transparent Casters > Mode is Off.
  • In Uniform Opacity, the renderer mixes opaque and transparent materials. Use Textured.
  • The renderer uses Tile-Only Mode, so Textured falls back to Uniform Opacity.
  • For point and spot lights, partial shadows need Local Light Transmittance and Sharp Stencil Shadows/Lit receivers.

Glass shadows are not colored

In URP Lighting, turn on Colored Transmittance for the sun, and Local Light Transmittance for point and spot lights with Sharp Stencil Shadows/Lit receivers. Sun colors are exact on Sharp Stencil Shadows/Lit receivers and approximate on stock URP shaders.

Shadows disappear on a Deferred renderer

With Overlay, set Stencil Mask to 0x0F or less, because URP's deferred lighting owns the higher bits.

A caster falls back to the CPU

The Console names the renderer and reason. See GPU fallback.

Frequently asked questions

Do I need to add a component to my objects?

No. Mesh Renderers and Skinned Mesh Renderers are found automatically.

Can I use it alongside URP's shadow maps?

In Overlay, point and spot lights can keep URP's shadow maps. In URP Lighting, point and spot lights without stencil shadows have no realtime shadow, except on classic Deferred. See Stencil shadows vs. shadow maps.

Does it support soft shadows?

No. Stencil shadows are always hard.

Does it work on mobile?

Yes, with the CPU backend where compute shaders are unavailable. Start from the Mobile Forward sample asset. See Mobile.

Does it work with the 2D Renderer or XR?

No.

Does it work with Shader Graph materials?

Yes, as casters and receivers. In URP Lighting, receivers must be lit Shader Graph materials.

Does it allocate memory every frame?

Static scenes render without managed allocations once warmed up. Discovery scans allocate periodically, and GPU-deformed casters make a small allocation each frame.