Threads
WebGL shader
Forty sine curves with drifting phase — a small nod to Threading Motion. Cursor height twists them.
Source
// Threads — layered sine curves with drifting phase.
// Uniforms: iResolution, iTime, iMouse, iTheme (0 dark, 1 light)
const int N = 40;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float px = 1.0 / iResolution.y;
float t = iTime * 0.4;
float twist = iMouse.x > 0.0 ? (iMouse.y / iResolution.y - 0.5) * 2.0 : 0.0;
float acc = 0.0;
for (int i = 0; i < N; i++) {
float fi = float(i) / float(N);
float y = 0.35 * sin(uv.x * (2.0 + fi * 3.0) + t + fi * 6.2831) * (0.4 + 0.6 * sin(t * 0.5 + fi * 3.0))
+ (fi - 0.5) * 0.5
+ twist * 0.25 * sin(uv.x * 3.0 + fi * 4.0);
float d = abs(uv.y - y);
float w = px * (0.8 + 1.5 * fi);
acc += smoothstep(w * 2.0, 0.0, d) * (0.25 + 0.75 * fi);
}
acc *= smoothstep(1.0, 0.3, abs(uv.x)); // fade at the sides
vec3 col = vec3(1.0 - exp(-acc * 1.2));
col = mix(col, 1.0 - col, iTheme);
fragColor = vec4(col, 1.0);
}