---
title: Stencils
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/manual/visual-effects/stencils
latest_url: https://docs.unity.com/en-us/engine/7000.0/manual/visual-effects/stencils.md
last_updated: 2026-11-21
generated_at: 2026-11-26T14:46:28.707Z
locale: en-us
---

# Stencils

> Use the stencil buffer to mask parts of the screen, in a hand-coded shader or in Shader Graph.

> **Important:**
>
> The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
>
> It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
>
> For more information on migration, refer to [Migrating from the Built-In Render Pipeline to the Universal Render Pipeline](https://docs.unity3d.com/Manual/urp/upgrading-from-birp.html) and [Render pipeline feature comparison](https://docs.unity3d.com/Manual/render-pipelines-feature-comparison.html).

Use the stencil buffer to control which pixels Unity draws, to hide or reveal parts of your project content for effects such as portals, mirrors, and cutaways.

You can check or write to the stencil buffer in a hand-coded shader in any render pipeline. In the Universal Render Pipeline (URP), you can also set stencil options in Shader Graph, without writing code.

| **Topic**                                                                                                                | **Description**                                                                                                                          |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------- |
| [Introduction to the stencil buffer](/engine/7000.0/manual/visual-effects/stencils/introduction-stencil-buffer.md)       | Understand what the stencil buffer is, how the stencil test works, and what to consider when you use stencils in URP.                    |
| [Choose a masking approach](/engine/7000.0/manual/visual-effects/stencils/choose-a-masking-approach.md)                  | Compare the ways to hide or reveal parts of objects, sprites, and UI elements in Unity, and choose the approach that suits your project. |
| [Set stencil options in Shader Graph](/engine/7000.0/manual/visual-effects/stencils/set-stencil-options-shader-graph.md) | Set stencil options in a Lit or Unlit shader graph to check or write to the stencil buffer without writing shader code.                  |

## Render pipeline information

How you work with stencils depends on the render pipeline you use.

| **Feature name** | **Built-In Render Pipeline**                                                                                                                                 | **Universal Render Pipeline (URP)**                                                                                                                                                                                                       | **High Definition Render Pipeline (HDRP)**           | **Custom Scriptable Render Pipeline (SRP)**          |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- |
| **Stencil**      | YesUse the [`Stencil` command](/engine/7000.0/manual/materials-and-shaders/shaders/reference/sl-reference/sl-commands/sl-stencil.md) in a hand-coded shader. | YesUse the `Stencil` command in a hand-coded shader, or [set stencil options in Shader Graph](/engine/7000.0/manual/visual-effects/stencils/set-stencil-options-shader-graph.md). Shader Graph stencil options are available only in URP. | YesUse the `Stencil` command in a hand-coded shader. | YesUse the `Stencil` command in a hand-coded shader. |

## Additional resources

* [Stencil command in ShaderLab reference](/engine/7000.0/manual/materials-and-shaders/shaders/reference/sl-reference/sl-commands/sl-stencil.md)
* [Check or write to the stencil buffer in a shader](/engine/7000.0/manual/materials-and-shaders/shaders/writing-custom/shader-writing/sl/writing-shader-render-state-commands/set-stencil.md)
* [Render Objects Renderer Feature reference for URP](/engine/7000.0/manual/render-pipelines/universal-render-pipeline/customizing-urp/urp-renderer-feature/renderer-feature-render-objects.md)
