// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "MudBun/Floater Splat (Built-In RP)"
{
	Properties
	{
		[HideInInspector]_Color("Color", Color) = (1,1,1,1)
		[HideInInspector]_Emission("Emission", Color) = (1,1,1,1)
		[HideInInspector]_Metallic("Metallic", Range( 0 , 1)) = 0
		[HideInInspector]_Smoothness("Smoothness", Range( 0 , 1)) = 1
		_Frequency("Frequency", Range( 0 , 1)) = 0.1
		_OffsetAmount("Offset Amount", Float) = 0.01
		_MainTex("Albedo", 2D) = "white" {}
		_AlphaCutoutThreshold("Alpha Cutout Threshold", Range( 0 , 1)) = 0
		_Dithering("Dithering", Range( 0 , 1)) = 1
		[Toggle]_RandomDither("Random Dither", Range( 0 , 1)) = 0
		_DitherTexture("Dither Texture", 2D) = "white" {}
		_DitherTextureSize("Dither Texture Size", Int) = 256
		[HideInInspector] __dirty( "", Int ) = 1
	}

	SubShader
	{
		Tags{ "RenderType" = "TransparentCutout"  "Queue" = "Geometry+0" "IsEmissive" = "true"  }
		Cull Back
		CGPROGRAM
		#include "UnityShaderVariables.cginc"
		#include "UnityCG.cginc"
		#pragma target 3.5
		#pragma shader_feature_local MUDBUN_QUAD_SPLATS
		#define SHADER_GRAPH
		#include "Assets/MudBun/Shader/Render/ShaderCommon.cginc"
		#include "Assets/MudBun/Shader/Render/SplatCommon.cginc"
		#pragma exclude_renderers d3d9 gles metal 
		#pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc 

		struct appdata_full_custom
		{
			float4 vertex : POSITION;
			float4 tangent : TANGENT;
			float3 normal : NORMAL;
			float4 texcoord : TEXCOORD0;
			float4 texcoord1 : TEXCOORD1;
			float4 texcoord2 : TEXCOORD2;
			float4 texcoord3 : TEXCOORD3;
			fixed4 color : COLOR;
			UNITY_VERTEX_INPUT_INSTANCE_ID
			uint ase_vertexId : SV_VertexID;
		};
		struct Input
		{
			float2 vertexToFrag34_g277;
			float4 vertexToFrag3_g277;
			float3 vertexToFrag20_g277;
			float3 vertexToFrag27_g281;
			uint ase_vertexId;
			float3 vertexToFrag11_g277;
			float vertexToFrag2_g277;
			float vertexToFrag14_g277;
		};

		uniform float _Frequency;
		uniform float _OffsetAmount;
		uniform sampler2D _MainTex;
		uniform sampler2D _DitherTexture;
		uniform int _DitherTextureSize;
		uniform float _RandomDither;
		uniform float _AlphaCutoutThreshold;
		uniform float _Dithering;


		float3 MudBunSplatPoint( int VertexID, out float3 PositionLs, out float3 NormalWs, out float3 NormalLs, out float3 TangentWs, out float3 TangentLs, out float3 CenterWs, out float3 CenterLs, out float4 Color, out float4 EmissionHash, out float Metallic, out float Smoothness, out float2 Tex, out float4 TextureWeight )
		{
			float4 positionWs;
			float2 metallicSmoothness;
			mudbun_splat_vert(VertexID, positionWs, PositionLs, NormalWs, NormalLs, TangentWs, TangentLs, CenterWs, CenterLs, Color, EmissionHash, metallicSmoothness, Tex, TextureWeight);
			Metallic = metallicSmoothness.x;
			Smoothness = metallicSmoothness.y;
			return positionWs.xyz;
		}


		float3 SimplexNoiseGradient6_g279( float3 Position, float Size )
		{
			#ifdef MUDBUN_VALID
			return snoise_grad(Position / max(1e-6, Size)).xyz;
			#else
			return Position;
			#endif
		}


		float3 SimplexNoiseGradient6_g280( float3 Position, float Size )
		{
			#ifdef MUDBUN_VALID
			return snoise_grad(Position / max(1e-6, Size)).xyz;
			#else
			return Position;
			#endif
		}


		void vertexDataFunc( inout appdata_full_custom v, out Input o )
		{
			UNITY_INITIALIZE_OUTPUT( Input, o );
			int VertexID5_g277 = v.ase_vertexId;
			float3 PositionLs5_g277 = float3( 0,0,0 );
			float3 NormalWs5_g277 = float3( 0,0,0 );
			float3 NormalLs5_g277 = float3( 0,0,0 );
			float3 TangentWs5_g277 = float3( 0,0,0 );
			float3 TangentLs5_g277 = float3( 0,0,0 );
			float3 CenterWs5_g277 = float3( 0,0,0 );
			float3 CenterLs5_g277 = float3( 0,0,0 );
			float4 Color5_g277 = float4( 0,0,0,0 );
			float4 EmissionHash5_g277 = float4( 0,0,0,0 );
			float Metallic5_g277 = 0.0;
			float Smoothness5_g277 = 0.0;
			float2 Tex5_g277 = float2( 0,0 );
			float4 TextureWeight5_g277 = float4( 1,0,0,0 );
			float3 localMudBunSplatPoint5_g277 = MudBunSplatPoint( VertexID5_g277 , PositionLs5_g277 , NormalWs5_g277 , NormalLs5_g277 , TangentWs5_g277 , TangentLs5_g277 , CenterWs5_g277 , CenterLs5_g277 , Color5_g277 , EmissionHash5_g277 , Metallic5_g277 , Smoothness5_g277 , Tex5_g277 , TextureWeight5_g277 );
			float3 temp_output_86_52 = TangentWs5_g277;
			float3 temp_output_86_60 = CenterWs5_g277;
			float3 Position6_g279 = temp_output_86_60;
			float Size6_g279 = 0.1;
			float3 localSimplexNoiseGradient6_g279 = SimplexNoiseGradient6_g279( Position6_g279 , Size6_g279 );
			float3 Position6_g280 = ( temp_output_86_60 + ( _Time.y * _Frequency ) + ( localSimplexNoiseGradient6_g279 * 1.0 ) );
			float Size6_g280 = 0.5;
			float3 localSimplexNoiseGradient6_g280 = SimplexNoiseGradient6_g280( Position6_g280 , Size6_g280 );
			float3 temp_output_66_0 = ( localSimplexNoiseGradient6_g280 * _OffsetAmount );
			float3 temp_output_86_28 = NormalWs5_g277;
			v.vertex.xyz = ( localMudBunSplatPoint5_g277 + ( temp_output_86_52 * (temp_output_66_0).x ) + ( cross( temp_output_86_28 , temp_output_86_52 ) * (temp_output_66_0).z ) );
			v.vertex.w = 1;
			v.normal = temp_output_86_28;
			o.vertexToFrag34_g277 = Tex5_g277;
			o.vertexToFrag3_g277 = Color5_g277;
			o.vertexToFrag20_g277 = localMudBunSplatPoint5_g277;
			o.vertexToFrag27_g281 = temp_output_86_28;
			o.ase_vertexId = v.ase_vertexId;
			o.vertexToFrag11_g277 = (EmissionHash5_g277).xyz;
			o.vertexToFrag2_g277 = Metallic5_g277;
			o.vertexToFrag14_g277 = Smoothness5_g277;
		}

		void surf( Input i , inout SurfaceOutputStandard o )
		{
			float2 clampResult36_g277 = clamp( ( i.vertexToFrag34_g277 + float2( 0.5,0.5 ) ) , float2( 0,0 ) , float2( 1,1 ) );
			#ifdef MUDBUN_QUAD_SPLATS
				float staticSwitch50_g277 = 0.0;
			#else
				float staticSwitch50_g277 = length( i.vertexToFrag34_g277 );
			#endif
			clip( 0.5 - staticSwitch50_g277);
			float4 temp_output_69_0 = ( tex2D( _MainTex, clampResult36_g277 ) * ( _Color * i.vertexToFrag3_g277 ) );
			float localComputeOpaqueTransparency20_g281 = ( 0.0 );
			float4 unityObjectToClipPos17_g277 = UnityObjectToClipPos( i.vertexToFrag20_g277 );
			float4 computeScreenPos18_g277 = ComputeScreenPos( unityObjectToClipPos17_g277 );
			float2 ScreenPos20_g281 = (( ( computeScreenPos18_g277 / (computeScreenPos18_g277).w ) * _ScreenParams )).xy;
			float3 VertPos20_g281 = i.vertexToFrag27_g281;
			int VertexID5_g277 = i.ase_vertexId;
			float3 PositionLs5_g277 = float3( 0,0,0 );
			float3 NormalWs5_g277 = float3( 0,0,0 );
			float3 NormalLs5_g277 = float3( 0,0,0 );
			float3 TangentWs5_g277 = float3( 0,0,0 );
			float3 TangentLs5_g277 = float3( 0,0,0 );
			float3 CenterWs5_g277 = float3( 0,0,0 );
			float3 CenterLs5_g277 = float3( 0,0,0 );
			float4 Color5_g277 = float4( 0,0,0,0 );
			float4 EmissionHash5_g277 = float4( 0,0,0,0 );
			float Metallic5_g277 = 0.0;
			float Smoothness5_g277 = 0.0;
			float2 Tex5_g277 = float2( 0,0 );
			float4 TextureWeight5_g277 = float4( 1,0,0,0 );
			float3 localMudBunSplatPoint5_g277 = MudBunSplatPoint( VertexID5_g277 , PositionLs5_g277 , NormalWs5_g277 , NormalLs5_g277 , TangentWs5_g277 , TangentLs5_g277 , CenterWs5_g277 , CenterLs5_g277 , Color5_g277 , EmissionHash5_g277 , Metallic5_g277 , Smoothness5_g277 , Tex5_g277 , TextureWeight5_g277 );
			float Hash20_g281 = (EmissionHash5_g277).w;
			float AlphaIn20_g281 = (( _Color * i.vertexToFrag3_g277 )).a;
			float AlphaOut20_g281 = 0;
			float AlphaThreshold20_g281 = 0;
			sampler2D DitherNoiseTexture20_g281 = _DitherTexture;
			int DitherNoiseTextureSize20_g281 = _DitherTextureSize;
			int UseRandomDither20_g281 = (int)_RandomDither;
			float AlphaCutoutThreshold20_g281 = _AlphaCutoutThreshold;
			float DitherBlend20_g281 = _Dithering;
			float alpha = AlphaIn20_g281;
			computeOpaqueTransparency(ScreenPos20_g281, VertPos20_g281, Hash20_g281, DitherNoiseTexture20_g281, DitherNoiseTextureSize20_g281, UseRandomDither20_g281 > 0, AlphaCutoutThreshold20_g281, DitherBlend20_g281,  alpha, AlphaThreshold20_g281);
			AlphaOut20_g281 = alpha;
			clip( ( (temp_output_69_0).a * AlphaOut20_g281 ) - AlphaThreshold20_g281);
			o.Albedo = temp_output_69_0.rgb;
			o.Emission = ( i.vertexToFrag11_g277 * (_Emission).rgb );
			o.Metallic = ( _Metallic * i.vertexToFrag2_g277 );
			o.Smoothness = ( _Smoothness * i.vertexToFrag14_g277 );
			o.Alpha = 1;
		}

		ENDCG
	}
	Fallback "Diffuse"
	CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=18500
-1542;215;1438;789;2206.85;-84.88116;1.377827;True;False
Node;AmplifyShaderEditor.FunctionNode;86;-1408,-128;Inherit;False;Mud Splat;1;;277;1947d49d4d7bb92419410ba0439aa2bc;0;0;17;COLOR;22;FLOAT2;29;FLOAT;24;FLOAT3;27;FLOAT;26;FLOAT;23;FLOAT4;45;FLOAT3;21;FLOAT3;43;FLOAT3;28;FLOAT3;42;FLOAT3;52;FLOAT3;53;FLOAT3;60;FLOAT3;61;FLOAT2;25;FLOAT;57
Node;AmplifyShaderEditor.SimpleTimeNode;22;-1456,576;Inherit;False;1;0;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;73;-1456,672;Inherit;False;Property;_Frequency;Frequency;6;0;Create;True;0;0;False;0;False;0.1;0.2;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;74;-1168,576;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.FunctionNode;88;-1232,448;Inherit;False;Mud Noise Gradient;-1;;279;ded4656e0e0531448b1f2a26fd64d584;0;3;2;FLOAT3;0,0,0;False;5;FLOAT;0.1;False;7;FLOAT;1;False;1;FLOAT3;0
Node;AmplifyShaderEditor.TexturePropertyNode;67;-1280,-384;Inherit;True;Property;_MainTex;Albedo;8;0;Create;False;0;0;False;0;False;None;None;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
Node;AmplifyShaderEditor.RangedFloatNode;19;-1456,768;Inherit;False;Property;_OffsetAmount;Offset Amount;7;0;Create;True;0;0;False;0;False;0.01;0.1;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;68;-896,-384;Inherit;True;Property;_TextureSample0;Texture Sample 0;0;0;Create;True;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleAddOpNode;28;-960,496;Inherit;False;3;3;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.FunctionNode;66;-784,528;Inherit;False;Mud Noise Gradient;-1;;280;ded4656e0e0531448b1f2a26fd64d584;0;3;2;FLOAT3;0,0,0;False;5;FLOAT;0.5;False;7;FLOAT;0.1;False;1;FLOAT3;0
Node;AmplifyShaderEditor.TexturePropertyNode;4;-1408,1088;Inherit;True;Property;_DitherTexture;Dither Texture;12;0;Create;True;0;0;False;0;False;f240bbb7854046345b218811e5681a54;f240bbb7854046345b218811e5681a54;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;69;-256,-128;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
Node;AmplifyShaderEditor.IntNode;8;-1408,1312;Inherit;False;Property;_DitherTextureSize;Dither Texture Size;13;0;Create;True;0;0;False;0;False;256;256;0;1;INT;0
Node;AmplifyShaderEditor.RangedFloatNode;5;-1408,1600;Inherit;False;Property;_Dithering;Dithering;10;0;Create;True;0;0;False;0;False;1;1;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;6;-1408,1408;Inherit;False;Property;_RandomDither;Random Dither;11;1;[Toggle];Create;True;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;7;-1408,1504;Inherit;False;Property;_AlphaCutoutThreshold;Alpha Cutout Threshold;9;0;Create;True;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.CrossProductOpNode;85;-688,752;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.ComponentMaskNode;70;-48,-80;Inherit;False;False;False;False;True;1;0;COLOR;0,0,0,0;False;1;FLOAT;0
Node;AmplifyShaderEditor.ComponentMaskNode;84;-496,608;Inherit;False;False;False;True;False;1;0;FLOAT3;0,0,0;False;1;FLOAT;0
Node;AmplifyShaderEditor.FunctionNode;9;-288,768;Inherit;False;Mud Alpha Threshold;-1;;281;926535703f4c32948ac1f55275a22bf0;0;9;8;FLOAT2;0,0;False;15;FLOAT3;0,0,0;False;18;FLOAT;0;False;22;FLOAT;0;False;19;SAMPLER2D;0;False;26;INT;256;False;9;INT;0;False;6;FLOAT;0;False;7;FLOAT;0;False;2;FLOAT;24;FLOAT;25
Node;AmplifyShaderEditor.ComponentMaskNode;83;-496,480;Inherit;False;True;False;False;False;1;0;FLOAT3;0,0,0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;71;208,-80;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;81;-224,608;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;80;-224,480;Inherit;False;2;2;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.ClipNode;72;512,-160;Inherit;False;3;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.SimpleAddOpNode;14;512,384;Inherit;False;3;3;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1024,0;Float;False;True;-1;3;ASEMaterialInspector;0;0;Standard;MudBun/Floater Splat (Built-In RP);False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.5;True;True;0;True;TransparentCutout;;Geometry;All;11;d3d11_9x;d3d11;glcore;gles3;vulkan;xbox360;xboxone;ps4;psp2;n3ds;wiiu;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Absolute;0;;0;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
WireConnection;74;0;22;0
WireConnection;74;1;73;0
WireConnection;88;2;86;60
WireConnection;68;0;67;0
WireConnection;68;1;86;29
WireConnection;28;0;86;60
WireConnection;28;1;74;0
WireConnection;28;2;88;0
WireConnection;66;2;28;0
WireConnection;66;7;19;0
WireConnection;69;0;68;0
WireConnection;69;1;86;22
WireConnection;85;0;86;28
WireConnection;85;1;86;52
WireConnection;70;0;69;0
WireConnection;84;0;66;0
WireConnection;9;8;86;25
WireConnection;9;15;86;28
WireConnection;9;18;86;57
WireConnection;9;22;86;24
WireConnection;9;19;4;0
WireConnection;9;26;8;0
WireConnection;9;9;6;0
WireConnection;9;6;7;0
WireConnection;9;7;5;0
WireConnection;83;0;66;0
WireConnection;71;0;70;0
WireConnection;71;1;9;24
WireConnection;81;0;85;0
WireConnection;81;1;84;0
WireConnection;80;0;86;52
WireConnection;80;1;83;0
WireConnection;72;0;69;0
WireConnection;72;1;71;0
WireConnection;72;2;9;25
WireConnection;14;0;86;21
WireConnection;14;1;80;0
WireConnection;14;2;81;0
WireConnection;0;0;72;0
WireConnection;0;2;86;27
WireConnection;0;3;86;26
WireConnection;0;4;86;23
WireConnection;0;11;14;0
WireConnection;0;12;86;28
ASEEND*/
//CHKSM=C6F337FA833DD571E18DE7227610860B84B10614