//Author：AboutVFX
//Email:54315031@qq.com
//QQ Group：156875373
Shader "URP/Effects/Particle/GhostTrail" {
    Properties {
        [HDR]_TintColor ("TintColor", Color) = (0.5,0.5,0.5,0.5)
        _MainTex ("MainTex", 2D) = "white" {}
		_FresnelPower("FresnelPower", Float) = 1
        [HideInInspector]_Opacity ("Opacity", Range(0, 1)) = 1
    }
    SubShader {
        Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
	    Blend SrcAlpha One
	    ColorMask RGB
	    Cull Back Lighting Off ZWrite Off
        Pass {            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
			#include "UnityCG.cginc"
			#include "UnityShaderVariables.cginc"
            uniform sampler2D _MainTex; 
            uniform fixed4 _TintColor;
            uniform fixed _Opacity=1.0;
			uniform half _FresnelPower;
            struct appdata {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
                float3 normal : NORMAL;
            };
            struct v2f {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                float3 worldNormal : TEXCOORD1;
                float3 worldPos : TEXCOORD2;
            };
            v2f vert (appdata v) {
                v2f o;
                o.uv = v.uv;
                o.pos = UnityObjectToClipPos( v.vertex );
				o.worldNormal = UnityObjectToWorldNormal(v.normal);
				o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
                return o;
            }
            float4 frag(v2f i) : SV_Target {
				float3 worldViewDir = UnityWorldSpaceViewDir(i.worldPos);
				half dotResult8 = dot( i.worldNormal , normalize(worldViewDir) );
				half temp_output_13_0 = pow( ( 1.0 - dotResult8 ) , _FresnelPower );
				float4 col;
				col = (tex2D(_MainTex,i.uv)*_TintColor*_TintColor.a*_Opacity);
				col.a *= temp_output_13_0;
                return col;
            }
            ENDCG
        }
    }
}
