Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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]
    ...
    }

    ...