// Shader created with Shader Forge v1.38 
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:True,rprd:False,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:2,bsrc:3,bdst:7,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:False,aust:False,igpj:True,qofs:0,qpre:3,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0,fgcg:0,fgcb:0,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:True,fnfb:True,fsmp:False;n:type:ShaderForge.SFN_Final,id:4795,x:32329,y:32511,varname:node_4795,prsc:2|custl-1807-OUT,clip-6559-OUT;n:type:ShaderForge.SFN_Tex2d,id:6074,x:31456,y:32629,ptovrint:False,ptlb:MainTex,ptin:_MainTex,varname:_MainTex,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Multiply,id:2393,x:31716,y:32680,varname:node_2393,prsc:2|A-6074-RGB,B-2053-RGB,C-797-RGB,D-9248-OUT;n:type:ShaderForge.SFN_VertexColor,id:2053,x:31456,y:32800,varname:node_2053,prsc:2;n:type:ShaderForge.SFN_Color,id:797,x:31456,y:32969,ptovrint:True,ptlb:InnerColor,ptin:_TintColor,varname:_TintColor,prsc:2,glob:False,taghide:False,taghdr:True,tagprd:False,tagnsco:False,tagnrm:False,c1:0.5,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Vector1,id:9248,x:31456,y:33122,varname:node_9248,prsc:2,v1:2;n:type:ShaderForge.SFN_Multiply,id:798,x:31716,y:32820,varname:node_798,prsc:2|A-6074-A,B-2053-A,C-797-A;n:type:ShaderForge.SFN_FaceSign,id:668,x:31394,y:32469,varname:node_668,prsc:2,fstp:0;n:type:ShaderForge.SFN_Vector1,id:5482,x:31716,y:32608,varname:node_5482,prsc:2,v1:0.5;n:type:ShaderForge.SFN_OneMinus,id:839,x:31551,y:32469,varname:node_839,prsc:2|IN-668-VFACE;n:type:ShaderForge.SFN_SwitchProperty,id:6436,x:31716,y:32469,ptovrint:False,ptlb:Invert,ptin:_Invert,varname:node_6436,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,on:False|A-839-OUT,B-668-VFACE;n:type:ShaderForge.SFN_If,id:1807,x:31974,y:32635,varname:node_1807,prsc:2|A-6436-OUT,B-5482-OUT,GT-2393-OUT,EQ-2393-OUT,LT-6943-OUT;n:type:ShaderForge.SFN_Color,id:9055,x:31456,y:33203,ptovrint:False,ptlb:OuterColor,ptin:_OuterColor,varname:node_9055,prsc:2,glob:False,taghide:False,taghdr:True,tagprd:False,tagnsco:False,tagnrm:False,c1:0.5,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Multiply,id:6943,x:31716,y:32981,varname:node_6943,prsc:2|A-6074-RGB,B-2053-RGB,C-9055-RGB,D-9248-OUT;n:type:ShaderForge.SFN_If,id:5271,x:31974,y:32871,varname:node_5271,prsc:2|A-6436-OUT,B-5482-OUT,GT-798-OUT,EQ-798-OUT,LT-7081-OUT;n:type:ShaderForge.SFN_Multiply,id:7081,x:31716,y:33147,varname:node_7081,prsc:2|A-6074-A,B-2053-A,C-9055-A;n:type:ShaderForge.SFN_Step,id:6559,x:32145,y:32973,varname:node_6559,prsc:2|A-6096-OUT,B-5271-OUT;n:type:ShaderForge.SFN_Vector1,id:6096,x:32145,y:33094,varname:node_6096,prsc:2,v1:0.1;proporder:6074-797-9055-6436;pass:END;sub:END;*/

Shader "URP/Effects/Particle/DoubleSide" {
    Properties {
        _MainTex ("MainTex", 2D) = "white" {}
        [HDR]_TintColor ("InnerColor", Color) = (0.5,0.5,0.5,1)
        [HDR]_OuterColor ("OuterColor", Color) = (0.5,0.5,0.5,1)
        [MaterialToggle] _Invert ("Invert", Float ) = 0
        [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
        [Toggle]_Specular("Specular", Range(0,1)) = 0
        _SpecColor("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
        _Shininess("Shininess", Range(0.01,2)) = 0.1
        _SpecSmooth("Smoothness", Range(0,1)) = 0.05
    }
    SubShader {
        Tags {
            "IgnoreProjector"="True"
            "Queue"="Transparent"
            "RenderType"="Transparent"
        }
        Pass {
            Name "FORWARD"
            Tags {
               // "LightMode"="ForwardBase"
            }
            Blend SrcAlpha OneMinusSrcAlpha
            Cull Off
            
            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #define UNITY_PASS_FORWARDBASE
            #include "UnityCG.cginc"
            #pragma multi_compile_fwdbase
            uniform sampler2D _MainTex; uniform float4 _MainTex_ST;
            uniform float4 _TintColor;
            uniform fixed _Invert;
            uniform float4 _OuterColor;
            uniform float4 _SpecColor;
            uniform float _SpecSmooth;
            uniform float _Shininess;
            uniform float _Specular;
            struct VertexInput {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
                float2 texcoord0 : TEXCOORD0;
                float4 vertexColor : COLOR;
            };
            struct VertexOutput {
                float4 pos : SV_POSITION;
                float2 uv0 : TEXCOORD0;
                float4 vertexColor : COLOR;
                half posW : TEXCOORD1;
            };
            VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
                o.uv0 = v.texcoord0;
                o.vertexColor = v.vertexColor;
                o.pos = UnityObjectToClipPos( v.vertex );
                float3 viewDir = ObjSpaceViewDir(v.vertex);
                o.posW = dot(normalize(v.normal), normalize(viewDir));
                return o;
            }
            float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
                float isFrontFace = ( facing >= 0 ? 1 : 0 );
                float faceSign = ( facing >= 0 ? 1 : -1 );
                float _Invert_var = lerp( (1.0 - isFrontFace), isFrontFace, _Invert );
                float node_5482 = 0.5;
                float node_5271_if_leA = step(_Invert_var,node_5482);
                float node_5271_if_leB = step(node_5482,_Invert_var);
                float4 _MainTex_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
                float node_798 = (_MainTex_var.a*i.vertexColor.a*_TintColor.a);
                clip(step(0.1,lerp((node_5271_if_leA*(_MainTex_var.a*i.vertexColor.a*_OuterColor.a))+(node_5271_if_leB*node_798),node_798,node_5271_if_leA*node_5271_if_leB)) - 0.5);
////// Lighting:
                float node_1807_if_leA = step(_Invert_var,node_5482);
                float node_1807_if_leB = step(node_5482,_Invert_var);
                float node_9248 = 2.0;
                float3 node_2393 = (_MainTex_var.rgb*i.vertexColor.rgb*_TintColor.rgb*node_9248);
                float3 finalColor = lerp((node_1807_if_leA*(_MainTex_var.rgb*i.vertexColor.rgb*_OuterColor.rgb*node_9248))+(node_1807_if_leB*node_2393),node_2393,node_1807_if_leA*node_1807_if_leB);
                float ndh = max(0, i.posW);
                float spec = pow(ndh, _Shininess * 128.0) * 2.0;
                spec = smoothstep(0.5 - _SpecSmooth * 0.5, 0.5 + _SpecSmooth * 0.5, spec);
                finalColor += lerp(0,spec * _SpecColor,_Specular); 
                return fixed4(finalColor,1);
            }
            ENDCG
        }
    }
    //CustomEditor "ShaderForgeMaterialInspector"
}
