Ridgelines
glint · Examples · Tutorials · Gallery
The spectrum's recent history as stacked ridges, Unknown Pleasures style. A history pass scrolls the FFT; the display pass draws it.
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
2 passes, drawn in this order each frame, in GLSL.
History: fragment shader
#version 300 es
precision highp float;
uniform sampler2D feedback;
uniform sampler2D fft;
uniform vec2 resolution;
uniform float time;
in vec2 v_texcoord;
out vec4 fragColor;
// Row 0 is "now"; every frame the history moves up one row. x is frequency.
void main() {
ivec2 p = ivec2(gl_FragCoord.xy);
if (p.y == 0) {
float f = pow(v_texcoord.x, 1.5) * 0.45;
float level = texture(fft, vec2(f, 0.25)).r;
// A little synthetic motion so it isn't flat in silence.
level = max(level, 0.08 * (0.5 + 0.5 * sin(v_texcoord.x * 30.0 + time * 3.0)) * exp(-pow((v_texcoord.x - 0.5) * 4.0, 2.0)));
fragColor = vec4(level, 0.0, 0.0, 1.0);
} else {
fragColor = texelFetch(feedback, p - ivec2(0, 1), 0);
}
}Ridges: fragment shader
#version 300 es
precision highp float;
uniform sampler2D prevPass;
uniform vec2 resolution;
uniform float beat;
uniform float lines;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec2 uv = gl_FragCoord.xy / resolution;
float x = (uv.x - 0.5) * resolution.x / resolution.y + 0.5;
vec3 col = vec3(0.0);
if (x > 0.2 && x < 0.8) {
float n = lines;
// Front to back: nearer ridges hide the ones behind them.
for (float i = 0.0; i < 60.0; i++) {
if (i >= n) break;
float base = 0.12 + i / n * 0.72;
// Two frames of history between ridges.
float hist = texture(prevPass, vec2((x - 0.2) / 0.6, (i * 2.0 + 0.5) / float(textureSize(prevPass, 0).y))).r;
float edge = smoothstep(0.0, 0.08, x - 0.2) * smoothstep(0.0, 0.08, 0.8 - x);
float h = base + hist * 0.25 * edge;
if (uv.y < h) {
float line = smoothstep(2.0 / resolution.y, 0.0, h - uv.y);
col = vec3(line) * (1.0 - i / n * 0.6) * (1.0 + beat * 0.5);
break;
}
}
}
fragColor = vec4(col, 1.0);
}More Starters examples
Terrain flyover · Dal Platinum · Bass rings · Radial spectrum · Kaleido pulse · Laser show · Metaballs · Oscilloscope trails