Simple sine wave shader
Usage
- Add the shader to a Color Rect or a Sprite
- Adjust the values to your usecase
Shader code
shader_type canvas_item;
uniform float time;
uniform float amplitude : hint_range(0.0, 100.0) = 20.0;
uniform float frequency : hint_range(0.1, 10.0) = 2.0;
uniform float speed : hint_range(0.0, 10.0) = 2.0;
uniform float thickness : hint_range(0.5, 100.0) = 2.0;
uniform vec4 line_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform vec2 resolution = vec2(256.0, 256.0); // width, height of the rect or texture
void fragment() {
float x = UV.x;
float y = UV.y;
float wave_y = 0.5 + amplitude * sin(x * frequency * 6.2831 + time * speed) / resolution.y;
float distance = abs(y - wave_y);
if (distance < thickness / resolution.y) {
COLOR = line_color;
} else {
discard;
}
}


