Cellular colony growth over live HTML

I wanted to know if a ping-pong framebuffer simulation can run on the GPU without pixel readback to grow organic cellular colonies from every tap on a live HTML card, inverting typography, checkboxes and buttons wherever the cells spread while every control stays clickable. Tap anywhere on the card, toggle the checklist, type a new specimen word or switch strain.

0 taps · ~0% · MOSS
PLATE 04 · AGAR-GL STRAIN: MOSS

Cellular colony growth

Tap anywhere on this dish, or toggle any control below, to seed a colony. Cells feed faster along dark ink and invert every glyph they cross.

Initialising ElementGL WebGL 2 dish...

Show the code drawable specimen card, RGBA8 ping-pong shaders, hit sync and 2D fallback
  1. One live specimen card inside a drawable canvas. Keeps semantic headings, checkboxes, an editable text <input> and strain buttons directly in the DOM tree inside <canvas content="drawable" layoutsubtree>.
  2. Top-down simulation and Voronoi composite shaders. Runs an extension-free RGBA8 reaction-diffusion step in SIM_FS using matching top-down UVs, then draws Voronoi cell walls and inverted palettes over uTex in COLONY_FRAG.
  3. Dual-buffer ping-pong loop without readback. Swaps two 192×256 RGBA8 framebuffers directly on the GPU for 200 steps per tap and stops automatically once the wave settles.
  4. Hit-box calibration and coordinate mapping. Calls updateElementGeometry() scaled by geometryUnit(), toggles dataset.hitTick, and maps taps on controls to card UVs without swallowing native clicks.
  5. 5-argument 2D and plain-HTML fallbacks. Draws drawElementImage(cardEl, 0, 0, w, h) with difference-blended organic blotches on 2D, or moves the card to #plain-host on context loss.

How it works

This experiment rebuilds sucodee's Colony Card (original post) using HTML-in-canvas. Instead of cloning text into static canvas layers, the entire specimen card lives inside one <canvas content="drawable" layoutsubtree> managed by a single ElementGL WebGL 2 context.

On the first paint event (and whenever you type, check a box or switch strain), stage.upload(cardEl) uploads the card into an RGBA8 texture with gl.texElementSubImage2D(). Two compact 192×256 RGBA8 framebuffers swap each step on the GPU with zero float-texture extensions and zero pixel readback: red tracks active dividing biomass, green tracks agar nutrient, and blue stores persistent colonised territory. Both the ping-pong vertex shader and ElementGL use top-down UVs (v = 0 at the top of the DOM card, v = 1 at the bottom), so stepping across the two buffers never flips the image vertically.

During each simulation step, SIM_FS reads the card texture to boost nutrient renewal slightly over dark ink, making colonies creep faster along letters and borders. COLONY_FRAG then evaluates a device-DPI Voronoi cell field over the smoothed colony territory, inverting dark typography and borders to luminous strain ink, shifting pale card paper to deep bio-ink, and lighting the advancing frontier with a proliferating membrane rim. Because WebGL draws don't move Chromium's hit boxes, syncCardGeometry() calibrates updateElementGeometry() with geometryUnit() and toggles dataset.hitTick so every checkbox, text field and button stays tappable. When prefers-reduced-motion: reduce is on, continuous animation pauses and taps stamp static cellular rings instead.

Live checks

These checks wait for a tap so the page opens with one WebGL context. Each check builds an isolated fixture on the test stage and retires its canvas before the next check runs.

Findings