How it works
A sheet of paper lies over an editorial hero, its headline faintly embossed into the sheet. Wherever the cursor touches it, the sheet ignites. A thin blackbody-orange ember line creeps outward through the fibres, scorching the paper ahead of it and leaving curled black char behind, until the sheet burns through and the page beneath shows. Once the fire is out and the cursor has moved on, the burn plays backwards and the sheet heals. The one idea that makes it work is that the fire is a travel-time field, not a grid of on/off cells. Every cell stores how long ago the front reached it, so the burning edge is a level set that can be drawn at full resolution from a simulation a third that size. The other half of the job is keeping that field clean where fires overlap and heal, so a filtered burn-depth pass sits between the simulation and everything that draws it.
Pipeline (per frame)
pointer (window, passive) ─▶ capsule from last frame's position to this one, sub-frame timed │ ├─ CLOCK heal clock a ← min(a + dt, neighbours + k·dist, RG32F 871×490 NEAREST, texelFetch only │ time since this cell's burn ended, cursor cone) │ reheat clock g ← min(g + dt, steep cone around the cursor) ├─ STATE ×1–4 relax τ against 16 neighbours (8 + knight moves) RGBA32F 871×490 ping-pong: τ arrival (s), e reach, │ + brush (ignite / predict, directional) + heal (sub-frame) H heal 0..1, fire id │ + settled-depth erosion + reach cap under the HUD row │ └ reads MEDIUM speed, fuel cost, grain cos2θ/sin2θ RGBA16F 871×490 rebuilt only when fibre params change ├─ BURN b = min(τ·v, min(e, R)) − S·H, clamped to the visible RGBA16F 871×490 b, ember temperature θ, heal H, │ band, 3×3 binomial; θ and H through the same filter pointer reheat (only reader of raw state) ├─ SPARKS respawn by rejection sampling on the hot front RGBA32F 64×64 4096 particles (uv, age, seed) ├─ EMIT blackbody(θ·Tpeak)·θ⁴ ember light | α = paper coverage RGBA16F 1280×720 │ └ sparks soft capsule quads, additive (alpha untouched) → EMIT ├─ BLOOM 5× down (5 taps) → 4× up (8 taps of the lower level RGBA16F 640×360 … 40×23 │ + 1 of the higher); α carries a multi-scale blur of the coverage (shadow mask) ├─ DISPLAY paper tile + embossed headline ─ scorch ─ lit char lip canvas 2560×1440 │ ─ page beneath (soft shadow, heat haze, warm light at the cursor) ─ ember line ─ bloom ─ shoulder ─ sRGB ─ dither │ ├ BURN via cubic B-spline (4 bilinear taps); pixels deep inside a hole take a short path │ ├ paper tile: 2D canvas, fibres + formation + grain RGBA8 1024² tileable, mipmapped │ ├ page: 2D canvas editorial layout SRGB8_ALPHA8 2560×1440 (sampled linear) │ ├ headline mask: same layout, headline only R8 1280×720, mipmapped (the mips are the bevel) │ └ blackbody LUT (Krystek 1985, 500–4000 K) RGBA16F 256×1 └─ SPARKS soft capsule quads, additive, on top canvas
The ideas that matter
- Travel time, not cell states. A cellular automaton (unburnt, burning, ash) draws a stair-stepped edge, and its fronts grow as diamonds. Here each cell stores
τ, the seconds since the front arrived. Each frame, every unburnt cell takes the best offer from 16 neighbours,τ = max(τₙ − |offset| / v). That is a Dijkstra/Huygens front through a random medium: a 16-gon, about 3% from round. The ember line, char band, ash fringe and hole are all level sets of one burn depthb = min(τ·v, e), in screen units. Glow width and char width are distances, not durations. - Filter the burn depth, never the raw state. Interpolating
τ,eandHseparately and only then takingminlets a jump in any of them leak through the spline as blocky contours; an untouched-cell sentinel leaks even further. So one BURN pass computesbper cell, clamps it to a narrow band around the visible features (scorch width plus a few cells below, char width plus a few cells above) and runs a 3×3 binomial over it. The lattice front leaves cell-scale structure, such as checkers where fires meet and alternating columns where relit and old cells interleave. The binomial removes exactly those modes and leaves the 5–15-cell-wide band ramps alone. Everything that draws (display, emission, spark spawning) reads only this texture. - A prediction band ahead of the front. Arrival times propagate about 2.5 hops ahead of the fire as negative
τ. That keeps the field continuous across the front, and it is what scorches the paper just before it catches. The brush writes the same ramp, with the paper's own directional speed and fuel cost, past the visible scorch width, so there is never an edge where it stopped writing. - Fingering comes from the paper, plus a fuel budget. Speed and fuel cost come from fbm stretched along a slowly wandering grain direction, plus ridged “veins”. Reach
edrops with distance × local fuel cost, so each burn dies irregularly and runs furthest down fast, cheap veins. Grain and updraft give each direction of travel a factorf = (1 + g·(2cos²θ − 1))·(1 + u·dy): the hop speed is multiplied byfand the fuel cost byf^−1.2. The cost is floored at 0.4, because reach that decays too slowly spreads the char rim (char width ÷ the slope ofb) into a wide black smear. The brush writes its first ramp with the same factors. In side-by-side tests of the same short stroke, maximum grain took the hole's aspect from 1.2 to 1.6 along the grain, and maximum updraft burnt about 2.4 times further up from the stroke than down. Burns run further along the grain and up the sheet, not just sooner. - Healing is the burn played backwards, on a smooth clock. Fading paper back in looks like a dissolve. Here heal progress
Hslidesbdown byS·H, so every hole closes from its rim inward with its char and scorch rims intact, and the scorch fades last. Heal progress only advances where the heal clock has passed the heal delay. That clock is the time since anything happened nearby: the cursor passed (a cone of at most 10 s per screen unit), or this cell's own burn ended, which isτ − e/vexactly rather than a frame count. It is Lipschitz-limited against its neighbours every frame, so no cell starts healing seconds before the one next to it. It is 32-bit, so a dt-sized increment never rounds away at 120 Hz. Heal is credited from the sub-frame moment the clock crossed the delay. Cells that cross in the same frame therefore still differ, and a fast heal closes as one smooth front instead of terraces. - Healed means healed, whatever the sliders say.
Sis today's reach + brush + scorch, and every read clamps a cell's stored reach to today's reach + brush. A hole burnt at a large Reach or Brush size still slides fully out of sight atH = 1after the slider is turned down, and can be burnt again. Reset starts over on a fresh sheet. While a sheet regrows, its char lip uncurls and loses its sheen, the deep scorch tone and the smouldering brown fade first, and the fibre fray on its edge grows a little. Closing slots then read as dry char, not lit rubber tubes or coffee stains. - Settled burns can't hold a cliff. Where a healed patch meets an open one, a finished burn may stand at most 3 cells per cell above its lowest finished neighbour. Anything steeper erodes, meaning it heals down to that slope (an octagonal limiter over 8 neighbours). The meeting line then closes as a ramp with its own char and scorch bands instead of leaving a seam. Live fire is exempt, so the limiter never stops a front.
- Fires never feed back on themselves. Each ignition carries a quarter-second fire id. A cell that has already burnt relights only from a fire more than about 1 s newer, and char relights only when a real front arrives with fuel left. Reach under the cursor is a smooth distance-to-stroke, not whatever the first capsule happened to write.
- The cursor is always a lit match. A second, steeper clock tracks how recently the cursor passed within about a brush radius. BURN turns it into reheat, which raises ember heat and smoulder on any char it touches. Rubbing an old, cold rim makes it glow again and throw sparks without changing what is burnt, and a small warm pool of light trails the cursor across the revealed page.
- A resting sheet that still reads. The headline is drawn a second time, white on black, into a half-resolution mask. Its mipmaps serve as a soft bevel, and two taps offset toward the light blind-emboss it into the paper. When everything has healed, the hero is a debossed headline on a sheet that promises to be burnt, not a blank rectangle.
- Glow that reads on a light page. Additive flames on cream paper look like orange stickers. A burning sheet, though, always puts its glow on black char. Each cell carries an ember temperature
θ = T/Tpeak. The colour comes from a blackbody LUT atθ·Tpeak, and the brightness goes asθ⁴, applied once.θcools asexp(−τ / 4·afterglow), so brightness falls to 1/e in one afterglow time. A front running out of fuel cools only to about ⅔ ofTpeak. A dimmer, redder ember line therefore keeps creeping until the front stops, then glows on along the final rim. The line is hottest at the leading edge, with slow-drifting hot spots, smouldering specks and sparks on top. The result is HDR into a per-channel shoulder, so hot cores clip toward yellow-white. Bloom adds a halo around a line that is already bright without it. - Depth for free, and a scorch tone per paper. Paper coverage rides along in the bloom chain's alpha, which yields a multi-scale blurred mask. Sampled toward the light, that mask is the soft shadow the sheet casts on the page beneath. The char lip is a height ramp toward the hole edge, lit from the top left with a dull sheen. Each preset picks a scorch tone: brown on cream, a desaturated navy-black on blueprint blue, and a lift toward grey ash on charcoal, where darkening would only look dirty.
- The controls stay on paper. Under the HUD row, a cell's reach is capped by a ramp that falls to light scorch at the HUD's lower edge, measured from the DOM on every resize. The cap wobbles with the paper's speed field. A burn that runs up the page stops raggedly just below the buttons, and their dark text never sits over the dark page beneath.
- Sparks with no readback. Each dead particle tries one random spot per frame and is born only if the front is bright there, in proportion to
θ⁴. The spawn rate therefore follows the length of the burning edge. Motion is analytic in (seed, age), so there is no velocity state to integrate. Each spark is drawn as a soft capsule quad about 2–3 px across, from where it was a streak-time ago to now.
Parameters
Presets
Performance & compatibility
- Measured on an Apple M-series Mac at 2560×1440. On an otherwise idle GPU, the harness sweep costs 1.8 ms mean GPU per frame (p95 2.8–5.1 ms). Across five full harness runs with other runs sharing the GPU, it was 2.7–4.7 ms mean (p95 6.4–8.2 ms). After this round's changes (directional brush, heal and glow fixes, the HUD band), full harness runs on a busy shared GPU measured 4.2–4.3 ms mean (p95 8.2–8.5 ms). An alternating A/B of 3 s sweeps against the previous version measured 2.0–3.5 ms mean for this version and 2.3–3.4 ms for the previous one, so there is no measurable cost change. JS is about 0.1 ms per frame, and the sweep holds 60 fps. Cost scales with burnt area. In scripted phases on a shared GPU: a small burn 2.6–4.0 ms mean (p95 3.8–6.2), a continuous 6 s scribble 3.5–5.3 ms (p95 6.1–7.8), and a screen-wide hole 3.9–5.0 ms (p95 5.6–7.7).
- What scales the cost: the sim is 0.34 × the canvas short side (at most 512, here 871×490). It takes 1 relaxation step per frame at the default spread, up to 4 at maximum. Untouched cells skip the knight taps, untouched paper pixels skip all burn shading, and pixels deep inside a hole skip the scorch, char and ember work. In skip tests the display pass and the bloom chain were roughly 1 ms each. The relaxation step reads its 8 near neighbours once and reuses them for the erosion limiter. Texture memory is an estimate of about 60 MB: 32-bit state and clocks 20 MB, the page 15 MB, the bloom chain and emission 12 MB, paper and mask 7 MB, medium and burn 7 MB. The browser's own canvas buffers come on top.
- Mobile: DPR 1.5, a 199×431 sim, 2048 sparks and a 512² paper tile. Lengths are measured in screen units of min(height, 1.4 × width), so on a tall phone a burn covers the same share of the width as on a desktop. Exposure and bloom drop to 0.55× and the bloom chain loses a level. A 390 px touch drag ran at 49 fps in the harness. The portrait layout re-flows the page, the intro stroke runs diagonally down from the headline through the deck into the body copy, and the heat haze is a third as strong, so the small body type stays sharp.
- Idle: the loop runs until the sheet has settled, not on a fixed timer. Each ignition sets a busy-until time: fire duration, heal delay, the heal clock's cone across the burn, the heal itself (or the embers' afterglow), capped at 40 s. The shell's 9.5 s idle timer then stops the loop. It stopped 10.6 s after the last input on Parchment and 11.6 s on Ash; a slowest-spread, longest-reach burn runs to the 40 s cap.
- Presets: switching preset, or pressing Reset, clears the sheet and replays the intro stroke, so every look opens on a live burn. Picking a dark paper colour switches the HUD to light text, and a light paper to dark text.
- Reduced motion: renders one still from 170 frames of the intro stroke, a mid-burn reveal, with a “Play anyway” button.
- Requirements: WebGL2 with
EXT_color_buffer_float(RGBA32F state and sparks, RG32F clocks, RGBA16F everything else). The 32-bit textures are only read withtexelFetch, so float-linear filtering is not needed. Without these the page shows the poster frame and a message. All textures are generated in the page (2D canvas paper, page and mask, JS blackbody LUT), with no network requests and system fonts only.
References & credits
- The “burning-paper” candidate and fire notes in
research/smoke-fire-ink.md(this library): char front, ember rim, scorch ramp and heal. - J. A. Sethian, Level Set Methods and Fast Marching Methods (Cambridge, 1999), https://math.berkeley.edu/~sethian/: fronts as arrival-time (eikonal) fields. Concept only.
- M. Krystek, “An algorithm to calculate correlated colour temperature”, Color Research & Application 10(1), 1985, https://doi.org/10.1002/col.5080100109: the rational Planckian-locus approximation used for the blackbody LUT. A published formula, re-implemented.
- D. Q. Nguyen, R. Fedkiw, H. W. Jensen, “Physically Based Modeling and Animation of Fire”, SIGGRAPH 2002, https://cseweb.ucsd.edu/~henrik/papers/fire/: blackbody emission with a T⁴ intensity. Concept only.
- C. Sigg, M. Hadwiger, “Fast Third-Order Texture Filtering”, GPU Gems 2 ch. 20, https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-20-fast-third-order-texture-filtering: a cubic B-spline from 4 bilinear taps. Technique, re-implemented.
- M. Bjørge, “Bandwidth-Efficient Rendering”, SIGGRAPH 2015, https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-20-66/siggraph2015_2D00_mmg_2D00_marius_2D00_slides.pdf: the dual-filter style down/up bloom chain. Technique, re-implemented.
- C. Wellons, “Prospecting for Hash Functions”, https://nullprogram.com/blog/2018/07/31/: the lowbias32 integer hash constants (public domain).
- T. Ettinger, mulberry32, https://gist.github.com/tommyettinger/46a874533244883189143505d203312c: the PRNG that seeds the paper tile (CC0 / public domain).
- Written from scratch for this library; no third-party code is included. The magazine, its copy and its byline are fictional.