Neon sign
glint · Examples · Tutorials · Gallery
OPEN in neon tubes on a brick wall, each letter a handful of line segments and the glow 1 / distance; the E stutters now and then, and the tubes buzz brighter with the bass.
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; }
// Is anything playing? (Examples fake their input when not.)
bool silent() { return spectrum.x + spectrum.y + spectrum.z < 0.0001; }
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))); }
float segment(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
return length(pa - ba * clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0));
}
// Letters in a 0.5 x 1.1 box, as line segments.
float letterO(vec2 p) { return min(min(segment(p, vec2(0.0, 0.1), vec2(0.0, 1.0)), segment(p, vec2(0.5, 0.1), vec2(0.5, 1.0))), min(segment(p, vec2(0.1, 0.0), vec2(0.4, 0.0)), segment(p, vec2(0.1, 1.1), vec2(0.4, 1.1)))); }
float letterP(vec2 p) { return min(min(segment(p, vec2(0.0), vec2(0.0, 1.1)), segment(p, vec2(0.0, 1.1), vec2(0.45, 1.1))), min(segment(p, vec2(0.5, 1.05), vec2(0.5, 0.6)), segment(p, vec2(0.45, 0.55), vec2(0.0, 0.55)))); }
float letterE(vec2 p) { return min(min(segment(p, vec2(0.5, 0.0), vec2(0.0, 0.0)), segment(p, vec2(0.0), vec2(0.0, 1.1))), min(segment(p, vec2(0.0, 1.1), vec2(0.5, 1.1)), segment(p, vec2(0.0, 0.55), vec2(0.4, 0.55)))); }
float letterN(vec2 p) { return min(min(segment(p, vec2(0.0), vec2(0.0, 1.1)), segment(p, vec2(0.0, 1.1), vec2(0.5, 0.0))), segment(p, vec2(0.5, 0.0), vec2(0.5, 1.1))); }
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
// Bricks.
vec2 b = uv * vec2(8.0, 16.0);
b.x += step(1.0, mod(floor(b.y), 2.0)) * 0.5;
vec2 bf = fract(b);
vec3 col = vec3(0.12, 0.05, 0.04) * (0.7 + 0.3 * hash(floor(b))) * smoothstep(0.0, 0.06, min(min(bf.x, 1.0 - bf.x) * 0.5, min(bf.y, 1.0 - bf.y)));
vec2 p = (uv + vec2(0.62, 0.17)) / 0.3;
float buzz = silent() ? 0.8 + 0.2 * kick() : 0.7 + spectrum.x * 0.8;
float eOn = step(0.12, hash(floor(time * 12.0))) * step(0.3, fract(time * 0.13) + 0.25);
float d = min(letterO(p), letterP(p - vec2(0.9, 0.0)));
d = min(d, letterN(p - vec2(2.7, 0.0)));
float e = letterE(p - vec2(1.8, 0.0));
vec3 pink = vec3(1.0, 0.2, 0.6);
col += pink * (0.02 / (d + 0.02) * 0.6 + smoothstep(0.05, 0.0, d)) * buzz * 0.45;
col += pink * (0.02 / (e + 0.02) * 0.6 + smoothstep(0.05, 0.0, e)) * buzz * 0.45 * eOn;
// A blue frame.
float frame = abs(max(abs(uv.x) - 0.78, abs(uv.y) - 0.3));
col += vec3(0.2, 0.5, 1.0) * (0.004 / (frame + 0.004) * 0.5 + smoothstep(0.008, 0.0, frame)) * buzz * (1.0 + kick() * 0.5);
fragColor = vec4(1.0 - exp(-col * 1.5), 1.0);
}More Audio-reactive examples
Grid pulses · Feedback mandala · 3D bar ring · Swarm · Ribbons · Bead knot