Stencil Lights and Shadows


Simple Yet Powerful

Stencil Lights and Shadows brings a flexible shader that uses the stencil buffer to create sharp stylized lights or shadows in realtime. It can be used as a lightweight substitute for realtime point lights or as a complementary effect to achieve stylized visual effects.

Inspired by the techniques used in old-generation consoles, which had strict hardware limitations and required innovative solutions.


✓ Simple to use, realtime, sharp and stylized. It is all just meshes with a material. Everything is made to be used in realtime. Everything can be dynamic and animated. No baking or mapping. Result is always sharp. Use low poly meshes for performance or high poly for smooth curved silhouettes. Works on top of any shader - feel free to use in your project that uses custom shaders. All we do is rendering meshes using a fancy transparent material.

✓ Super performative. More efficient than realtime point lights. Produce realtime effects that otherwise would not be viable in platforms where performance is critical. Performance test included in the package. Use low poly meshes for better performance or high poly for smooth silhouettes. Use LOD to have the best of both worlds of high performance and silhouette vertex resolution. Using multiple colors? Use the vertex colors option to reduce the number of materials per scene and have effect color embedded in each mesh.

✓ Show Volume Option: For those beautiful god rays and spotlights. You can also individually control the volume color, separate from the main effect color.

✓ Unlimited lights per object. Everything is just a mesh. This means that even in forward rendering any number of stencil lights and shadows can affect any given single mesh. Traditionally, forward rendering only supports a limited number of realtime lights per object.

✓ Support non-convex meshes and the camera can enter the mesh: Which are traditionally not supported by naive implementations. Meshes only need to be closed and orientable to work and you can safely move the camera the mesh volume.

✓ Built-in, URP and HDRP Support: Works out of the box for the built-in render pipeline and requires very minimal setup for URP and HDRP. Just add our renderer feature. Upon importing Stencil Lights and Shadows will recompile its shaders and setup all examples to the pipeline being used. You can also manually set the package to any chosen render pipeline in the settings window.

✓ Blend Modes: Stack stencil lights and shadows on top of each other. Combine with traditional realtime lights for hybrid effects. If the simplicity of just “lights” and “shadows” aren't enough for you, Stencil Lights and Shadows includes 16 advanced blending modes.

✓ Everything shown in the demo video and screenshots is included. All examples are included for each and every pipeline.

Documentation and Source Code Included.

✓ All scripts are separated into their appropriate Assembly Definitions.


  • Flat colors only and no texture support. We plan adding support for gradient effects and textures in the future, but this version currently does not support it.
  • No realtime projected shadows, by design. We suggest combining with regular realtime spotlights if you need projected shadows.
  • Stencil Lights and Shadow does not include any mesh modeling, extrusion or projection features. We provide only the shader and meshes used in the examples.
  • If using the built-in render pipeline, having two meshes that use Stencil Lights and Shadow on the exact same world position as each other produces incorrect results (Unity limitation). As a workaround, we suggest offsetting them by a very small delta.

The Package Includes:

  • The "Stencil Lights and Shadows" shaders and a custom material editor GUI to configure and switch between them.
  • All examples listed in the description, including their prefabs, scripts, meshes, textures, materials and custom shaders.
  • Documentation
  • Editor window tool to manually configure the package rendering pipeline.

8 Basic Examples:

  • Hello World
  • Lights And Shadows
  • Base Color
  • Volume
  • LOD
  • Light Count
  • Camera Inside Mesh
  • Non-Convex Meshes

10 Use Case Examples:

  • Moving Light
  • Spotlight
  • Fireflies
  • Window (God Rays)
  • Flickering Flames
  • Hanging Lantern
  • Drop Shadows
  • Fake Shadow
  • Fake Ambient Occlusion
  • Invert Colors VFX

Performance Test:

  • Techniques tested: "traditional realtime lights (with no shadows)" and "Stencil Lights and Shadows"
  • Individual test cases with increasing light count: 8, 16, 32, 64, 128, 256, 521, 1024, 2048 and 4096

16 Advanced Blending Modes:

  • Normal (Opaque)
  • Lighten (Max)
  • Screen (Soft Additive)
  • Color Dodge
  • Linear Dodge (Additive)
  • Darken (Min)
  • Multiply
  • Color Burn
  • Linear Burn
  • 2x Multiply
  • Difference
  • Exclusion
  • Subtract
  • Divide
  • Transparency
  • Premultiplied Transparency