Search Unity

Stencil ReadMask as parameter don't work

Discussion in 'Shaders' started by Twil75, Nov 1, 2013.

  1. Twil75

    Twil75

    Joined:
    Aug 30, 2012
    Posts:
    22
    Hi

    I would like to set the stencil ReadMak value as parameter of my shader, but unity say compilation error.

    I set the Ref value as param and it works good, but impossible to set the ReadMask or WriteMask

    Exemple:
    ...
    Properties
    {
    _StencilRef ("Stencil Ref", Float) = 0
    _StencilMask ("Stencil Mask", Float) = 0
    }

    ....
    Stencil
    {
    Ref [_StencilRef] //Work good
    ReadMask [_StencilMask] //Don't work !!
    WriteMask [_StencilMask] //Don't work !!
    Comp NotEqual
    }
    ....

    An idea ?

    Thanks
    Laurent
     
  2. rorylane

    rorylane

    Joined:
    Apr 10, 2013
    Posts:
    22
    Ever get this figured out?
     
  3. ahnafnafee

    ahnafnafee

    Joined:
    May 18, 2020
    Posts:
    7
    This is pretty late but you can do something like this:

    Properties
    {
    [IntRange] _ReadMask ("ReadMask [0:255]", Range( 0 , 255)) = 1
    ...
    }

    ...

    Stencil
    {
    Ref [_StencilRef]
    ReadMask [_ReadMask]
    ...
    }

    ...