Hex pulse
glint · Examples · Tutorials · Gallery
A honeycomb that lights up in rings spreading from the middle on every kick, tinted by the spectrum around the circle.
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))); }
// Nearest hexagon centre (in hex-grid units) and the position inside it.
vec4 hexCell(vec2 p) {
vec2 s = vec2(1.0, 1.7320508);
vec2 a = mod(p, s) - s * 0.5;
vec2 b = mod(p - s * 0.5, s) - s * 0.5;
vec2 g = dot(a, a) < dot(b, b) ? a : b;
return vec4(g, p - g);
}
void main() {
vec2 uv = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
vec4 h = hexCell(uv * 12.0);
vec2 centre = h.zw / 12.0;
// Hexagonal distance from the cell centre: 0.5 on the edge.
float edge = max(dot(abs(h.xy), normalize(vec2(1.0, 1.7320508))), abs(h.x));
float dist = length(centre);
// A ring of light leaving the middle at each kick.
float ring = exp(-abs(dist - sinceKick() * 1.2) * 18.0) * exp(-sinceKick() * 1.5);
float ang = fract(atan(centre.y, centre.x) / 6.28318 + 0.5);
float lv = bin(0.02 + ang * 0.3);
vec3 tint = pal(ang + time * 0.03);
float on = ring * 1.5 + lv * 0.8 * smoothstep(0.9, 0.2, dist) + 0.04;
float cell = smoothstep(0.5, 0.44, edge);
vec3 col = tint * on * cell + tint * 0.06 * smoothstep(0.02, 0.0, abs(edge - 0.47));
fragColor = vec4(col * (1.0 + kick() * 0.3), 1.0);
}More Audio-reactive examples
Bass blob · Vinyl · Sonar · Neon runner · Spectrum flower · Starburst · Mirror bars · Punch zoom