Search Unity

[solved] Help with stencil shader

Discussion in 'Shaders' started by TitoOliveira, Nov 29, 2019.

  1. TitoOliveira

    TitoOliveira

    Joined:
    Aug 4, 2014
    Posts:
    79
    I have this quad that is writing to the stencil buffer, which is my stencil mask. Over to the right there is an opaque cube that is working as intended, the quad masks it.

    At the bottom i have a water shader that has a gradient color based on depth. But the quad is messing with the effect. I thought it would simply be ignored, since it doesn't do any stencil stuff, but i guess the screen depth information accounts for it. Not sure how could i ignore it.

    And at the left i have an additive particle effect that reads the stencil just like the cube does. But it only gets masked correctly by the quad if the particle effect is in front of it. When i move them behind the mask, they get occluded. What's up with that?

    Thanks for the help

     
  2. TitoOliveira

    TitoOliveira

    Joined:
    Aug 4, 2014
    Posts:
    79
    All problems were solved by disabling receive and cast shadows on the Stencil Mask shader
     
  3. great04

    great04

    Joined:
    Apr 14, 2021
    Posts:
    3
    Hi Tito,

    I ran into similar problem, the model shows through stencil but particle system does not. My Stencil Mask Shader doesn't have shadow setting. Any help is appreciated!

    Shader script:
    Code (CSharp):
    1. Shader "Unlit/Mask"
    2. {
    3.     Properties
    4.     {
    5.  
    6.     }
    7.     SubShader
    8.     {
    9.         Tags
    10.         {
    11.             "RenderType"="Transparent"
    12.         }
    13.  
    14.         Pass
    15.         {
    16.             Blend Zero One
    17.             ZWrite Off
    18.         }
    19.     }
    20. }