Here's a Shadertoy shader that creates a red spiral that slowly forms at the cursor position every 5 seconds:
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord / iResolution.xy;
// Get cursor position (normalized)
vec2 cursor = iMouse.xy / iResolution.xy;
// Time in 5-second cycles
float cycleTime = mod(iTime, 5.0);
float cycleProgress = cycleTime / 5.0;
// Only draw when we're in the first 3 seconds of each cycle
float drawTime = smoothstep(0.0, 0.1, cycleProgress) * (1.0 - smoothstep(0.6, 0.7, cycleProgress));
// Vector from cursor to current pixel
vec2 delta = uv - cursor;
// Polar coordinates relative to cursor
float angle = atan(delta.y, delta.x);
float radius = length(delta) * 2.0;
// Spiral pattern (fades in over time)
float spiral = sin(angle * 5.0 + radius * 20.0 - cycleTime * 10.0);
spiral = smoothstep(0.7, 0.9, spiral) * drawTime;
// Color (red with fade)
vec3 col = vec3(spiral * (1.0 - radius), 0.0, 0.0);
// Output to screen
fragColor = vec4(col, 1.0);
}
How it works:
- The shader creates a 5-second cycle using
mod(iTime, 5.0)
- During each cycle, a red spiral forms at the cursor position
- The spiral fades in over the first part of the cycle and then disappears
- The spiral is created using polar coordinates relative to the cursor position
- The
sin() function combined with angle and radius creates the spiral pattern
- The
smoothstep() functions control the fade-in and fade-out
You can paste this code directly into a new shader on Shadertoy.com. The spiral will appear at your mouse cursor position and reform every 5 seconds.
If you want to adjust the appearance, you can modify:
- The
5.0 values to change the cycle time
- The
5.0 in angle * 5.0 to change how many arms the spiral has
- The
20.0 in radius * 20.0 to change how tightly wound the spiral is
- The fade times by adjusting the
0.6 and 0.7 values