glsl
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
// Normalize pixel coordinates
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Get mouse position in normalized coordinates
vec2 mouse = (iMouse.xy - 0.5 * iResolution.xy) / iResolution.y;
// Calculate time for the spiral animation (repeats every 5 seconds)
float t = mod(iTime, 5.0);
// Calculate distance and angle from current pixel to mouse position
vec2 diff = uv - mouse;
float dist = length(diff);
float angle = atan(diff.y, diff.x);
// Archimedean spiral formula: r = a + bθ
float a = 0.1; // Starting radius
float b = 0.1; // Growth rate
float spiral_radius = a + b * (angle + t * 5.0);
// Calculate distance from point to spiral
float spiral = abs(dist - spiral_radius);
float line = smoothstep(0.01, 0.0, spiral);
// Fade spiral based on distance and time
float fade = smoothstep(1.0, 0.0, dist * 2.0);
fade *= smoothstep(0.0, 0.5, t) * smoothstep(5.0, 4.5, t);
// Create final color (blue spiral)
vec3 color = vec3(0.0, 0.4, 1.0) * line * fade;
fragColor = vec4(color, 1.0);
}
The spiral will now grow outward in a mathematically precise Archimedean pattern, rather than the previous artistic spiral effect.