Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Adding Stencil Buffer to URP Shader

Discussion in 'Universal Render Pipeline' started by wickedwaring, Apr 20, 2021.

  1. wickedwaring

    wickedwaring

    Joined:
    Feb 5, 2014
    Posts:
    32
    Hi,

    I am new to shader coding, I have managed to get a basic shader to work with a stencil buffer as I need to for our project.

    I have a stencil write shader, and simply read it within my stencil read shader as follows

    [IntRange] _StencilRef ("Stencil Reference Value", Range(0,255)) = 0

    ...

    Stencil {
    Ref [_StencilRef]
    Comp Equal
    }

    A couple of questions -

    a) How would I get hold of the Unity Source for the URP shaders (currently using Lit for starters), so I can add my Stencil code to it? (I will just leave the rest of the code as is)
    b) Is there another method to do this that I am not aware of?

    Thanks for your help,
    Matt
     
    Last edited: Apr 20, 2021