0

I know when declaring the properties for a shader there are some types of "input": float, range, color, 2D. but when I try to set up a Stencil Operation as a property. how to do this? I mean what I know that Stencil Operation is one of this list (Greater, GEqual, Less, LEqual, Equal, NotEqual, Always, Never) so then how to indicate which op from the editor.

I saw a line like this:

_StencilOp ("Stencil Operation", Float) = 0

so what "0" stands for?

Firas Bz
  • 11
  • 1

1 Answers1

0

The names of the operations correspond to an integer, but it would be tedious to have to remember all the numbers, so we have names. But you can still assign an integer using a variable.

In C# you set an int on the shader using the CompareFunction enum (which is just an int)
MyMaterial.SetInt("_MyStencilOp", (int)CompareFunction.Always);

And in the shader you place the variable like this

Stencil {
            Ref [_PlayerStencilRef]
            Comp [_MyStencilOp]
            Pass Replace
        }

(example modified from here)

Salvatore Ambulando
  • 402
  • 1
  • 6
  • 13