UGUI—让自定义Shader支持ScrollRect遮罩

作者:追风剑情 发布于:2024-4-17 18:55 分类:Shader

转载 https://blog.csdn.net/rcfalcon/article/details/50511574

Shader "Custom/XXXXX"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}

        //添加支持 UGUI ScrollRect 遮罩
        _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
        //END
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Transparent" "IgnoreProjector" = "True" "PreviewType" = "Plane" }
        LOD 100
        ...

        //添加支持 UGUI ScrollRect 遮罩
        Stencil
        {
            Ref [_Stencil]
            Comp [_StencilComp]
            Pass [_StencilOp] 
            ReadMask [_StencilReadMask]
            WriteMask [_StencilWriteMask]
        }
        ColorMask [_ColorMask]
        //END

	...
    }
}

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号