layered Sine Scroll

This effect is a modern take on classic “raster bars.” It divides the screen into horizontal strips that scroll in opposite directions. By applying a sine wave to the horizontal displacement based on the vertical position, it creates a “shearing” or “worm-like” motion where the rectangles tilt and undulate as they move.


Parameter Reference Table

Parameter Type Function Visual Impact
line_count int Defines how many horizontal slices the ColorRect is divided into. Higher values create thinner, smoother worms; lower values result in thick, chunky blocks.
movement_speed float Controls how fast the lines scroll and how quickly the waves oscillate. High values create an energetic/fast background; low values (0.1 – 0.5) make it chill and subtle.
wave_intensity float The amplitude of the sine function. It determines the maximum “tilt” or stretch. Increasing this makes the “worm” effect more extreme and curvy.
wave_frequency float Sets how many wave peaks or “humps” appear vertically. Controls the waviness; higher values make the lines look like they are zigzagging more.
color_1 & color_2 vec4 The two colors used for the alternating rectangular pattern. Sets the visual mood. Use low contrast for a professional background look.
Shader code
shader_type canvas_item;

uniform int lineas = 255;             
uniform float velocidad = 2.0;      
uniform float ondulacion = 0.19;     
uniform float frecuencia = 5.0;   
uniform vec4 color_a : source_color = vec4(0.1, 0.5, 0.8, 1.0);
uniform vec4 color_b : source_color = vec4(0.1, 0.1, 0.2, 1.0);

void fragment() {
    vec2 uv = UV;
    
    float id_linea = floor(uv.y * float(lineas));
    
    float sentido = (mod(id_linea, 2.0) == 0.0) ? 1.0 : -1.0;
    
    float desfase_gusano = sin(uv.y * frecuencia + TIME * velocidad) * ondulacion;
    
    float movimiento_h = (TIME * velocidad * 0.2) * sentido;
    uv.x += movimiento_h + (desfase_gusano * sentido);
    
    float patron = step(0.5, fract(uv.x * 2.0));
    
    vec3 color_final = mix(color_a.rgb, color_b.rgb, patron);
    
    float borde = sin(fract(uv.y * float(lineas)) * PI);
    color_final *= smoothstep(0.0, 0.1, borde); 
    
    COLOR = vec4(color_final, 1.0);
}
Live Preview
Tags
animated-gradient, godot-shader, procedural-motion, raster-wave, scrolling-background
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Gerardo LCDF

Related shaders

guest

0 Comments
Oldest
Newest Most Voted