Shader "URP/Effects/UI/AdditiveColor Mask Camp_G_UI" {
    Properties {
        [HDR]_TintColor ("Color", Color) = (0.5,0.5,0.5,1)
        _MainTex ("MainTex", 2D) = "white" {}
        _USpeed01 ("U Speed 01", Float ) = 0
        _VSpeed01 ("V Speed 01", Float ) = 0
        _02Tex ("02Tex", 2D) = "white" {}
        _USpeed02 ("U Speed 02", Float ) = 0
        _VSpeed02 ("V Speed 02", Float ) = 0
        _Power ("Power", Range(0, 10)) = 1
        _Mask ("Mask", 2D) = "white" {}
        [MaterialToggle] _Camp ("Camp", Float ) = 0.5
        _EnemyColor ("EnemyColor", Color) = (1,0,0,1)
        [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
        [HideInInspector]_StencilComp("Stencil Comparison", Float) = 8
        [HideInInspector]_Stencil("Stencil ID", Float) = 0
        [HideInInspector]_StencilOp("Stencil Operation", Float) = 0
        [HideInInspector]_StencilWriteMask("Stencil Write Mask", Float) = 255
        [HideInInspector]_StencilReadMask("Stencil Read Mask", Float) = 255

    }
    SubShader {
        Tags {
           "Queue" = "Transparent"
            "IgnoreProjector" = "True"
            "RenderType" = "Transparent"
            "PreviewType" = "Plane"
            "CanUseSpriteAtlas" = "True"
        }
        Stencil {
                Ref[_Stencil]
                ReadMask[_StencilReadMask]
                WriteMask[_StencilWriteMask]
                Comp[_StencilComp]
                Pass[_StencilOp]
            }
        Pass {
            // Name "FORWARD"
            // Tags {
            //     "LightMode"="ForwardBase"
            // }
            Blend SrcAlpha OneMinusSrcAlpha
            Cull Off
            ZWrite Off
            ZTest [unity_GUIZTestMode]
            
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            //#define UNITY_PASS_FORWARDBASE
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            //#pragma multi_compile_fwdbase
             
            #pragma target 3.0
            CBUFFER_START(UnityPerMaterial)
            uniform float4 _TintColor;
            uniform float _USpeed01;
            uniform float _VSpeed01;

            uniform float _USpeed02;
            uniform float _VSpeed02;

            uniform half _Camp;
            uniform float4 _EnemyColor;
            uniform float _Power;
            CBUFFER_END

            // uniform sampler2D _MainTex; 
            // uniform float4 _MainTex_ST;
            // uniform sampler2D _02Tex; 
            // uniform float4 _02Tex_ST;
            // uniform sampler2D _Mask; 
            // uniform float4 _Mask_ST;

            TEXTURE2D(_MainTex);
            SAMPLER(sampler_MainTex);

            TEXTURE2D(_02Tex);
            SAMPLER(sampler_02Tex);

            TEXTURE2D(_Mask);
            SAMPLER(sampler_Mask);

            struct VertexInput {
                float4 vertex : POSITION;
                float2 texcoord0 : TEXCOORD0;
                float4 vertexColor : COLOR;
            };
            struct VertexOutput {
                float4 pos : SV_POSITION;
                float2 uv0 : TEXCOORD0;
                float4 vertexColor : COLOR;
            };
            VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
                o.uv0 = v.texcoord0;
                o.vertexColor = v.vertexColor;
                VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz);
		        o.pos = vertexInput.positionCS;
                //o.pos = UnityObjectToClipPos( v.vertex );

                return o;
            }

            half4 frag(VertexOutput i, float facing : VFACE) : COLOR {
                float isFrontFace = ( facing >= 0 ? 1 : 0 );
                float faceSign = ( facing >= 0 ? 1 : -1 );
////// Lighting:
                float4 node_2388 = _Time;
                float2 node_2628 = (i.uv0+(node_2388.g*float2(_USpeed01,_VSpeed01)));
                float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, node_2628);
                float2 node_3434 = (i.uv0+(node_2388.g*float2(_USpeed02,_VSpeed02)));
                //float4 _02Tex_var = tex2D(_02Tex,TRANSFORM_TEX(node_3434, _02Tex));
                float4 _02Tex_var = SAMPLE_TEXTURE2D(_02Tex, sampler_02Tex, node_3434);;
                //float4 _Mask_var = tex2D(_Mask,TRANSFORM_TEX(i.uv0, _Mask));
                float4 _Mask_var = SAMPLE_TEXTURE2D(_Mask, sampler_Mask, i.uv0);;
                float3 finalColor = (_MainTex_var.rgb*_02Tex_var.rgb*_Power*(lerp( _TintColor.rgb, _EnemyColor.rgb, _Camp )*i.vertexColor.rgb)*_Mask_var.r);
                return half4(finalColor,(_MainTex_var.a*i.vertexColor.a*_TintColor.a*_EnemyColor.a));
            }
            ENDHLSL
        }
    }
    //CustomEditor "ShaderForgeMaterialInspector"
}
