← Ian Ramos
how I built it

Vesper

A starling murmuration over an animated dusk sky, in plain Three.js. Clicking startles the flock, and the panic spreads through it in a chain reaction. The work was mostly about performance: the sky used to cost more than the birds.

Try Vesper →

Stack

Rendering
Three.js, no framework: one imperative loop with nothing between it and WebGL
Birds
Three instanced meshes: body and both wings for 300 birds in three draw calls
Sky
A GLSL fragment shader: moved from the CPU to the GPU
Simulation
Plain TypeScript, no DOM: runs in Node for benchmarks

Notes

The flock

Birds follow group leaders and steer in one pass over their neighbours, found through a 3×3×3-cell spatial grid. A click sends a disturbance through the flock that spreads over about 200 ms, which is what makes it ripple like a real murmuration.

Moving the sky to the GPU

The sky was recomputed on the CPU every frame: 131,000 noise calls and a 512 KB texture upload, most of the frame time. I ported the noise function to GLSL with the same permutation table, so the shader draws the same sky: screenshots differ by at most one colour level on about 0.01% of pixels.

Refactoring without changing the look

Some of the look comes from accidents in the original code, such as bodies that are not quite on their own bird. A benchmark harness records every position, velocity, instance matrix and colour, every frame, so a refactor has to be identical to count as a refactor. Anything else is a behaviour change, checked by eye.