// Made with Amplify Shader Editor // Available at the Unity Asset Store - http://u3d.as/y3X Shader "Gemini/GraphicWaterfall" { Properties { _ShapeTexture("Shape Texture", 2D) = "white" {} _BackgroundColor("Background Color", Color) = (0,0,0,0) _BackgroundOpacity("Background Opacity", Range( 0 , 1)) = 0.5 _MoveDirection("Move Direction", Vector) = (1,0,0,0) _MinMoveSpeed("Min Move Speed", Float) = 0.1 _MaxMoveSpeed("Max Move Speed", Float) = 0.5 _MinRotationSpeed("Min Rotation Speed", Range( 0 , 10)) = 1 _MaxRotationSpeed("Max Rotation Speed", Range( 0 , 10)) = 5 _Density("Density", Range( 1 , 100)) = 10 _ShapeOpacity("Shape Opacity", Range( 0 , 1)) = 1 [Toggle]_EnableEmission("Enable Emission", Float) = 0 _EmissionColor("Emission Color", Color) = (1,1,1,1) _GlobalOpacity("Global Opacity", Range( 0 , 1)) = 1 [HideInInspector] _texcoord( "", 2D ) = "white" {} } SubShader { Tags { "RenderType"="Transparent" "Queue"="Transparent" "DisableBatching"="True" } LOD 100 CGINCLUDE #pragma target 3.0 ENDCG Blend SrcAlpha OneMinusSrcAlpha Cull Off ColorMask RGBA ZWrite Off ZTest LEqual Pass { Name "Unlit" CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile _ ETC1_EXTERNAL_ALPHA #include "UnityCG.cginc" #pragma multi_compile _ ENABLEEMISSION_ON struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; }; uniform sampler2D _ShapeTexture; uniform float _Density; uniform float4 _MoveDirection; uniform float _MinMoveSpeed; uniform float _MaxMoveSpeed; uniform float _MinRotationSpeed; uniform float _MaxRotationSpeed; uniform float4 _BackgroundColor; uniform float _BackgroundOpacity; uniform float _ShapeOpacity; uniform float _GlobalOpacity; uniform float4 _EmissionColor; v2f vert ( appdata v ) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } // https://www.ronja-tutorials.com/post/028-voronoi-noise/ // https://www.shadertoy.com/view/MslGD8 float2 random( float2 p ) { return frac( sin( float2( dot( p, float2( 127.1, 311.7 ) ), dot( p, float2( 269.5, 183.3 ) ) ) ) * 43758.5453 ); } fixed4 frag (v2f i ) : SV_Target { fixed4 finalColor; //--------------------------------------------------------- // 4.1 - 创建网格 (Grid) 和单元格内部坐标 (Cell UV) //--------------------------------------------------------- float2 mainUV = i.uv; float2 tiledUV = mainUV * _Density; float2 cellID = floor(tiledUV); float2 cellUV = frac(tiledUV); //--------------------------------------------------------- // 4.2 - 为每个单元格生成独立的随机值 //--------------------------------------------------------- float2 randomValue1 = random(cellID); float2 randomValue2 = random(cellID + float2(1.2, 3.4)); float randomSpeed = lerp(_MinMoveSpeed, _MaxMoveSpeed, randomValue1.x); float randomRotationSpeed = lerp(_MinRotationSpeed, _MaxRotationSpeed, randomValue1.y); float randomPhase = randomValue2.x * 100.0; //--------------------------------------------------------- // 4.3 - 实现独立的平滑移动与旋转 (核心) //--------------------------------------------------------- // 计算移动 float localTime = _Time.y + randomPhase; float2 movementOffset = (localTime * randomSpeed) * _MoveDirection.xy; float2 panningUV = cellUV - movementOffset; // 计算旋转 float rotationAngle = localTime * randomRotationSpeed; float2 anchor = float2(0.5, 0.5); float sinRot = sin(rotationAngle); float cosRot = cos(rotationAngle); float2x2 rotationMatrix = float2x2(cosRot, -sinRot, sinRot, cosRot); float2 finalUV = mul(panningUV - anchor, rotationMatrix) + anchor; //--------------------------------------------------------- // 4.4 - 最终采样与混合 //--------------------------------------------------------- float4 shapeSample = tex2D(_ShapeTexture, finalUV); // 混合颜色 float3 mixedColor = lerp(_BackgroundColor.rgb, shapeSample.rgb, shapeSample.a); // 混合透明度 float mixedOpacity = lerp(_BackgroundOpacity, _ShapeOpacity, shapeSample.a); float finalOpacity = mixedOpacity * _GlobalOpacity; // 处理发光 float3 emission = 0.0; #ifdef ENABLEEMISSION_ON emission = shapeSample.rgb * _EmissionColor.rgb * shapeSample.a; #endif finalColor = float4(mixedColor + emission, finalOpacity); return finalColor; } ENDCG } } CustomEditor "AmplifyShaderEditor.AmplifyShaderEditor" } /*ASEBEGIN Version=19100 Node;AmplifyShaderEditor.TextureCoordinatesNode;1;-1472,64;Inherit;False;0;3;2;3;2;FLOAT2;0,0;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.RangedFloatNode;2;-1472,256;Inherit;False;Property;_Density;Density;8;0;Create;True;0;0;0;False;0;False;10;1;1;100;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;3;-1216,128;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.FloorOpNode;5;-960,64;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.FractNode;4;-960,192;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.CommentNode;48;-768,-448;Inherit;False;1024;336;4.2 随机值生成;10;8;10;11;12;13;14;15;16;17;47 Node;AmplifyShaderEditor.CommentNode;49;-1568,0;Inherit;False;720;352;4.1 网格划分;5;1;2;3;4;5 Node;AmplifyShaderEditor.CommentNode;50;-768,256;Inherit;False;1232;528;4.3 独立运动与旋转;11;18;19;20;21;22;23;24;25;26;27;30 Node;AmplifyShaderEditor.Vector2Node;11;-704,-384;Inherit;False;Constant;_Vector0;Vector 0;8;0;Create;True;0;0;0;False;0;False;1.2,3.4;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 Node;AmplifyShaderEditor.SimpleAddOpNode;10;-448,-384;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.RandomRangeNode;8;-448,-256;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.RandomRangeNode;12;-192,-384;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.RangedFloatNode;15;-448,0;Inherit;False;Property;_MaxMoveSpeed;Max Move Speed;5;0;Create;True;0;0;0;False;0;False;0.5;0;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;14;-448,-128;Inherit;False;Property;_MinMoveSpeed;Min Move Speed;4;0;Create;True;0;0;0;False;0;False;0.1;0;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;13;-192,-224;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;17;-192,-128;Inherit;False;Property;_MaxRotationSpeed;Max Rotation Speed;7;0;Create;True;0;0;0;False;0;False;5;0;0;10;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;16;-192,0;Inherit;False;Property;_MinRotationSpeed;Min Rotation Speed;6;0;Create;True;0;0;0;False;0;False;1;0;0;10;0;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;47;-16,-96;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.ComponentMaskNode;46;-16,-224;Inherit;False;1;1;0;FLOAT2;0,0;False;1;FLOAT;0 Node;AmplifyShaderEditor.ComponentMaskNode;45;-16,-384;Inherit;False;0;1;0;FLOAT2;0,0;False;1;FLOAT;0 Node;AmplifyShaderEditor.TimeNode;19;-704,320;Inherit;False;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;21;112,-384;Inherit;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;100;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;20;-448,320;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;22;-224,320;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.Vector4Node;24;-448,448;Inherit;False;Property;_MoveDirection;Move Direction;3;0;Create;True;0;0;0;False;0;False;1,0,0,0;1,0,0,0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;23;-16,384;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.SimpleSubtractOpNode;25;240,320;Inherit;False;2;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;27;-224,512;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.Vector2Node;30;240,640;Inherit;False;Constant;_Vector1;Vector 1;10;0;Create;True;0;0;0;False;0;False;0.5,0.5;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 Node;AmplifyShaderEditor.RotatorNode;26;496,448;Inherit;False;3;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.CommentNode;51;704,64;Inherit;False;1296;608;4.4 最终采样与混合;10;28;29;31;32;33;34;35;36;37;44 Node;AmplifyShaderEditor.SamplerNode;28;768,128;Inherit;True;Property;_ShapeTexture;Shape Texture;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;FLOAT;0;False;8;FLOAT;0;False;9;FLOAT;0;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.ColorNode;29;768,384;Inherit;False;Property;_BackgroundColor;Background Color;1;0;Create;True;0;0;0;False;0;False;0,0,0,0;0,0,0,0;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.LerpOp;31;1088,256;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;33;1088,512;Inherit;False;Property;_ShapeOpacity;Shape Opacity;9;0;Create;True;0;0;0;False;0;False;1;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;32;1088,384;Inherit;False;Property;_BackgroundOpacity;Background Opacity;2;0;Create;True;0;0;0;False;0;False;0.5;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;34;1344,384;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.RangedFloatNode;35;1344,512;Inherit;False;Property;_GlobalOpacity;Global Opacity;12;0;Create;True;0;0;0;False;0;False;1;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;36;1600,448;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.ColorNode;37;1600,256;Inherit;False;Property;_EmissionColor;Emission Color;11;0;Create;True;0;0;0;False;0;False;1,1,1,1;1,1,1,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.StaticSwitch;44;1344,128;Inherit;False;Property;_EnableEmission;Enable Emission;10;0;Create;True;0;0;0;False;0;False;0;0;0;True;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;43;1088,128;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.StandardUnlitNode;0;2112,256;Float;False;True;2;Float;ASEMaterialInspector;0;0;Unlit;Gemini/GraphicWaterfall;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;False;False;False;False;False;False;Back;0;False;;0;False;;False;0;False;;0;False;;False;0;Transparent;0.5;True;True;0;False;Transparent;RenderType;Transparent=RenderType;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;False;255;False;255;False;255;False;7;False;6;False;5;False;4;False;3;False;2;False;1;False;0;False;0;False;0;False;0;False;0;False;0;False;0;False;False;2;15;10;25;False;0.5;True;0;0;False;;0;0;Standard;0;False;0;2;True;8;1;False;0;0;2;1;1;1;1;1;False;0;0;False;0;0;0;0;0;0;0;0;Float4;0,0,0,0;False;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0 WireConnection;3;0;1;0 WireConnection;3;1;2;0 WireConnection;5;0;3;0 WireConnection;4;0;3;0 WireConnection;10;0;5;0 WireConnection;10;1;11;0 WireConnection;8;0;5;0 WireConnection;12;0;10;0 WireConnection;13;0;14;0 WireConnection;13;1;15;0 WireConnection;13;2;45;0 WireConnection;47;0;16;0 WireConnection;47;1;17;0 WireConnection;47;2;46;0 WireConnection;46;0;8;0 WireConnection;45;0;8;0 IConnection;21;0;12;0 WireConnection;20;0;19;1 WireConnection;20;1;21;0 WireConnection;22;0;20;0 WireConnection;22;1;13;0 WireConnection;23;0;22;0 WireConnection;23;1;24;0 WireConnection;25;0;4;0 WireConnection;25;1;23;0 WireConnection;27;0;20;0 WireConnection;27;1;47;0 WireConnection;26;0;25;0 WireConnection;26;1;30;0 WireConnection;26;2;27;0 WireConnection;28;0;26;0 WireConnection;31;0;29;0 WireConnection;31;1;28;0 WireConnection;31;2;28;4 WireConnection;34;0;32;0 WireConnection;34;1;33;0 WireConnection;34;2;28;4 WireConnection;36;0;34;0 WireConnection;36;1;35;0 WireConnection;44;0;43;0 WireConnection;44;1;37;0 WireConnection;43;0;28;0 WireConnection;43;1;28;4 WireConnection;0;0;31;0 WireConnection;0;1;44;0 WireConnection;0;2;36;0 ASEEND*/ //CHKSM=12A9E53835C4A36B690A81180A5844053B2505C5