Unity Web Shader IDE
Full source <URP>/Shaders/Utils/StencilDitherMaskSeed.shader ShaderLab / HLSL 60 lines 14 symbols 1 includes Hide source Show source
StencilDitherMaskSeed.shader <URP>/Shaders/Utils/StencilDitherMaskSeed.shader
Language
ShaderLab / HLSL
Lines
60
Symbols
14
Includes
1
Open IDE root

<URP>/Shaders/Utils/StencilDitherMaskSeed.shader full source

Shader "Hidden/Universal Render Pipeline/StencilDitherMaskSeed"
{
    Properties
    {
        _StencilRefDitherMask ("StencilRefDitherMask", Int) = 0
        _StencilWriteDitherMask ("StencilWriteDitherMask", Int) = 0
    }

    SubShader
    {
        Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline"}

        Pass
        {
            Name "StencilDitherMaskSeed"

            // -------------------------------------
            // Render State Commands
            ZWrite Off
            ZTest Always
            Blend Off
            Cull Off

            // -------------------------------------
            // Stencil Settings
            Stencil
            {
                Ref [_StencilRefDitherMask]
                WriteMask [_StencilWriteDitherMask]
                CompFront Always
                PassFront Replace
                PassBack Replace
            }

            HLSLPROGRAM
            // -------------------------------------
            // Shader Stages
            #pragma vertex Vert
            #pragma fragment Pixel

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"

            uint _StencilDitherPattern;

            void Pixel(Varyings input)
            {
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

                uint a = (uint)input.positionCS.x & 0x1;
                uint b = (((uint)input.positionCS.y & 0x1) ^ a) << 1;
                if ((a + b) != _StencilDitherPattern)
                    discard;
            }

            ENDHLSL
        }
    }
}