Stencil Debugger is a new, free, and open-source utility created by software engineer and graphics programmer Alexander Ameye, released under the MIT license. The tool enables developers to visualize the stencil buffer in Unity's Universal Render Pipeline (URP), simplifying the debugging of rendering effects that rely on it.

The stencil buffer is a part of the graphics pipeline that allows developers to control where rendering occurs on the screen. It stores an additional layer of data for each pixel, which can be used to mask or limit rendering to specific regions, enabling advanced effects like shadows, outlines, or special post-processing.

As a practical example, the author used the tool in his own outline shader, which follows this process:

  • 1) The object to be outlined is rendered to a buffer as a colored silhouette, with the stencil value set to 1.
  • 2) The silhouette is then expanded or dilated while preserving the original stencil values. The dilated silhouette does not write to the stencil buffer.
  • 3) Finally, the dilated silhouette is composed with the scene. To remove the original silhouette, rendering is performed only in areas where the stencil value is 0.

Stencil Debugger can be installed in the Unity editor through the Package Manager. It is available via an option that allows the installation of packages from Git URLs.The tool has been tested for compatibility with Unity 2022 and Unity 6, though it currently has some limitations, such as a lack of performance optimization. The author recommends using it in the editor only and avoiding its inclusion in project builds.

For more information, visit the project's page on GitHub.

Blips Game Music Packs

Note: You're leaving the Blips Blog. The visited links may be subject to different privacy and cookie policies.