// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "URP/Effects/Particle/Test/UVflow"
{
	Properties
	{
		_Cutoff( "Mask Clip Value", Float ) = 1
		_MainTex("MainTex", 2D) = "white" {}
		[HDR]_Color("Color", Color) = (0,0.1110165,1,1)
		_Emission("Emission", Float) = 1
		_Noise("Noise", 2D) = "white" {}
		_Vector0("Vector 0", Vector) = (0,0,0,0)
		_Mask("Mask", 2D) = "white" {}
		[Toggle(_MASKONOFF_ON)] _MaskONOFF("Mask ON/OFF", Float) = 1
		_TextureSample0("Texture Sample 0", 2D) = "white" {}
	}

	SubShader
	{
		Tags{ "RenderType" = "Transparent"  "Queue" = "AlphaTest+0" "IsEmissive" = "true"  }
		Cull Off
		Blend SrcAlpha OneMinusSrcAlpha
		
		Pass
	{

		CGPROGRAM
		#include "UnityCG.cginc"
		#pragma target 3.0
		#pragma shader_feature _MASKONOFF_ON

		#pragma vertex vert
		#pragma fragment frag

		#undef TRANSFORM_TEX
		#define TRANSFORM_TEX(tex,name) float4(tex.xy * name##_ST.xy + name##_ST.zw, tex.z, tex.w)

	struct Attributes
	{
		float4 positionOS   : POSITION;
		float4 vertexColor : COLOR;
		float4 texcoord     : TEXCOORD0;
		UNITY_VERTEX_INPUT_INSTANCE_ID
	};

	struct v2f
	{
		float4 vertex : SV_POSITION;
		float4 vertexColor : COLOR;
		float2 uv : TEXCOORD2;
		float4 uv2 : TEXCOORD3;
		UNITY_VERTEX_INPUT_INSTANCE_ID
			UNITY_VERTEX_OUTPUT_STEREO
	};

		 float4 _Color;
		 float _Emission;
		 sampler2D _MainTex;
		 float4 _MainTex_ST;
		 sampler2D _TextureSample0;
		 float4 _Vector0;
		 sampler2D _Mask;
		 float4 _Mask_ST;
		 sampler2D _Noise;
		 float _Cutoff = 1;

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

			o.vertex = UnityObjectToClipPos(v.positionOS);
			o.vertexColor = v.vertexColor;

			o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
			o.uv2.xyzw = TRANSFORM_TEX(v.texcoord, _Mask);

			//VertexPositionInputs vertexInput = GetVertexPositionInputs(v.positionOS.xyz);
			//o.vertex = vertexInput.positionCS;

			return o;
		}

		float4 frag(v2f i) : SV_Target
		{
			UNITY_SETUP_INSTANCE_ID(i);
			UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);

			float2 uv_MainTex = i.uv * _MainTex_ST.xy + _MainTex_ST.zw;
			float2 appendResult38 = (float2(_Vector0.x, _Vector0.y));
			float4 col = (_Color * _Emission * i.vertexColor * tex2D(_MainTex, uv_MainTex) * i.vertexColor.a * tex2D(_TextureSample0, (i.uv + (appendResult38 * _Time.y))));
			col.a = 1;
			//float2 uv_Mask = i.uv_texcoord * _Mask_ST.xy + _Mask_ST.zw;
			float2 appendResult39 = (float2(_Vector0.z, _Vector0.w));
#ifdef _MASKONOFF_ON
			float staticSwitch58 = i.uv2.z;
#else
			float staticSwitch58 = 1.0;
#endif
			clip((tex2D(_Mask, uv_MainTex) + tex2D(_Noise, ((i.uv2).xyzw + float4((_Time.y * appendResult39), 0.0, 0.0)).xy) + staticSwitch58 + i.uv2.w).r - _Cutoff);

			return col;
		}

		ENDCG
		}
	}
}
