Clifford dust (WebGPU)
glint · Examples · Tutorials · Gallery
A million points hopping round a Clifford attractor; where they pile up is the picture, and its four numbers wander, so the dust keeps reforming into new silk-like shapes. Needs WebGPU (Chrome, Edge, Safari 26).
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 WGSL and GLSL.
Dust: WGSL module
// A million points, each hopping round the Clifford attractor (x' = sin(a y) + c cos(a x), y' = sin(b x) + d cos(b y))
// a few times a frame. Where they pile up is the picture; a, b, c, d wander slowly, so it never stops changing.
struct Particle {
pos: vec2f,
}
fn hash(n: u32) -> f32 {
var x = n * 747796405u + 2891336453u;
x = ((x >> ((x >> 28u) + 4u)) ^ x) * 277803737u;
return f32((x >> 22u) ^ x) / 4294967295.0;
}
fn hash3(n: u32) -> vec3f { return vec3f(hash(n), hash(n + 1u), hash(n + 2u)); }
// A 3D view: turn about y, tilt about x, perspective; returns clip position and depth.
fn view3(p: vec3f, yaw: f32, pitch: f32, dist: f32) -> vec4f {
let cy = cos(yaw);
let sy = sin(yaw);
var q = vec3f(p.x * cy - p.z * sy, p.y, p.x * sy + p.z * cy);
let cp = cos(pitch);
let sp = sin(pitch);
q = vec3f(q.x, q.y * cp - q.z * sp, q.y * sp + q.z * cp);
let z = q.z + dist;
let aspect = glint.resolution.x / glint.resolution.y;
return vec4f(q.x / z * 1.8 / aspect, q.y / z * 1.8, 0.0, z);
}
fn coefs() -> vec4f {
let t = glint.time * params.drift * 0.03;
return vec4f(-1.4 + 0.3 * sin(t), 1.6 + 0.2 * sin(t * 1.3 + 1.0), 1.0 + 0.2 * sin(t * 0.7 + 2.0), 0.7 + 0.25 * sin(t * 1.1 + 3.0));
}
@compute @workgroup_size(64)
fn init(@builtin(global_invocation_id) id: vec3u) {
let i = id.x;
if (i >= glint.count) { return; }
particles[i].pos = (vec2f(hash(i * 2u), hash(i * 2u + 1u)) - 0.5) * 4.0;
}
@compute @workgroup_size(64)
fn update(@builtin(global_invocation_id) id: vec3u) {
let i = id.x;
if (i >= glint.count) { return; }
let k = coefs();
var p = particles[i].pos;
for (var n = 0; n < 4; n++) {
p = vec2f(sin(k.x * p.y) + k.z * cos(k.x * p.x), sin(k.y * p.x) + k.w * cos(k.y * p.y));
}
// Now and then, a fresh start (keeps the cloud from collapsing onto a few orbits).
if (hash(i + glint.frame * 977u) < 0.002) { p = (vec2f(hash(i * 5u + glint.frame), hash(i * 3u + glint.frame)) - 0.5) * 4.0; }
particles[i].pos = p;
}
struct VOut {
@builtin(position) pos: vec4f,
@location(0) color: vec3f,
}
@vertex
fn vs(@builtin(instance_index) i: u32) -> VOut {
let p = particles[i].pos;
let aspect = glint.resolution.x / glint.resolution.y;
var o: VOut;
o.pos = vec4f(p.x * 0.42 / aspect, p.y * 0.42, 0.0, 1.0);
// Colour by where it came from (its index), so the strands carry hues through each other.
let h = hash(i);
o.color = (0.55 + 0.45 * cos(6.2832 * (h * 0.35 + vec3f(0.0, 0.25, 0.55) + glint.time * 0.02))) * params.brightness * (1.0 + glint.beat * 0.6);
return o;
}
@fragment
fn fs(v: VOut) -> @location(0) vec4f {
return vec4f(v.color, 1.0);
}Glow: fragment shader
#version 300 es
precision highp float;
uniform vec2 resolution;
uniform sampler2D pass0;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec2 uv = gl_FragCoord.xy / resolution;
vec2 px = 1.0 / resolution;
vec3 col = texture(pass0, uv).rgb;
vec3 halo = vec3(0.0);
for (int ring = 1; ring <= 3; ring++) {
float r = float(ring * ring) * 2.0;
for (int k = 0; k < 8; k++) {
float a = float(k) * 0.785398 + float(ring) * 0.4;
halo += texture(pass0, uv + vec2(cos(a), sin(a)) * r * px).rgb / float(ring * 8);
}
}
col += halo * 0.5;
fragColor = vec4(1.0 - exp(-col * 2.2), 1.0);
}More WebGPU examples
Galaxy (WebGPU) · Murmuration (WebGPU) · Galaxy collision (WebGPU) · Lorenz cloud (WebGPU) · Fireworks (WebGPU) · Fountain (WebGPU) · Silk (WebGPU) · Shape shifter (WebGPU)