Bead knot
glint · Examples · Tutorials · Gallery
Two hundred instanced spheres threaded on a (3, 2) torus knot, sliding along it, each bead's size from the spectrum at its place on the string.
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.
vertex shader
#version 300 es
in vec4 a_position;
in vec3 a_normal;
uniform mat4 mvp;
uniform mat3 normalMatrix;
uniform int instanceCount;
uniform float time;
uniform vec3 spectrum;
uniform float beat;
uniform float beatTime;
uniform int beatCount;
uniform sampler2D fft;
float kick() { return beatCount > 0 ? beat : pow(1.0 - fract(time * 2.0), 4.0); }
float sinceKick() { return beatCount > 0 ? beatTime : fract(time * 2.0) / 2.0; }
float kickId() { return beatCount > 0 ? float(beatCount) : floor(time * 2.0); }
bool silent() { return spectrum.x + spectrum.y + spectrum.z < 0.0001; }
float bin(float x) { return silent() ? 0.35 + 0.3 * sin(x * 40.0 - time * 3.0) : texture(fft, vec2(x, 0.25)).r; }
float hash(float n) { return fract(sin(n * 127.1) * 43758.5453); }
out vec3 v_normal;
out vec3 v_color;
// A (p, q) torus knot: winds p times round the axis while going q times through the hole.
vec3 knot(float t) {
float p = 3.0, q = 2.0;
float r = 0.8 + 0.35 * cos(q * t);
return vec3(r * cos(p * t), 0.35 * sin(q * t), r * sin(p * t));
}
void main() {
float i = float(gl_InstanceID) / float(instanceCount);
float t = (i + time * 0.02) * 6.28318;
float size = 0.03 + 0.07 * bin(0.01 + abs(fract(i * 2.0) - 0.5) * 0.8) + 0.02 * kick();
vec3 p = a_position.xyz * size * 2.0 + knot(t);
v_normal = normalMatrix * a_normal;
v_color = 0.5 + 0.5 * cos(6.28318 * (i * 2.0 + vec3(0.0, 0.33, 0.67)));
gl_Position = mvp * vec4(p, 1.0);
}fragment shader
#version 300 es
precision highp float;
in vec3 v_normal;
in vec3 v_color;
out vec4 fragColor;
void main() {
vec3 n = normalize(v_normal);
vec3 l = normalize(vec3(0.4, 0.9, 0.5));
float spec = pow(max(dot(reflect(-l, n), vec3(0.0, 0.0, 1.0)), 0.0), 24.0);
fragColor = vec4(v_color * (0.25 + 0.75 * max(dot(n, l), 0.0)) + spec * 0.4, 1.0);
}More Audio-reactive examples
3D bar ring · Swarm · Neon sign · Ribbons