Below is a drop-in “Image” shader for ShaderToy.
It draws a red Archimedean spiral that starts at the current mouse position, slowly reveals itself over 5 seconds, then restarts and grows again – forever.
glsl
/*
Red Spiral – grows from the mouse every 5 seconds
-------------------------------------------------
• Left-click / move the mouse to change the origin.
• If no mouse is present the spiral spawns from the screen centre.
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
//-------------------------------------------------------------
// 1. Normalised coordinates (keep pixels square)
//-------------------------------------------------------------
vec2 p = fragCoord.xy / iResolution.y; // 0…≈aspect on x, 0…1 on y
//-------------------------------------------------------------
// 2. Spiral centre = current mouse, or centre if no mouse
//-------------------------------------------------------------
vec2 rawMouse = (length(iMouse.xy) < 1.0) // ≈0 when no mouse move
? 0.5 * iResolution.xy // default = screen centre
: iMouse.xy; // live mouse
vec2 center = rawMouse / iResolution.y; // keep same units as p
//-------------------------------------------------------------
// 3. Polar coordinates relative to the centre
//-------------------------------------------------------------
vec2 rel = p - center; // offset vector
float r = length(rel); // radius
float ang = atan(rel.y, rel.x); // angle –π…π
if (ang < 0.0) ang += 6.28318530718; // 0…2π
//-------------------------------------------------------------
// 4. Archimedean spiral: r = k·θ
//-------------------------------------------------------------
const float k = 0.12; // spiral tightness (bigger = looser)
float idealR = k * ang; // radius the spiral “should” be here
float d = abs(r - idealR); // distance to ideal curve
//-------------------------------------------------------------
// 5. Slow reveal mask (0 → 1 over 5 s, then repeats)
//-------------------------------------------------------------
float progress = fract(iTime / 5.0); // 0…1 every 5 sec
float maxR = length(iResolution.xy) / iResolution.y; // biggest radius
float reveal = step(r, progress * maxR); // 1 if within revealed radius
//-------------------------------------------------------------
// 6. Draw the spiral line
//-------------------------------------------------------------
float thickness = 0.003; // line width
float line = smoothstep(thickness, 0.0, d); // 1 on the line, 0 off
//-------------------------------------------------------------
// 7. Final colour
//-------------------------------------------------------------
vec3 col = vec3(1.0, 0.0, 0.0) * line * reveal; // red spiral on black
fragColor = vec4(col, 1.0);
}
Quick tweaks you might like to play with:
• k changes how tight/loose the spiral winds.
• thickness controls line width.
• Change progress = fract(iTime / 5.0) to another divisor (e.g. 7.0) for a different growth period.
Have fun spiralling! 🌀
User
Please make it a blue Archimedean spiral
Assistant
Blue Archimedean Spiral – grows from the mouse every 5 seconds
(Just copy-paste into a new ShaderToy “Image” pass)
glsl
/*
Blue Archimedean Spiral
-----------------------
• Spawns at the mouse position (or screen-centre if no mouse).
• Slowly reveals over 5 s, then restarts.
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
//-------------------------------------------------------------
// 1. Normalised pixel coordinates (square pixels)
//-------------------------------------------------------------
vec2 uv = fragCoord.xy / iResolution.y; // x stretched by aspect
//-------------------------------------------------------------
// 2. Spiral centre = mouse or centre of screen
//-------------------------------------------------------------
vec2 m = (iMouse.z < 0.5) // iMouse.z ≈ 0 when no click
? 0.5 * iResolution.xy // centre
: iMouse.xy; // live position
vec2 center = m / iResolution.y; // same units as uv
//-------------------------------------------------------------
// 3. Polar coordinates
//-------------------------------------------------------------
vec2 dPos = uv - center;
float r = length(dPos);
float ang = atan(dPos.y, dPos.x); // −π … π
if (ang < 0.0) ang += 6.28318530718; // 0 … 2π
//-------------------------------------------------------------
// 4. Archimedean spiral r = kθ
//-------------------------------------------------------------
const float k = 0.12; // tightness
float idealR = k * ang;
float dist = abs(r - idealR); // radial distance to curve
//-------------------------------------------------------------
// 5. Reveal mask (loops every 5 s)
//-------------------------------------------------------------
float progress = fract(iTime / 5.0); // 0–1 every 5 seconds
float maxR = length(iResolution.xy) / iResolution.y;
float revealed = step(r, progress * maxR); // 1 if within revealed zone
//-------------------------------------------------------------
// 6. Line thickness
//-------------------------------------------------------------
float thickness = 0.003;
float line = smoothstep(thickness, 0.0, dist); // 1 on line
//-------------------------------------------------------------
// 7. Final colour (BLUE!)
//-------------------------------------------------------------
vec3 colour = vec3(0.0, 0.55, 1.0) * line * revealed; // adjust blue tint
fragColor = vec4(colour, 1.0);
}
Changes from the previous red version
• The colour vector is now vec3(0.0, 0.55, 1.0) → a bright, slightly lighter blue.
• All else (growth timing, thickness, mouse control) stays the same.