
Shader "URP/Effects/Particle/Test/AddMul_SS_Correction" {
    Properties {
        _MainTexture ("MainTexture", 2D) = "white" {}
        _Color ("Color", Color) = (1,1,1,1)
        _EmissiveIntensity ("EmissiveIntensity", Float ) = 4
        _OpacityIntensity ("OpacityIntensity", Float ) = 4
        [MaterialToggle] _HasNoiseEmissive ("HasNoiseEmissive?", Float ) = 0
        _Noise ("Noise", 2D) = "white" {}
        _U_Speed ("U_Speed", Float ) = 0.1
        _V_Speed ("V_Speed", Float ) = 0.15
        _NoisePower ("NoisePower", Float ) = 3
        [MaterialToggle] _HasNoiseOpacity ("HasNoiseOpacity?", Float ) = 0
        _Depth ("Depth", Float ) = 0.2
        [MaterialToggle] _HasOpacityDepth ("HasOpacityDepth?", Float ) = 0
        [MaterialToggle] _HasEmissiveDepth ("HasEmissiveDepth?", Float ) = 0
        _FresnelExp ("FresnelExp", Float ) = 0.5
        [MaterialToggle] _HasOpacityFresnel ("HasOpacityFresnel?", Float ) = 0
        [MaterialToggle] _HasEmissiveFresnel ("HasEmissiveFresnel?", Float ) = 0
        _FresnelPower ("FresnelPower", Float ) = 1.2
        _FinalOpacity ("FinalOpacity", Float ) = 1
        [MaterialToggle] _Is_ScreenSpace ("Is_ScreenSpace?", Float ) = 0
        [MaterialToggle] _HasColorGradient ("HasColorGradient?", Float ) = 0
        _ColorGradient ("ColorGradient", 2D) = "white" {}
        [MaterialToggle] _HasColorGradientMask ("HasColorGradientMask?", Float ) = 0
        _ColorGradientMask ("ColorGradientMask", 2D) = "white" {}
        _ColorMaskIntensity ("ColorMaskIntensity", Float ) = 1
        [MaterialToggle] _IsFirstPanUV1 ("IsFirstPanUV1", Float ) = 0
        _U_Speed_2 ("U_Speed_2", Float ) = 0.1
        _V_Speed_2 ("V_Speed_2", Float ) = 0.15
        _SecondaryNoise ("SecondaryNoise", 2D) = "white" {}
        [MaterialToggle] _HasSecondaryNoise ("HasSecondaryNoise", Float ) = 0
        _SecondaryNoisePower ("SecondaryNoisePower", Float ) = 1
        _IntersectionDepth ("IntersectionDepth", Float ) = 0.25
        [MaterialToggle] _HasIntersectionDepth ("HasIntersectionDepth", Float ) = 0
        _IntersectionColor ("IntersectionColor", Color) = (1,1,1,1)
        _IntersectionStrength ("IntersectionStrength", Float ) = 1
        _IntersectionTexture ("IntersectionTexture", 2D) = "white" {}
        [MaterialToggle] _HasDistortion ("HasDistortion?", Float ) = 0
        [MaterialToggle] _SameDistortionAsOpacity ("SameDistortionAsOpacity?", Float ) = 0
        _DistortionTexture ("DistortionTexture", 2D) = "white" {}
        _DistortionStrength ("DistortionStrength", Float ) = 0.1
        [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    }
    SubShader {
        Tags {
            "IgnoreProjector"="True"
            "Queue"="Transparent"
            "RenderType"="Transparent"
        }
        LOD 200
        GrabPass{ }
        Pass {
            Name "FORWARD"
            Tags {
                //"LightMode"="ForwardBase"
            }
            Blend SrcAlpha OneMinusSrcAlpha
            Cull Off
            ZWrite Off
            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #define UNITY_PASS_FORWARDBASE
            #include "UnityCG.cginc"
            #pragma multi_compile_fwdbase
            #pragma target 3.0
            uniform sampler2D _GrabTexture;
            uniform sampler2D _CameraDepthTexture;
            uniform float4 _TimeEditor;
            uniform sampler2D _MainTexture; uniform float4 _MainTexture_ST;
            uniform float4 _Color;
            uniform float _EmissiveIntensity;
            uniform float _OpacityIntensity;
            uniform fixed _HasNoiseEmissive;
            uniform sampler2D _Noise; uniform float4 _Noise_ST;
            uniform float _U_Speed;
            uniform float _V_Speed;
            uniform float _NoisePower;
            uniform fixed _HasNoiseOpacity;
            uniform float _Depth;
            uniform fixed _HasOpacityDepth;
            uniform fixed _HasEmissiveDepth;
            uniform float _FresnelExp;
            uniform fixed _HasOpacityFresnel;
            uniform fixed _HasEmissiveFresnel;
            uniform float _FresnelPower;
            uniform float _FinalOpacity;
            uniform fixed _Is_ScreenSpace;
            uniform fixed _HasColorGradient;
            uniform sampler2D _ColorGradient; uniform float4 _ColorGradient_ST;
            uniform fixed _HasColorGradientMask;
            uniform sampler2D _ColorGradientMask; uniform float4 _ColorGradientMask_ST;
            uniform float _ColorMaskIntensity;
            uniform fixed _IsFirstPanUV1;
            uniform float _U_Speed_2;
            uniform float _V_Speed_2;
            uniform sampler2D _SecondaryNoise; uniform float4 _SecondaryNoise_ST;
            uniform fixed _HasSecondaryNoise;
            uniform float _SecondaryNoisePower;
            uniform float _IntersectionDepth;
            uniform fixed _HasIntersectionDepth;
            uniform float4 _IntersectionColor;
            uniform float _IntersectionStrength;
            uniform sampler2D _IntersectionTexture; uniform float4 _IntersectionTexture_ST;
            uniform fixed _HasDistortion;
            uniform fixed _SameDistortionAsOpacity;
            uniform sampler2D _DistortionTexture; uniform float4 _DistortionTexture_ST;
            uniform float _DistortionStrength;
            struct VertexInput {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
                float2 texcoord0 : TEXCOORD0;
                float2 texcoord1 : TEXCOORD1;
                float4 vertexColor : COLOR;
            };
            struct VertexOutput {
                float4 pos : SV_POSITION;
                float2 uv0 : TEXCOORD0;
                float2 uv1 : TEXCOORD1;
                float4 posWorld : TEXCOORD2;
                float3 normalDir : TEXCOORD3;
                float4 screenPos : TEXCOORD4;
                float4 vertexColor : COLOR;
                float4 projPos : TEXCOORD5;
            };
            VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
                o.uv0 = v.texcoord0;
                o.uv1 = v.texcoord1;
                o.vertexColor = v.vertexColor;
                o.normalDir = UnityObjectToWorldNormal(v.normal);
                o.posWorld = mul(unity_ObjectToWorld, v.vertex);
                o.pos = UnityObjectToClipPos(v.vertex );
                o.projPos = ComputeScreenPos (o.pos);
                COMPUTE_EYEDEPTH(o.projPos.z);
                o.screenPos = o.pos;
                return o;
            }
            float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
                float isFrontFace = ( facing >= 0 ? 1 : 0 );
                float faceSign = ( facing >= 0 ? 1 : -1 );
                #if UNITY_UV_STARTS_AT_TOP
                    float grabSign = -_ProjectionParams.x;
                #else
                    float grabSign = _ProjectionParams.x;
                #endif
                i.normalDir = normalize(i.normalDir);
                i.normalDir *= faceSign;
                i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
                i.screenPos.y *= _ProjectionParams.x;
                float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
                float3 normalDirection = i.normalDir;
                float sceneZ = max(0,LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)))) - _ProjectionParams.g);
                float partZ = max(0,i.projPos.z - _ProjectionParams.g);
                float4 node_7638 = tex2D(_DistortionTexture,TRANSFORM_TEX(i.uv0, _DistortionTexture));
                float4 node_6236 = tex2D(_MainTexture,TRANSFORM_TEX(i.uv0, _MainTexture));
                float3 node_7726 = (_EmissiveIntensity*(node_6236.rgb*_Color.rgb*i.vertexColor.rgb*i.vertexColor.a));
                float4 node_3262 = _Time + _TimeEditor;
                float2 node_1800 = ((float2(_U_Speed,_V_Speed)*node_3262.g)+lerp( lerp( i.uv0, i.uv1, _IsFirstPanUV1 ), i.screenPos.rg, _Is_ScreenSpace ));
                float4 node_5766 = tex2D(_Noise,TRANSFORM_TEX(node_1800, _Noise));
                float3 node_2541 = pow(node_5766.rgb,_NoisePower);
                float3 _HasNoiseEmissive_var = lerp( node_7726, (node_2541*node_7726), _HasNoiseEmissive );
                float node_7176 = saturate((sceneZ-partZ)/_Depth);
                float3 _HasEmissiveDepth_var = lerp( _HasNoiseEmissive_var, (_HasNoiseEmissive_var*node_7176), _HasEmissiveDepth );
                float node_8690 = pow((1.0 - pow(1.0-max(0,dot(normalDirection, viewDirection)),_FresnelExp)),_FresnelPower);
                float3 _HasEmissiveFresnel_var = lerp( _HasEmissiveDepth_var, (_HasEmissiveDepth_var*node_8690), _HasEmissiveFresnel );
                float4 node_6774 = tex2D(_ColorGradient,TRANSFORM_TEX(i.uv0, _ColorGradient));
                float node_875 = 1.0;
                float4 node_2563 = tex2D(_ColorGradientMask,TRANSFORM_TEX(i.uv0, _ColorGradientMask));
                float3 node_5584 = (lerp( _HasEmissiveFresnel_var, (lerp( node_6774.rgb, lerp(node_6774.rgb,float3(node_875,node_875,node_875),(node_2563.rgb*_ColorMaskIntensity)), _HasColorGradientMask )*_HasEmissiveFresnel_var), _HasColorGradient )*_FinalOpacity);
                float4 node_9192 = tex2D(_IntersectionTexture,TRANSFORM_TEX(i.uv0, _IntersectionTexture));
                float3 _HasIntersectionDepth_var = lerp( node_5584, (((_IntersectionStrength*((1.0 - saturate((sceneZ-partZ)/_IntersectionDepth))*_IntersectionColor.rgb))*node_9192.rgb)+node_5584), _HasIntersectionDepth );
                float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5 + (lerp( float2(0,0), lerp( node_7638.rgb.rg, _HasIntersectionDepth_var.rg, _SameDistortionAsOpacity ), _HasDistortion )*_DistortionStrength);
                float4 sceneColor = tex2D(_GrabTexture, sceneUVs);
////// Lighting:
////// Emissive:
                float3 emissive = _HasIntersectionDepth_var;
                float3 finalColor = emissive;
                float node_5136 = ((node_6236.r*_Color.a*i.vertexColor.a)*_OpacityIntensity);
                float4 node_8329 = _Time + _TimeEditor;
                float2 node_6639 = ((float2(_U_Speed_2,_V_Speed_2)*node_8329.g)+i.uv0);
                float4 node_2432 = tex2D(_SecondaryNoise,TRANSFORM_TEX(node_6639, _SecondaryNoise));
                float _HasNoiseOpacity_var = lerp( node_5136, (lerp( node_2541, ((_SecondaryNoisePower*node_2432.rgb)*node_2541), _HasSecondaryNoise ).r*node_5136), _HasNoiseOpacity );
                float _HasOpacityDepth_var = lerp( _HasNoiseOpacity_var, (_HasNoiseOpacity_var*node_7176), _HasOpacityDepth );
                return fixed4(lerp(sceneColor.rgb, finalColor,(_FinalOpacity*lerp( _HasOpacityDepth_var, (_HasOpacityDepth_var*node_8690), _HasOpacityFresnel ))),1);
            }
            ENDCG
        }
    }
    FallBack "Particles/Additive"
    //CustomEditor "ShaderForgeMaterialInspector"
}
