Loose mosaic wall
WebGL film: glass and gold leaf, figures as flocks of tiles
- 0–2.4 s the quiet wall, a band of light wandering across the gold, single tiles hopping out or re-seating themselves
- 2.4–7.3 s the fish lifts out of the sea tile by tile, mortar crumbs jump with it, it swims and turns
- 7.3–10.2 s a leap through the gold ground, the swallow lifts off the wall
- 10.2–13.3 s the fish dives in, spray flies, a ring wave of flipping tiles runs through the sea
- 13.3–20 s first the fish clicks in, then the swallow — every tile back into its own socket
- Mosaic
- 20 s Loop
- 1080² · 30 fps
- WebGL2
- 4.4 MB
Prompt
Build a 20-second looping animated film, 1080×1080, in WebGL2 and plain JavaScript (no libraries, no image, font or audio files): a wall mosaic of glass and gold-leaf tesserae that were never glued down. Figures are flocks of tiles — they lift out of the wall, flip, fly, and click back into their own sockets.
DESIGN
Every tessera is a real small 3D tile, instanced: about 15.6 px tall, 13–20 px long, 7 px thick, with a narrow bevel, corners slightly irregular, joints of 2.2 px, each tile tilted a few degrees at random (gold tiles more, some steeply, so the ground sparkles).
Layout (generated once from a seeded PRNG): upper two thirds a gold ground in straight rows; the lowest two gold rows follow the sea's wavy edge. Lower third a sea band in wavy parallel rows — a foam row of white and pale aqua on top, then turquoise, cobalt, ultramarine and deep blue bands. Depicted in the wall: a fish in side view in the sea (silver outline row, teal/turquoise back, pearl belly, silver lateral line, coral and orange fins, a black eye tile) and a swallow seen from above in the sky (blue-black outline, cobalt and night-blue rows, red face, white tail prongs). Lay the figures like a mosaicist: compute an exact signed distance field of each silhouette, extract its offset contours with marching squares, and set tiles along them — outline row first, rows inward, then one or two halo rows outside (sea glass around the fish, gold around the swallow). Fill remaining gaps with cut pieces (14 → 6 px) aligned to the nearest contour.
Setting bed: bake a height map from the layout — every tile leaves its own socket, with ridges of squeezed-up mortar between them. Shade it with normals from that map so the ridges catch the raking light and throw a short shadow, add grit in the sockets and slow tonal variation. Seated tiles cast a contact shadow onto the bed, projected from the light: joints go dark, and an empty hole reads as a field of imprints with a shadowed rim.
Materials: gold = metal, eight alloy tones (yellow, red, green and pale gold), about one tile in seven worn and matte, a soft leaf crinkle plus fine scratches in one direction per tile, GGX highlight and an environment reflection with two soft bright "windows", so each tile's tilt decides whether it flashes. Glass = coloured albedo, brighter toward the edges and deeper in the core, small frozen air bubbles, a clear-coat highlight and Fresnel reflection; bevels glow with colour. Silver tiles in the fish. Tile backs pale rough cement — visible whenever a tile flips. Light: one fixed point light high above the upper left of the wall, plus a slow band of brightness that travels diagonally across the wall; outside the band the wall stays pixel-stable. Lifted tiles cast soft shadows projected from the light, softer and lighter the higher they fly. ACES tone mapping, gentle vignette. No text. All micro detail is fixed to the tile or the wall — nothing is re-rolled per frame, so seated tiles stay pixel-stable.
STORYBOARD
0–2.4 Quiet wall; the band of light wanders across the gold. Two gold tiles hop out, flip and click back in; two others only re-seat themselves with a small twist.
2.4–7.3 The fish lifts out of the sea head first: each tile gives a tiny jerk, rises, then flips once it is clear of the wall; mortar crumbs jump with it and come to rest in the open sockets; neighbouring tiles twitch. It swims right, its body undulating, and turns at the right edge by yawing about its vertical axis — head toward us, tail away.
7.3–10.2 It leaps up-left through the gold sky, rising higher off the wall, and comes down in a slanted arc. At 10.0 the swallow lifts off its spot in the wall the same way.
10.2–13.3 The nose goes in: spray tiles are thrown up and outward on parabolas, each with its own height and hang time, and a ring wave runs across the sea at 330 px/s — near the splash the tiles roll right over (pale backs read as foam), farther out they only lean; two weaker rings follow. The swallow flies one wide loop and glides low over the water behind the wave.
13.3–20 The fish glides into its hole and its tiles land from 13.6 to 14.7: each flips once at hover height, drops, clicks into its exact socket with a short glint, and pushes its neighbours aside by a pixel or two. The swallow flies home alone and lands from 17.7 to 18.7. Two more gold tiles hop near the end, then the quiet wall again.
MOTION
Each figure follows a timed Hermite path with zero velocity at its socket; every tile samples the path slightly later the farther it sits from the head, so the body bends through turns while the formation stays tight and the silhouette readable in every frame. Lift and landing are staggered head to tail with a little random offset. Wing beats rotate each wing's tiles about the body axis, more up than down, so no tile sinks into the wall; nothing may pass through the wall or start flipping before it is clear of it. Motion blur: average three samples across a 0.42-frame shutter while holding the light at the frame time. Render 2× supersampled with 4× MSAA, then downsample.
TECHNIQUE
- One self-contained HTML page plus one JS file (no inline script, no libraries, no network requests). Stage exactly 1080×1080 CSS px, or the size named above (1080×1920 for portrait).
- Expose window.MOTION = { duration, fps: 30, width, height, seek(t) } with the stage size in width and height. seek(t) redraws the frame for time t from scratch: no state between frames, no Math.random (seeded PRNG only), no Date, no CSS transitions, no timers.
- Loop: seek(0) and seek(duration) must look identical.
- With ?render=1 the stage sits unscaled at the top left (for frame capture). Without it, scale the stage to fit the window and loop with requestAnimationFrame.
- prefers-reduced-motion: show one representative still, no loop.
CHECK
Render stills at the listed times, look at every one, fix anything that overlaps, is cut off, aliased or unreadable, then render again. Report only when frame 0 equals the last frame.
Stills: every 0.5 s, plus every 0.1 s around 2.4, 6.3, 7.3, 9.3, 10.2, 13.2–15 and 17.5–20. How to recreate it
-
Give the prompt to a coding agent
Create an empty folder and paste the prompt into Claude Code, Codex or Cursor. The agent writes one HTML page and one script — the animation then runs right in the browser.
-
Let it check the stills
The prompt makes the agent render stills and look at them itself. Only refine what you don't like in the picture: “scene 3 is too busy” works better than a new prompt.
-
Render to MP4
Because every animation can draw any frame exactly through
window.MOTION.seek(t), a small script renders it frame by frame — no stutter, no screen recording. Then ffmpeg joins the frames into a clip.
# 1 · Render every frame (Chrome, Node ≥ 22) node render.mjs http://localhost:3000/ \ frames/ frames 30 # 2 · Join the frames into an MP4 ffmpeg -framerate 30 -i frames/%05d.png \ -c:v libx264 -preset slow -crf 22 \ -pix_fmt yuv420p -movflags +faststart \ my-motion.mp4
Background
A wall of about 4,200 glass and gold-leaf tesserae that were never glued down: a fish lifts out of the sea and leaps through the gold, a swallow takes off, a ring wave of flipping tiles runs through the water — and in the end every tile clicks back into its own socket. 20 seconds of WebGL2, no library, with the prompt.
What I learned building it
A mosaic only looks real when the rows follow the contours, so I computed a distance field for each figure and laid the tiles along its contour lines. You only read that tiles are missing once the setting bed shows their imprints. And gold reads as metal not because of its colour but because every single tile is tilted slightly differently.
Inspiration
The starting point was a prompt by @zeezomb ((opens in a new tab)) on Skillry. You'll find the original wording there; the prompt above is my own version.
More motions
-
An agent platform, introduced UI motion 0:15 -
Agents that pick the model UI motion 0:14 -
A sentence becomes an app UI motion 0:15 -
An operating system, introduced UI motion 0:47.2 -
Your new design partner Voice-over 0:54.3 -
Ten kilometres, floating UGC ad 0:12.6 -
The journey of an order Explainer 0:34 -
Make it move Kinetic typography 0:08 -
From noise to a workflow Particles 0:14 -
The Gimli Glider Voice-over 0:19 -
Oscilloscope intro Oscilloscope 0:20 -
A keystroke in cross-section Explainer 0:20 -
A ring called Orbit UI motion 0:10 -
The bug that wants to stay Short film 0:20 -
Shin, not foot Voice-over 0:17 -
Jellyfish in a light shaft Organic loop 0:18 -
A logo that comes alive Logo reveal 0:08 -
How circles draw any shape Explainer 0:20 -
Pixel wizard Pixel art 0:16 -
The shortest war Voice-over 0:16 -
Near fall Physics simulation 0:09 -
A Negroni, explained Explainer 0:20 -
Where the fuel money goes Voice-over 0:19.5 -
One print, nothing else Title sequence 0:20 -
Infinite zoom into the detail Infinite zoom 0:15 -
Cube stack Short film 0:07 -
A request at 22:47 Chat story 0:17 -
Claude Code in three steps Voice-over 0:17.5 -
The inbox factory Isometric loop 0:12 -
From 0 to 100 % soft Physics simulation 0:10 -
One line, three inks Showreel 0:20 -
The request breaks out Physics simulation 0:15 -
The slicing machine Isometric loop 0:09 -
How backlinks work Explainer 0:20 -
A ball that grows with every bounce Physics simulation 0:10 -
One shape, fourteen states UI motion 0:14 -
What makes a home Paper cut-out 0:20 -
Words that carry Kinetic typography 0:20 -
Shard logo reveal Logo reveal 0:11