Bass rings

glint · Examples · Tutorials · Gallery

Neon rings rushing out of the centre; every kick fires a new one. Rides on spectrumIntegrated.

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

Bass rings: 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 r = length(uv), a = atan(uv.y, uv.x);
    // Distance travelled: steady drift plus a push from the bass.
    float z = time * 0.3 + spectrumIntegrated.x * 2.0;
    float rings = log(r + 0.02) * 3.0 - z;
    float id = floor(rings);
    float f = fract(rings);
    vec3 hue = 0.5 + 0.5 * cos(6.28318 * (id * 0.13 + vec3(0.0, 0.33, 0.67)));
    float wobble = 0.05 * sin(a * 6.0 + id + time) * spectrum.y;
    float line = smoothstep(0.08, 0.0, abs(f - 0.5 + wobble)) * smoothstep(0.0, 0.3, r);
    vec3 col = hue * line * (0.6 + 1.5 * spectrum.x);
    col += vec3(1.0, 0.9, 0.8) * beat * 0.25 * smoothstep(0.6, 0.0, r);   // flash on the kick
    col += 0.03 / (r + 0.03) * vec3(0.5, 0.3, 1.0) * (0.3 + spectrum.z);
    fragColor = vec4(col, 1.0);
}

More Starters examples

Wireframe waves · Bloom · Terrain flyover · Dal Platinum · Radial spectrum · Ridgelines · Kaleido pulse · Laser show