Radial spectrum

glint · Examples · Tutorials · Gallery

Circular spectrum analyser with a waveform ring, mirrored and rotating with the music.

Audio-reactive: it moves with music from a microphone, line-in or a file.

Radial spectrum: an audio-reactive GLSL shader

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 vec3 spectrumIntegrated;
uniform float beat;
uniform int beatCount;
uniform sampler2D fft;

in vec2 v_texcoord;
out vec4 fragColor;

void main() {
    vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
    float rot = spectrumIntegrated.y * 0.5 + time * 0.05;
    float a = atan(uv.y, uv.x) + rot;
    float r = length(uv);
    float t = abs(fract(a / 6.28318) * 2.0 - 1.0);      // mirrored 0..1 around the circle
    float bars = 96.0;
    float bi = floor(t * bars);
    float f = pow((bi + 0.5) / bars, 1.6) * 0.5;
    float level = texture(fft, vec2(f, 0.25)).r;
    float inner = 0.22 + 0.04 * beat;
    float bar = step(inner, r) * step(r, inner + 0.02 + level * 0.35) * step(0.25, fract(t * bars));
    vec3 col = bar * (0.5 + 0.5 * cos(6.28318 * (t * 0.8 + vec3(0.0, 0.33, 0.67) + time * 0.05)));
    float wave = texture(fft, vec2(t, 0.75)).r - 0.5;
    col += smoothstep(0.006, 0.0, abs(r - (inner - 0.05 + wave * 0.15))) * vec3(1.0);
    col += (0.01 / (r + 0.01)) * vec3(0.4, 0.5, 1.0) * spectrum.x;
    col += smoothstep(inner - 0.07, 0.0, r) * vec3(0.1, 0.05, 0.2) * (1.0 + 3.0 * beat);
    fragColor = vec4(col, 1.0);
}

More Starters examples

Bloom · Terrain flyover · Dal Platinum · Bass rings · Ridgelines · Kaleido pulse · Laser show · Metaballs