// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "Turtles/AudioLink Watch"
{
	Properties
	{
		_TileSet("Tile Set", 2D) = "white" {}
		_Colour("Colour", Color) = (0,0,0,0)
		_Emission("Emission", Range( 0 , 5)) = 0

	}
	
	SubShader
	{
		
		
		Tags { "RenderType"="Opaque" }
	LOD 100

		CGINCLUDE
		#pragma target 3.0
		ENDCG
		Blend Off
		AlphaToMask Off
		Cull Back
		ColorMask RGBA
		ZWrite On
		ZTest LEqual
		Offset 0 , 0
		
		
		GrabPass{ }

		Pass
		{
			Name "Unlit"
			Tags { "LightMode"="ForwardBase" }
			CGPROGRAM

			#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
			#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex);
			#else
			#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex)
			#endif


			#ifndef UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
			//only defining to not throw compilation error over Unity 5.5
			#define UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
			#endif
			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_instancing
			#include "UnityCG.cginc"
			#include "Assets/AudioLink/Shaders/AudioLink.cginc"

			#include "UnityShaderVariables.cginc"


			struct appdata
			{
				float4 vertex : POSITION;
				float4 color : COLOR;
				float4 ase_texcoord : TEXCOORD0;
				UNITY_VERTEX_INPUT_INSTANCE_ID
			};
			
			struct v2f
			{
				float4 vertex : SV_POSITION;
				#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
				float3 worldPos : TEXCOORD0;
				#endif
				float4 ase_texcoord1 : TEXCOORD1;
				float4 ase_texcoord2 : TEXCOORD2;
				UNITY_VERTEX_INPUT_INSTANCE_ID
				UNITY_VERTEX_OUTPUT_STEREO
			};

			uniform float _Emission;
			uniform float4 _Colour;
			uniform sampler2D _TileSet;
			ASE_DECLARE_SCREENSPACE_TEXTURE( _GrabTexture )
			float GetTimeU102( float U )
			{
				const float U35=U/3.27;
				const float fac1=0.0627;
				const float fac2=0.0612;
				const uint time=AudioLinkDecodeDataAsSeconds( ALPASS_GENERALVU_LOCAL_TIME);
				const uint t=time/60;
				const uint t60=t/60;
				const uint hourstens=(t60-t60%10)/10;
				const uint hoursones=t60%10;
				const uint tens=(t%60-t%10)/10;
				const uint ones=t%10;
				const uint tick=time%2;
				float a=
				step(U,0.2)*(hourstens*fac1+U35)+
				step(0.2,U)*step(U-0.2,0.2)*(hoursones*fac1+U35-fac2)+
				step(0.6,U)*step(U-0.6,0.2)*(tens*fac1+U35-(fac2*3))+
				step(0.8,U)*step(U-0.8,0.2)*(ones*fac1+U35-(fac2*4))+
				step(0.4,U)*step(U-0.4,0.2)*(tick*.517+((1-tick)*0.82)+(U35*.909))
				;
				return(a);
			}
			
			inline float4 ASE_ComputeGrabScreenPos( float4 pos )
			{
				#if UNITY_UV_STARTS_AT_TOP
				float scale = -1.0;
				#else
				float scale = 1.0;
				#endif
				float4 o = pos;
				o.y = pos.w * 0.5f;
				o.y = ( pos.y - o.y ) * _ProjectionParams.x * scale + o.y;
				return o;
			}
			

			
			v2f vert ( appdata v )
			{
				v2f o;
				UNITY_SETUP_INSTANCE_ID(v);
				UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
				UNITY_TRANSFER_INSTANCE_ID(v, o);

				float4 ase_clipPos = UnityObjectToClipPos(v.vertex);
				float4 screenPos = ComputeScreenPos(ase_clipPos);
				o.ase_texcoord2 = screenPos;
				
				o.ase_texcoord1.xy = v.ase_texcoord.xy;
				
				//setting value to unused interpolator channels and avoid initialization warnings
				o.ase_texcoord1.zw = 0;
				float3 vertexValue = float3(0, 0, 0);
				#if ASE_ABSOLUTE_VERTEX_POS
				vertexValue = v.vertex.xyz;
				#endif
				vertexValue = vertexValue;
				#if ASE_ABSOLUTE_VERTEX_POS
				v.vertex.xyz = vertexValue;
				#else
				v.vertex.xyz += vertexValue;
				#endif
				o.vertex = UnityObjectToClipPos(v.vertex);

				#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
				o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
				#endif
				return o;
			}
			
			fixed4 frag (v2f i ) : SV_Target
			{
				UNITY_SETUP_INSTANCE_ID(i);
				UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
				fixed4 finalColor;
				#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
				float3 WorldPosition = i.worldPos;
				#endif
				float U102 = i.ase_texcoord1.xy.x;
				float localGetTimeU102 = GetTimeU102( U102 );
				float4 appendResult10 = (float4(localGetTimeU102 , ( ( i.ase_texcoord1.xy.y / 1.471 ) + 0.318 ) , 0.0 , 0.0));
				float localAudioLinkIsAvailable58 = ( AudioLinkIsAvailable()?1.0:0.0 );
				float mulTime124 = _Time.y * 0.05;
				float temp_output_119_0 = ( ( i.ase_texcoord1.xy.y - mulTime124 ) * 16.0 );
				float temp_output_123_0 = abs( ( round( temp_output_119_0 ) - temp_output_119_0 ) );
				float temp_output_113_0 = ( step( 0.967 , ( ( 1.0 - tex2D( _TileSet, appendResult10.xy ).r ) * localAudioLinkIsAvailable58 ) ) * ( temp_output_123_0 * temp_output_123_0 ) );
				float Bloom133 = ( temp_output_113_0 * temp_output_113_0 * 20.0 );
				float4 screenPos = i.ase_texcoord2;
				float4 ase_grabScreenPos = ASE_ComputeGrabScreenPos( screenPos );
				float4 screenColor106 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_GrabTexture,ase_grabScreenPos.xy/ase_grabScreenPos.w);
				float4 lerpResult112 = lerp( ( ( ( _Emission + 1.0 ) * _Colour ) + Bloom133 ) , screenColor106 , ( 1.0 - temp_output_113_0 ));
				
				
				finalColor = lerpResult112;
				return finalColor;
			}
			ENDCG
		}
	}
	CustomEditor "ASEMaterialInspector"
	
	
}
/*ASEBEGIN
Version=18912
257.6;-1074;1920;1053;854.0846;862.7217;1.329649;True;False
Node;AmplifyShaderEditor.RangedFloatNode;75;-578.2931,-105.422;Inherit;False;Constant;_Float0;Float 0;4;0;Create;True;0;0;0;False;0;False;1.471;1.233;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.TexCoordVertexDataNode;7;-600.8224,-306.1501;Inherit;False;0;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.TexCoordVertexDataNode;118;-181.6067,-36.60905;Inherit;False;0;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleTimeNode;124;-162.1328,133.2857;Inherit;False;1;0;FLOAT;0.05;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;78;-525.4509,-13.0959;Inherit;False;Constant;_Float2;Float 2;4;0;Create;True;0;0;0;False;0;False;0.318;0.318;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleDivideOpNode;76;-359.3102,-187.9837;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleSubtractOpNode;126;54.66775,65.48587;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleAddOpNode;77;-190.9813,-192.0837;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;-0.735;False;1;FLOAT;0
Node;AmplifyShaderEditor.CustomExpressionNode;102;-199.4578,-285.6555;Inherit;False;const float U35=U/3.27@$const float fac1=0.0627@$const float fac2=0.0612@$const uint time=AudioLinkDecodeDataAsSeconds( ALPASS_GENERALVU_LOCAL_TIME)@$const uint t=time/60@$const uint t60=t/60@$const uint hourstens=(t60-t60%10)/10@$const uint hoursones=t60%10@$const uint tens=(t%60-t%10)/10@$const uint ones=t%10@$const uint tick=time%2@$$float a=$step(U,0.2)*(hourstens*fac1+U35)+$step(0.2,U)*step(U-0.2,0.2)*(hoursones*fac1+U35-fac2)+$step(0.6,U)*step(U-0.6,0.2)*(tens*fac1+U35-(fac2*3))+$step(0.8,U)*step(U-0.8,0.2)*(ones*fac1+U35-(fac2*4))+$step(0.4,U)*step(U-0.4,0.2)*(tick*.517+((1-tick)*0.82)+(U35*.909))$@$return(a)@;1;Create;1;True;U;FLOAT;0;In;;Inherit;False;GetTimeU;True;False;0;;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.TexturePropertyNode;6;-132.9997,-512.5001;Inherit;True;Property;_TileSet;Tile Set;0;0;Create;True;0;0;0;False;0;False;None;780d6cc52c0e27b419c7d9a057c23207;False;white;Auto;Texture2D;-1;0;2;SAMPLER2D;0;SAMPLERSTATE;1
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;119;217.4935,66.09154;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;16;False;1;FLOAT;0
Node;AmplifyShaderEditor.DynamicAppendNode;10;-38.91817,-286.0605;Inherit;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.SamplerNode;1;131.5999,-409.1001;Inherit;True;Property;_Tileset;Tileset;0;0;Create;True;0;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.RoundOpNode;120;361.7896,27.09179;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleSubtractOpNode;121;494.3916,42.69143;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.OneMinusNode;68;434.2289,-377.2665;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.CustomExpressionNode;58;419.7912,-294.7218;Inherit;False;AudioLinkIsAvailable()?1.0:0.0;1;Create;0;AudioLinkIsAvailable;True;False;0;;False;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;80;600.9401,-357.9942;Inherit;False;2;2;0;FLOAT;1;False;1;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.AbsOpNode;123;648.3665,43.98603;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StepOpNode;101;824.2657,-313.1575;Inherit;False;2;0;FLOAT;0.967;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;129;803.8619,32.14421;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;113;969.4575,-245.072;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;132;1048.611,-44.87103;Inherit;False;Constant;_Float1;Float 1;4;0;Create;True;0;0;0;False;0;False;20;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;115;922.5316,-711.0821;Inherit;False;Property;_Emission;Emission;3;0;Create;True;0;0;0;False;0;False;0;5;0;5;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;130;1236.868,-86.92859;Inherit;False;3;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;133;1402.094,-91.9345;Inherit;False;Bloom;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.ColorNode;95;991.104,-616.8862;Inherit;False;Property;_Colour;Colour;1;0;Create;True;0;0;0;False;0;False;0,0,0,0;1,0,0.5563878,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleAddOpNode;116;1289.133,-707.1008;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;117;1440.775,-641.7516;Inherit;False;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0
Node;AmplifyShaderEditor.GetLocalVarNode;134;1413.109,-496.4863;Inherit;False;133;Bloom;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleAddOpNode;131;1593.355,-579.601;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.OneMinusNode;108;1583.348,-246.1384;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.ScreenColorNode;106;988.032,-432.4346;Inherit;False;Global;_GrabScreen0;Grab Screen 0;7;0;Create;True;0;0;0;False;0;False;Object;-1;False;False;False;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.LerpOp;112;1770.894,-454.0874;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.RangedFloatNode;111;645.3589,-134.7719;Inherit;False;Property;_Opacity;Opacity;2;0;Create;True;0;0;0;False;0;False;0;1;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;105;1982.356,-467.6176;Float;False;True;-1;2;ASEMaterialInspector;100;12;Turtles/AudioLink Watch;98260b9dbbbb4b244bc27a597305f10e;True;Unlit;0;0;Unlit;2;False;True;0;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;True;0;False;-1;0;False;-1;False;False;False;False;False;False;False;False;False;True;0;False;-1;False;True;0;False;-1;False;True;True;True;True;True;0;False;-1;False;False;False;False;False;False;False;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;False;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;RenderType=Opaque=RenderType;True;2;False;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=ForwardBase;False;False;0;;0;0;Standard;1;Vertex Position,InvertActionOnDeselection;1;0;1;True;False;;False;0
WireConnection;76;0;7;2
WireConnection;76;1;75;0
WireConnection;126;0;118;2
WireConnection;126;1;124;0
WireConnection;77;0;76;0
WireConnection;77;1;78;0
WireConnection;102;0;7;1
WireConnection;119;0;126;0
WireConnection;10;0;102;0
WireConnection;10;1;77;0
WireConnection;1;0;6;0
WireConnection;1;1;10;0
WireConnection;120;0;119;0
WireConnection;121;0;120;0
WireConnection;121;1;119;0
WireConnection;68;0;1;1
WireConnection;80;0;68;0
WireConnection;80;1;58;0
WireConnection;123;0;121;0
WireConnection;101;1;80;0
WireConnection;129;0;123;0
WireConnection;129;1;123;0
WireConnection;113;0;101;0
WireConnection;113;1;129;0
WireConnection;130;0;113;0
WireConnection;130;1;113;0
WireConnection;130;2;132;0
WireConnection;133;0;130;0
WireConnection;116;0;115;0
WireConnection;117;0;116;0
WireConnection;117;1;95;0
WireConnection;131;0;117;0
WireConnection;131;1;134;0
WireConnection;108;0;113;0
WireConnection;112;0;131;0
WireConnection;112;1;106;0
WireConnection;112;2;108;0
WireConnection;105;0;112;0
ASEEND*/
//CHKSM=1166FD133D92CBF97C750E044F56F91905BB2AE8