Shader "URP/Environment/WeatherSystem/Particles/Additive" 
{
	Properties 
	{
		[HideInInspector]
	    _GlobalOpaque("Global Opaque", Range(0,1)) = 1
		[HDR]_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
		_MainTex ("Particle Texture", 2D) = "white" {}
		[Toggle(_X2M_PARTICLE_ALPHA_AS_MASK_ON)]
		_AlphaAsMask("Alpha Channel As Mask",Float) = 0
		[Space(10)]
		[Header(SoftParticles)]
		[Toggle(_X2M_PARTICLE_SOFTPARTICLES_ON)]
		_SoftParticlesOn("Enable"   ,Float)          = 0
		_InvFade("Factor", Range(0.01,3.0)) = 1.0

		[Space(10)]
		[Header(UVAnimation)]
		[Toggle(_UVANIMATION)]
		_UVAnimation("Motion Vertor", Float) = 0
		_MotionVectorTex("MotionVector Texture", 2D) = "white" {}
		_FramePerSec("UV Frame Per Second", Range(0.1,30)) = 10
		_Distortion("Vector Distortion", Range(0.000, 0.1)) = 0.001
		_cycleNum("cycle", Range(0, 30)) = 0
		[HideInInspector]
		_StartTime("Start Time", Float) = 0
		_ElapsedTime("Elapsed Time", Float) = -1

		[Space(10)]
		//[Header(Distance Fade)]
		//[Toggle(_X2M_PARTICLE_DISTANCE_FADE_ON)]
		//_DistanceFadeOn("Distance Fade", Float) = 0
		//_FadeCenter("Fade Center", Range(0.1,3000)) = 500
		//_FadeDistance("Fade Distance", Range(-3000,3000)) = 300

		[Header(UVRotation)]
		[Toggle(_X2M_PARTICLE_UVROTATION_ON)] 
		_UVRotationEnabled("Enable"   ,Float)          = 0 
		_UVRotationOri    ("Rotation" ,Range(0,360))   = 0
		_UVRotationSpeed  ("Speed"    ,Range(-10000,10000))= 0
		_UVRotationPivotU ("Pivot(U)" ,Range(0,1))     = 0.5
		_UVRotationPivotV ("Pivot(V)" ,Range(0,1))     = 0.5
		[Header(UVScroll)]
		[Toggle(_X2M_PARTICLE_UVSCROLL_ON)] 
		_UVScrollEnabled("Enable"  ,Float)         = 0 
		_UVScrollSpeedU ("Speed(U)",Range(-10,10)) = 0
		_UVScrollSpeedV ("Speed(V)",Range(-10,10)) = 0.1

		[Space(4)]
		[Header(Rim Effect)]
		[Toggle(_X2M_PARTICLE_RIM_ON)]
		_RimEnabled("Enable"   ,Float) = 0
		[HDR]_RimColor("Rim Color", Color) = (0,0,0,1)
		_RimPower("Rim Power", Range(0, 5)) = 1.0

		[Header(Flow Effect)]
		[Toggle(_X2M_PARTICLE_FLOW_ON)]
		_FlowEnabled("Enable"   ,Float) = 0
		[NoScaleOffset]_FlowTex("Flow Effect Map", 2D) = "black" {}
		[HDR]_FlowColor("Flow Color", Color) = (1,1,1,1)
		_FlowFactor("Flow Speed(xy),Scaling(zw)",Vector) = (0,1,0.5,0.5)
		_FlowStrength("Flow Strength",Range(0,5)) = 1

		[Header(Mask Effect(Particle Tex))]
		[Toggle(_X2M_PARTICLE_MASK_TEXTURE_ON)]
		_MaskEffectEnabled("Enabled", Float) = 0
		_MaskTex("Mask Texture", 2D) = "white" {}

		[Header(Dissolve)]
		[Toggle(_X2M_PARTICLE_DISSOLVE_ON)]
		_DissolveEnabled("Dissolve Enable"  ,Float)         = 0
		_DissolveTex("Dissolve Tex(A)", 2D) = "white" {}
		_DissolveThreshold("Dissolve Threshold", Range(0, 2)) = 1
   [HDR]_DissolveColor1 ("Dissolve Color1", Color) = (1,0,0,1)
		_DissolveEdgeSize("Dissolve EdgeSize",Range(0,1)) = 0.0
		[Toggle(_X2M_PARTICLE_DISSOLVE_PER_PARTICLE_ON)]
		_DissolvePerParticleEnabled("Dissolve Per Particle"  ,Float) = 0
		_DissolveDelayTime("Dissolve DelayTime"  ,Float) = 0
		_DissolveDuration ("Dissolve Duration"  ,Float) = 0
		[Header(UIParticle)]
		[Toggle(_X2M_PARTICLE_UI_CLIP_RECT_ON)]
		_UIClipRectOn("UI裁剪"  ,Float)         = 0
	}
    SubShader 
	{
		Tags 
		{
			"RenderType"        = "Transparent"
			"Queue"             = "Transparent" 
			"IgnoreProjector"   = "True" 
			"PreviewType"       = "Plane"
			"PerformanceChecks" = "False" 
			"RenderPipeline"    = "LightweightPipeline"
		}

		Blend SrcAlpha One
		ColorMask RGB
		Cull Off 
		Lighting Off 
		ZWrite Off

        Pass 
		{
            HLSLPROGRAM
            #pragma vertex   ParticleUnlitVS
            #pragma fragment ParticleUnlitPS

            #pragma target 2.0
			#pragma prefer_hlslcc gles
            #pragma exclude_renderers d3d11_9x

            //#pragma multi_compile_particles //注释掉: 就禁止关键字SOFT_PARTICLES
			#pragma shader_feature _UVANIMATION
			#pragma shader_feature _X2M_PARTICLE_UVROTATION_ON
			#pragma shader_feature _X2M_PARTICLE_UVSCROLL_ON
			//#pragma shader_feature _X2M_PARTICLE_DISTANCE_FADE_ON
			#pragma shader_feature _X2M_PARTICLE_RIM_ON
			#pragma shader_feature _X2M_PARTICLE_FLOW_ON
			#pragma shader_feature _X2M_PARTICLE_DISSOLVE_ON
			#pragma shader_feature _X2M_PARTICLE_DISSOLVE_PER_PARTICLE_ON
			#pragma shader_feature _X2M_PARTICLE_MASK_TEXTURE_ON
			#pragma shader_feature _X2M_PARTICLE_ALPHA_AS_MASK_ON
			#pragma shader_feature _X2M_PARTICLE_SOFTPARTICLES_ON

			#pragma shader_feature _X2M_PARTICLE_UI_CLIP_RECT_ON

			#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" 
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
			#include "Particle-Unlit.hlsl"

            ENDHLSL
        }
    }
	Fallback "Hidden/X2MErrorShader"
}
