hero-mark-2/shaders/beam_of_sin.gdshader

19 lines
No EOL
526 B
Text

shader_type canvas_item;
const float TAU = 6.28319;
uniform float speed = 1.0;
uniform float cycle_offset = 0.0;
uniform float wave_length = 1.0;
uniform float thickness = 0.05;
float plot(vec2 st, float pct) {
return step( pct - thickness, st.x) -
step( pct + thickness, st.x);
}
void fragment() {
float sin_time = fract(TIME * floor(speed)) * TAU;
float x = sin(UV.y * wave_length + sin_time + cycle_offset)*0.5+0.5;
COLOR = COLOR * vec4(1.0, 1.0, 1.0, plot(UV * vec2(1.2, 1.0) + vec2(-0.1, 0.0), x));
}