Shader "URP/Effects/UI/UI_DissolutionIF"
{
	Properties
	{
		[Enum(Addtive,1,Alpha,10)]_BlendMode("BlendMode", Float) = 1
		[HDR]_MainColor("MainColor", Color) = (1,1,1,1)
		_MainTex("MainTex", 2D) = "white" {}
		_Dissolution("Dissolution", 2D) = "black" {}
		[HDR]_DissColor("DissColor", Color) = (1,1,1,1)
		_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 { "RenderType"="Transparent" "Queue"="Transparent" "PerviewType"="Plane" "IgnoreProjector" = "True" "CanUseSpriteAtlas" = "True"}

		CGINCLUDE
		#pragma target 3.0
		ENDCG
		Blend SrcAlpha [_BlendMode]
		Cull Off
		ColorMask RGBA
		ZWrite Off
		ZTest LEqual
		Stencil
		{
			Ref [_Stencil]
			Comp [_StencilComp]
			Pass [_StencilOp] 
			ReadMask [_StencilReadMask]
			WriteMask [_StencilWriteMask]
		}
		
		Pass
		{
			Name "Unlit"
			Tags { "LightMode"="LightweightForward" }
			CGPROGRAM

			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_instancing
			#include "UnityCG.cginc"
			

		struct appdata
			{
				float4 vertex : POSITION;
				float4 color : COLOR;
			
				float4 texcoord : TEXCOORD0;
				float4 texcoord1 : TEXCOORD1;
			};

			struct v2f
			{
				float4 vertex : SV_POSITION;
	
				float4 texcoord : TEXCOORD0;
				float4 color : COLOR;
				float4 texcoord1 : TEXCOORD1;
			};

			uniform half _BlendMode;
			uniform sampler2D _MainTex;
			uniform half4 _MainTex_ST;
			uniform half4 _MainColor;
			uniform sampler2D _Dissolution;
			uniform half4 _Dissolution_ST;
			uniform half4 _DissColor;
			half _Cutoff;

			v2f vert(appdata v)
			{
				v2f o;
		

				o.texcoord.xy = v.texcoord.xy;
				o.color = v.color;
				o.texcoord1 = v.texcoord1;

				o.texcoord.zw = 0;
				float3 vertexValue = float3(0, 0, 0);
		
				v.vertex.xyz += vertexValue;
		
				o.vertex = UnityObjectToClipPos(v.vertex);
				return o;
			}

			fixed4 frag(v2f i) : SV_Target
			{
		
				fixed4 finalColor;
				float2 uv_MainTex = i.texcoord.xy * _MainTex_ST.xy + _MainTex_ST.zw;
				half4 tex2DNode7 = tex2D(_MainTex, uv_MainTex);
				half4 uv1_MainTex = i.texcoord1;
				uv1_MainTex.xy = i.texcoord1.xy * _MainTex_ST.xy + _MainTex_ST.zw;
				half2 uv0_Dissolution = i.texcoord.xy * _Dissolution_ST.xy + _Dissolution_ST.zw;
				half2 appendResult43 = (half2((uv0_Dissolution.x + (uv1_MainTex.z * _Time.y)) , (uv0_Dissolution.y + (uv1_MainTex.w * _Time.y))));
				half4 tex2DNode12 = tex2D(_Dissolution, appendResult43);
				half ifLocalVar3 = 0;
				if (uv1_MainTex.x >= tex2DNode12.r)
				ifLocalVar3 = 1.0;
				else
				ifLocalVar3 = 0.0;
				half ifLocalVar23 = 0;
				if (uv1_MainTex.x >= (tex2DNode12.r + uv1_MainTex.y))
				ifLocalVar23 = 1.0;
				else
				ifLocalVar23 = 0.0;


				finalColor = ((tex2DNode7 * _MainColor * i.color * ifLocalVar3) + ((ifLocalVar3 - ifLocalVar23) * _DissColor * tex2DNode7.a));
				clip(finalColor.a-_Cutoff);
				return finalColor;
			}
			ENDCG
		}
	}	
}
