please make a shadertoy shader that displays a red spiral that slow forms at the cursors…
- User
please make a shadertoy shader that displays a red spiral that slow forms at the cursors position every 5 seconds
Assistant
Here's a Shadertoy shader that creates a red spiral that slowly forms at the cursor's position every 5 seconds. The spiral grows outward from the mouse location over time, resetting every 5 seconds.
void mainImage(out vec4 fragColor, in vec2 fragCoord) { // Normalize coordinates vec2 uv = fragCoord / iResolution.xy; // Mouse position in screen coordinates vec2 mouse = iMouse.xy; // Calculate vector from mouse to current pixel vec2 pos = uv * iResolution.xy; vec2 dx = pos - mouse; float r = length(dx); float theta = atan(dx.y, dx.x); // Time within the 5-second cycle float t = mod(iTime, 5.0); // Spiral parameter: r = theta * t / 5.0 float spiralParam = theta * t / 5.0; float diff = r - spiralParam; // Create a thin red line around the spiral path float alpha = smoothstep(0.0, 0.1, abs(diff)); // Output red color with alpha fragColor = vec4(vec3(1.0, 0.0, 0.0) * alpha, 1.0); }How It Works:
- Mouse Position: The cursor's position (
iMouse.xy) is used as the center of the spiral. - Polar Coordinates: For each pixel, the distance (
r) and angle (theta) from the mouse are calculated. - Spiral Equation: The spiral is defined by
r = theta * t / 5.0, wheretis the time within the 5-second cycle. Astincreases, the spiral expands outward. - Visualizing the Spiral: The difference between the actual radius (
r) and the spiral's expected radius (spiralParam) is used to determine how close the pixel is to the spiral path. Asmoothstepfunction creates a thin red line around the spiral.
Customization:
- Thickness: Adjust the
0.1insmoothstep(0.0, 0.1, ...)to make the spiral thicker or thinner. - Speed: Modify the
t / 5.0factor to control how quickly the spiral forms. - Appearance: Replace
smoothstepwith other functions (e.g.,sin,abs) for different visual effects.
This shader will reset the spiral every 5 seconds, creating a continuous loop of forming spirals at the cursor's location.
- Mouse Position: The cursor's position (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.