Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Custom Pass - Stencil Masking

Discussion in '2022.2 Beta' started by Grimreaper358, May 13, 2022.

  1. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Now that the stencil option for the custom pass feature in HDRP is now exposed.
    I tried making a cutout effect with it but it seems I'm missing something or maybe it's a bug?
    I did basically the same thing in URP and it worked fine but maybe HDRP requires more.

    The Setup

    I made two Layer Masks

    • Stencil Mask - Object that will do the masking
    • Stencil Show - Object that will be affected by the masks.

    Applied the correct Layer Mask to each object
    • Sphere - Stencil Mask
    • Cube - Stencil Show

    Created a Stencil Shader

    Created a Custom Pass Volume

    Added two Draw Renders Pass
    • One for the masking object
    • Another for the objects that will show the mask
    • Setup the Stencil options
    Created a material from the Stencil Shader

    Added it to the material slot for the Stencil Mask Custom Render Pass


    Result

    upload_2022-5-13_2-46-9.png


    What I'm trying to achieve

     
  2. Sisay

    Sisay

    Joined:
    Dec 6, 2012
    Posts:
    57
    some progress?