Files
beyond/Assets/Shaders/WaveButton.shader
2024-11-20 15:21:28 +01:00

97 lines
2.7 KiB
Plaintext

Shader "Unlit/WaveButton"
{
Properties
{
P1ColorIn("Color1 In", Color) = (1.0, 0.5, 0.0, 1.0)
P1ColorOut("Color1 Out", Color) = (1.0, 0.0, 0.0, 1.0)
Amplitude("Amplitudes", Float) = 0.1
Frequency("Frequencies", Float) = 40
Shift("Shift", Float) = 0.5
Scale("Scale", Float) = 0.5
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
half4 P1ColorIn;
half4 P1ColorOut;
half Amplitude;
half Frequency;
half Shift;
half Scale;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
//o.uv = TRANSFORM_TEX(v.uv, _MainTex);
//UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
half3 CalcCurve(half2 uv, float amp, float freq, half3 c1, half3 c2)
{
float curve = amp * sin((freq * uv.x) + (2.0 * _Time.z));
float lineAShape = smoothstep(1.0 - clamp(distance(curve + uv.y, 0.5), 0.0, 1.0), 1.0, 0.99);
return (1.0 - lineAShape) * lerp(c1, c2, lineAShape);
}
half3 CalcComplexCurve(half2 uv, half4 amp, half4 freq, half3 c1, half3 c2)
{
float curve = amp.x * sin((freq.x * uv.x) + (2.0 * _Time.z));
curve += amp.y * sin((freq.y * uv.x) + (2.0 * _Time.z));
curve += amp.z * sin((freq.z * uv.x) + (2.0 * _Time.z));
curve += amp.w * sin((freq.w * uv.x) + (2.0 * _Time.z));
float lineAShape = smoothstep(1.0 - clamp(distance(curve + uv.y, 0.5), 0.0, 1.0), 1.0, 0.99);
return (1.0 - lineAShape) * lerp(c1, c2, lineAShape);
}
half4 frag (v2f i) : SV_Target
{
half4 col = half4(0,0,0,1);// = tex2D(_MainTex, i.uv);
float curve = Amplitude * sin(Frequency * (2.0 * _Time.z)) * Scale + Shift;
if (i.uv.x < curve)
col.xyz = P1ColorIn.xyz;
return col;
}
ENDCG
}
}
}