Shader "URP/Effects/Particle/Outline"
{
	Properties
	{
		[Header(Eunm)]
		[Enum(Alpha,10,Add,1)] _BlendMode("BlendMode", Float) = 10
		[Enum(UnityEngine.Rendering.CullMode)]_CullMode("CullMode", Float) = 0
		[Enum(Off,0,On,1)]_ZWriteMode("ZWriteMode", Float) = 0
		[Header(Main)]
		[HDR]_MainColor("MainColor", Color) = (0.5,0.5,0.5,0.5)
		_MainTex("MainTex", 2D) = "white" {}
		[Header(Move)]
		[Toggle]_MoveSwitch("MoveSwitch", Float) = 1
		_U("U", Float) = 0
		_V("V", Float) = 0
		[HDR]_MoveTexColor("MoveTexColor", Color) = (0.5,0.5,0.5,0.5)
		_MoveTex("MoveTex", 2D) = "white" {}
		_Mask("Mask", 2D) = "white" {}
		[Header(Fresnel)]
		[Toggle]_FresnelSwitch("FresnelSwitch", Float) = 1
		[HDR]_FresnelColor("FresnelColor", Color) = (0.5,0.5,0.5,0.5)
		_FresnelScale("FresnelScale", Float) = 1
		[Header(Dissolution)]
		_Dissolution("Dissolution", 2D) = "black" {}
		_DissolutionColor("DissolutionColor", Color) = (0.5,0.5,0.5,0.5)
	}

		SubShader
	{
		Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }

		CGINCLUDE
		#pragma target 3.0
		ENDCG
		Blend SrcAlpha[_BlendMode]
		Cull[_CullMode]
		ColorMask RGBA
		ZWrite[_ZWriteMode]
		ZTest LEqual

		Pass
		{
			Name "Unlit"
			Tags { "LightweightForward" = "ForwardBase" }
			CGPROGRAM


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


		struct appdata
		{
			float4 vertex : POSITION;
			float4 color : COLOR;
			UNITY_VERTEX_INPUT_INSTANCE_ID
			float4 texcoord : TEXCOORD0;
			half3 normal : NORMAL;
			float4 texcoord1 : TEXCOORD1;
		};

		struct v2f
		{
				float4 vertex : SV_POSITION;
				#ifdef NEEDS_FRAG_WORLD_POSITION
				float3 worldPos : TEXCOORD0;
				#endif
				UNITY_VERTEX_INPUT_INSTANCE_ID
				UNITY_VERTEX_OUTPUT_STEREO
				float4 texcoord1 : TEXCOORD1;
				float4 color : COLOR;
				float4 texcoord2 : TEXCOORD2;
			};

			uniform half _BlendMode;
			uniform half _CullMode;
			uniform half _ZWriteMode;
			uniform sampler2D _MainTex;
			uniform half4 _MainTex_ST;
			uniform half4 _MainColor;
			uniform half _FresnelSwitch;
			uniform half _FresnelScale;
			uniform half4 _FresnelColor;
			uniform half _MoveSwitch;
			uniform sampler2D _MoveTex;
			uniform half4 _MoveTex_ST;
			uniform half _U;
			uniform half _V;
			uniform half4 _MoveTexColor;
			uniform sampler2D _Mask;
			uniform half4 _Mask_ST;
			uniform sampler2D _Dissolution;
			uniform half4 _Dissolution_ST;
			uniform half4 _DissolutionColor;


			v2f vert(appdata v)
			{
				v2f o;
				UNITY_SETUP_INSTANCE_ID(v);
				UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
				UNITY_TRANSFER_INSTANCE_ID(v, o);

				half3 worldNormal = UnityObjectToWorldNormal(v.normal);
				o.texcoord2.xyz = worldNormal;

				o.texcoord1.xy = v.texcoord.xy;
				o.color = v.color;
				o.texcoord1.zw = v.texcoord1.xy;
				o.texcoord2.w = 0;
				float3 vertexValue = float3(0, 0, 0);
				#if ABSOLUTE_VERTEX_POS
				vertexValue = v.vertex.xyz;
				#endif
				vertexValue = vertexValue;
				#if ABSOLUTE_VERTEX_POS
				v.vertex.xyz = vertexValue;
				#else
				v.vertex.xyz += vertexValue;
				#endif
				o.vertex = UnityObjectToClipPos(v.vertex);

				#ifdef NEEDS_FRAG_WORLD_POSITION
				o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
				#endif
				return o;
			}

			fixed4 frag(v2f i) : SV_Target
			{
				UNITY_SETUP_INSTANCE_ID(i);
				UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
				fixed4 finalColor;
				#ifdef NEEDS_FRAG_WORLD_POSITION
				float3 WorldPosition = i.worldPos;
				#endif
				float2 uv_MainTex = i.texcoord1.xy * _MainTex_ST.xy + _MainTex_ST.zw;
				half4 tex2DNode11 = tex2D(_MainTex, uv_MainTex);
				float3 worldViewDir = UnityWorldSpaceViewDir(WorldPosition);
				worldViewDir = normalize(worldViewDir);
				half3 worldNormal = i.texcoord2.xyz;
				half dotResult18 = dot(worldViewDir , worldNormal);
				half2 uv0_MoveTex = i.texcoord1.xy * _MoveTex_ST.xy + _MoveTex_ST.zw;
				half2 appendResult34 = (half2((uv0_MoveTex.x + (_U * _Time.y)) , (uv0_MoveTex.y + (_Time.y * _V))));
				float2 uv_Mask = i.texcoord1.xy * _Mask_ST.xy + _Mask_ST.zw;
				half2 uv192 = i.texcoord1.zw * float2(1,1) + float2(0,0);
				float2 uv_Dissolution = i.texcoord1.xy * _Dissolution_ST.xy + _Dissolution_ST.zw;
				half4 tex2DNode51 = tex2D(_Dissolution, uv_Dissolution);
				half ifLocalVar57 = 0;
				if (uv192.x >= tex2DNode51.r)
				ifLocalVar57 = 1.0;
				else
				ifLocalVar57 = 0.0;
				half ifLocalVar62 = 0;
				if (uv192.x >= (tex2DNode51.r + uv192.y))
				ifLocalVar62 = 1.0;
				else
				ifLocalVar62 = 0.0;
				half temp_output_68_0 = (tex2DNode11.a * ifLocalVar57);
				finalColor = ((((tex2DNode11 * i.color * _MainColor) + ((_FresnelSwitch) ? ((pow((1.0 - dotResult18) , _FresnelScale) * _FresnelColor)) : (float4(0,0,0,0))) + ((_MoveSwitch) ? (((tex2D(_MoveTex, appendResult34) * _MoveTexColor) * tex2D(_Mask, uv_Mask).r)) : (float4(0,0,0,0)))) + ((ifLocalVar57 - ifLocalVar62) * _DissolutionColor)) * temp_output_68_0);
				return finalColor;
			}
			ENDCG
		}
	}
}
