Spectrum flower
glint · Examples · Tutorials · Gallery
Petals that each grow with one slice of the spectrum, mirrored into a flower that slowly turns; the centre blooms on the kick.
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
One pass, in GLSL.
fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
uniform vec3 spectrum;
uniform float beat;
uniform float beatTime;
uniform int beatCount;
uniform sampler2D fft;
in vec2 v_texcoord;
out vec4 fragColor;
// 1 on each kick, fading; without audio, a steady pulse twice a second.
float kick() { return beatCount > 0 ? beat : pow(1.0 - fract(time * 2.0), 4.0); }
// Seconds since the last kick, and which kick it was (the same fallback).
float sinceKick() { return beatCount > 0 ? beatTime : fract(time * 2.0) / 2.0; }
float kickId() { return beatCount > 0 ? float(beatCount) : floor(time * 2.0); }
// One FFT bin, 0..1 across the spectrum (bass on the left).
float bin(float x) { return texture(fft, vec2(x, 0.25)).r; }
float hash(float n) { return fract(sin(n * 127.1) * 43758.5453); }
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
vec2 hash2(float n) { return fract(sin(vec2(n * 127.1, n * 269.5)) * 43758.5453); }
mat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, s, -s, c); }
vec3 pal(float t) { return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))); }
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
uv = rot(time * 0.1) * uv;
float r = length(uv);
float a = atan(uv.y, uv.x) / 6.28318 + 0.5;
const float N = 24.0;
float petal = floor(a * N);
// Which slice of the spectrum each petal shows, shuffled (golden-ratio steps) so long and short petals spread
// evenly round the flower instead of the bass all on one side.
float band = fract(petal * 0.618034);
// Treble is much quieter than bass: lift it so every petal gets a share.
float lv = pow(bin(0.01 + pow(band, 1.5) * 0.5), 0.7) * (1.0 + band * 2.0);
if (beatCount == 0) lv = 0.35 + 0.3 * sin(time * 1.5 + band * 6.0);
float len = 0.16 + clamp(lv, 0.0, 1.0) * 0.3;
// A rounded petal: narrow at the base, round at the tip.
float within = abs(fract(a * N) - 0.5) * 2.0;
float shape = len * sqrt(max(0.0, 1.0 - within * within));
vec3 col = vec3(0.02, 0.01, 0.04);
float m = smoothstep(0.004, -0.004, r - shape) * step(0.05, r);
col = mix(col, pal(band * 0.6 + time * 0.05) * (0.5 + r * 2.0), m);
col += pal(band * 0.6 + 0.3) * 0.4 * smoothstep(0.006, 0.0, abs(r - shape)) * step(0.05, r);
// The centre.
col = mix(col, vec3(1.0, 0.85, 0.4), smoothstep(0.07 + 0.04 * kick(), 0.06, r));
fragColor = vec4(col, 1.0);
}More Audio-reactive examples
Vinyl · Sonar · Neon runner · Hex pulse · Starburst · Mirror bars · Punch zoom · Synthwave drive