Unity中让shader支持UI的Mask遮罩

Shader "XXX"
{
    Properties
    {
        //MASK SUPPORT ADD
        _StencilComp("Stencil Comparison", Float) = 8
        _Stencil("Stencil ID", Float) = 0
        _StencilOp("Stencil Operation", Float) = 0
        _StencilWriteMask("Stencil Write Mask", Float) = 255
        _StencilReadMask("Stencil Read Mask", Float) = 255
        _ColorMask("Color Mask", Float) = 15
        //MASK SUPPORT END
    }
    SubShader
    {
        //MASK SUPPORT ADD
        Stencil
        {
            Ref[_Stencil]
            Comp[_StencilComp]
            Pass[_StencilOp]
            ReadMask[_StencilReadMask]
            WriteMask[_StencilWriteMask]
        }
        ColorMask[_ColorMask]
        //MASK SUPPORT END
    }
}

你可能感兴趣的:(Unity中让shader支持UI的Mask遮罩)