// Shader created with Shader Forge v1.37 
// 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.37;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:1,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,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:True,aust:False,igpj:False,qofs:0,qpre:2,rntp:3,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:630,x:33348,y:32492,varname:node_630,prsc:2|emission-462-OUT,clip-2739-OUT;n:type:ShaderForge.SFN_Tex2d,id:3602,x:32192,y:32727,ptovrint:False,ptlb:Mask,ptin:_Mask,varname:node_3602,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:83d0c25d76f69824c8085cfade4d58e2,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:859,x:32058,y:33057,ptovrint:False,ptlb:Noise,ptin:_Noise,varname:node_859,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:8c4f25816f4cfa64c90e411824696771,ntxv:0,isnm:False|UVIN-6380-OUT;n:type:ShaderForge.SFN_Clamp,id:7526,x:32271,y:33096,varname:node_7526,prsc:2|IN-859-R,MIN-9726-OUT,MAX-373-OUT;n:type:ShaderForge.SFN_Vector1,id:9726,x:32058,y:33216,varname:node_9726,prsc:2,v1:0;n:type:ShaderForge.SFN_Vector1,id:373,x:32058,y:33279,varname:node_373,prsc:2,v1:1;n:type:ShaderForge.SFN_TexCoord,id:6657,x:31532,y:32955,varname:node_6657,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Add,id:6380,x:31880,y:33040,varname:node_6380,prsc:2|A-6657-UVOUT,B-7071-OUT;n:type:ShaderForge.SFN_Append,id:135,x:31472,y:33105,varname:node_135,prsc:2|A-6108-OUT,B-3154-OUT;n:type:ShaderForge.SFN_Multiply,id:7071,x:31647,y:33156,varname:node_7071,prsc:2|A-135-OUT,B-6076-T;n:type:ShaderForge.SFN_Time,id:6076,x:31472,y:33300,varname:node_6076,prsc:2;n:type:ShaderForge.SFN_Multiply,id:2739,x:32897,y:32759,varname:node_2739,prsc:2|A-6281-OUT,B-1415-A;n:type:ShaderForge.SFN_Add,id:1672,x:32460,y:32977,varname:node_1672,prsc:2|A-3602-RGB,B-7526-OUT;n:type:ShaderForge.SFN_Multiply,id:462,x:32593,y:32585,varname:node_462,prsc:2|A-1415-RGB,B-3602-RGB;n:type:ShaderForge.SFN_VertexColor,id:1415,x:32182,y:32550,varname:node_1415,prsc:2;n:type:ShaderForge.SFN_Multiply,id:6281,x:32680,y:32865,varname:node_6281,prsc:2|A-3602-RGB,B-1672-OUT;n:type:ShaderForge.SFN_Slider,id:6108,x:31030,y:33098,ptovrint:False,ptlb:Noise_Uspeed,ptin:_Noise_Uspeed,varname:node_6108,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Slider,id:3154,x:31047,y:33246,ptovrint:False,ptlb:Noise_Vspeed,ptin:_Noise_Vspeed,varname:node_3154,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;proporder:859-3602-6108-3154;pass:END;sub:END;*/

Shader "URP/Effects/Particle/Dissolution" {
    Properties {
        [HDR]_Color ("Color", Color) = (1,1,1,1)
        _Noise ("Noise", 2D) = "white" {}
        _Mask ("Mask", 2D) = "white" {}
        _Noise_Uspeed ("Noise_Uspeed", Float) = 0
        _Noise_Vspeed ("Noise_Vspeed", Float) = 0
        [ToggleOff]_Mask_Change("Mask_Change",Float)=0
        [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    }
    SubShader {
        Tags {
            "Queue"="AlphaTest"
            "RenderType"="TransparentCutout"
        }
        LOD 100
        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_fullshadows
            #pragma multi_compile_fog
            uniform float4 _TimeEditor;
            uniform float3 _Color;
            uniform sampler2D _Mask; uniform float4 _Mask_ST;
            uniform sampler2D _Noise; uniform float4 _Noise_ST;
            uniform float _Noise_Uspeed;
            uniform float _Noise_Vspeed;
            uniform float _Mask_Change;
            struct VertexInput {
                float4 vertex : POSITION;
                float2 texcoord0 : TEXCOORD0;
                float4 vertexColor : COLOR;
            };
            struct VertexOutput {
                float4 pos : SV_POSITION;
                float2 uv0 : TEXCOORD0;
                float4 vertexColor : COLOR;
                UNITY_FOG_COORDS(1)
            };
            VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
                o.uv0 = v.texcoord0;
                o.vertexColor = v.vertexColor;
                o.pos = UnityObjectToClipPos( v.vertex );
                UNITY_TRANSFER_FOG(o,o.pos);
                return o;
            }
            float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
                float isFrontFace = ( facing >= 0 ? 1 : 0 );
                float faceSign = ( facing >= 0 ? 1 : -1 );
                float4 _Mask_var = tex2D(_Mask,TRANSFORM_TEX(i.uv0, _Mask));
                float4 node_6076 = _Time + _TimeEditor;
                float2 node_6380 = (i.uv0+(float2(_Noise_Uspeed,_Noise_Vspeed)*node_6076.g));
                float4 _Noise_var = tex2D(_Noise,TRANSFORM_TEX(node_6380, _Noise));
                float Mask = lerp(_Mask_var.a,_Mask_var.rgb,_Mask_Change);
                clip(((Mask*(_Mask_var.rgb+clamp(_Noise_var.ra,0.0,1.0)))*i.vertexColor.a) - 0.5);
////// Lighting:
////// Emissive:
                float3 emissive = (i.vertexColor.rgb*_Mask_var.rgb);
                float3 finalColor = emissive;
                fixed4 finalRGBA = fixed4(finalColor*_Color,1);
                UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
                return finalRGBA;
            }
            ENDCG
        }
    }
}
