tz.mt

Rendering a slime blob: an analytic SDF body, one transmission pass, and a 3 ms budget we sometimes missed

Mintie contributors

core stack 2026-10-30

Mintie is an open-source talking slime blob that runs in a browser tab (repo, live demo). The body has to look like translucent candy, squash and stretch when dragged, grow soft arms for gestures, and hold 60 fps next to a voice pipeline. This post covers how it is drawn, why we picked that over the obvious alternatives, and what the perf numbers said, including where we missed our own gate. Code links are pinned to release commit 1ea1104.

All measurements are from one machine (M1 Max, Chrome) unless stated. We have no phone or other-GPU data; WebKit and phone-sized viewports were only screenshot-checked, on earlier builds. Several early numbers (the three prototypes and some Oct 30-31 checks) come from our project log, not from saved raw samples; we say so where it matters.

Mintie at rest: a translucent green blob with two glossy black eyes on a warm-grey floor with a faint grid

Mintie at rest, default camera, release build. Captured from the open-source release code in Chrome for Testing 154 at device pixel ratio 2.

The constraints

We fixed kill criteria before prototyping:

Criterion

Gate

GPU time, p95

3 ms or less at device pixel ratio (DPR) 2, M1 Max

JS time, p95

2 ms or less

Visuals

no seams, correct depth, readable arm shapes

Dynamics

p95 2 ms or less, volume 0.90-1.10, penetration 1% or less

The release still enforces the first two: tools/check.mjs fails a row unless it holds 60 fps with JS p95 at most 2 ms and GPU p95 at most 3 ms, and the architecture doc lists the same budgets.

The body is a rounded dome with a flared base. It deforms (squash, lean, stretch, dents from touch, wobble) and grows and retracts arms from either side. Arms are not hands: we tried articulated hands, our owner rejected them as uncanny, and each arm is now one rounded nub of three tapered capsules.

Three representations, two killed

Full SDF raymarch. The whole character as a distance function. It looked best: arms unioned seamlessly, correct depth. GPU p95 was 9.4 ms at DPR 2 (7.3 ms at DPR 1.25). Killed on cost.

Full mesh. One rasterised body, deformed in the vertex shader. Fast, 2.23 ms at DPR 2. Killed on visuals: a crease and spike at the arm junction during deformation, faceted webbing between the then-articulated fingers, and a fixed topology cannot grow or retract an arm.

We rejected Gaussian splats without a prototype: no data-driven arm path, and research-grade tooling for a stylised original.

The hybrid we shipped. A rasterised body whose shape comes from an analytic SDF, plus raymarching only inside a small bounding proxy per arm. No arm, no raymarch cost.

Three columns comparing full raymarch, full mesh and the hybrid: boxes listing each approach, its GPU time and verdict

A diagram, not renders: the prototype captures of the raymarch and mesh builds were not preserved, and the shipped character looks different from both, so we do not fake them. Numbers are from our project log (GPU, DPR 2, M1 Max); the log does not record which pose the raymarch and mesh figures were taken in.

The body: an analytic SDF, sampled once

The body is a flared ellipsoid softly intersected with the floor. Its distance function (bodyDistance) is closed-form: a first-order distance estimate for an ellipsoid, a radius that tapers with height, a small flare at the base, and a smooth-min against a gently curved floor.

We do not march it on the GPU. At startup we sample it on the CPU: for each direction on a 112 by 72 grid (56 by 36 in reduced quality) we bisect 25 steps from the body's centre to find the surface. The result is a star-shaped analytic surface with no marching grid, no facets, and no hard seam at the floor.

The vertex shader deforms that mesh: up to four Gaussian dents along a surface normal and a travelling wobble, then one affine transform carrying squash, lean, stretch, shear, rigid yaw and the pendulum swing about the grab point. The same affine drives the arms and every surface anchor, so nothing drifts from the skin. Two details worth copying:

  • •

    A coarse 40 by 28 CPU copy exists only for pointer picking. The render mesh is never CPU-skinned.

  • •

    Anchors for eyes, mouth and cheeks come from finite differences: transform a surface point and two neighbours through the same warp and cross them. Decals follow dents and wobble.

Arms: raymarching inside a box

Each arm is three capsules smooth-unioned with the body SDF (buds.js). Its fragment shader raymarches only inside a bounding proxy, in body-local space with the warp inverted, so it shares the body's deformation exactly: up to 28 steps (22 reduced), hit threshold 0.001. The proxy is a screen-facing quad sized from the projected corners of the arm's bounding box. Three rules fixed the seam:

  • 1.

    Outside the arm's union influence, discard: the raster body owns colour and depth.

  • 2.

    One Newton correction before writing depth, so arm and body agree.

  • 3.

    Blend the normal from the body's analytic gradient to the union gradient near the body surface. The body normal is a closed-form derivative (jelly.js), two lengths instead of six distance taps; together with the new framing, that recovered budget (below).

Edges rely on MSAA. The material sets alphaToCoverage, but the arm shader writes a constant alpha of 1, because grazing alpha made thin nubs ghostly.

Left: Mintie with one arm raised mid-wave. Right: the same frame painted by which shader owns each pixel: a magenta quad where the arm proxy was rasterised but the ray missed, cyan where the ray hit the arm union but the body owns the pixel, blue where the raymarched arm owns it

The same frame twice. Right: a debug build of the arm shader (release code with three extra output colours, patched in at serve time) paints what each pixel does. The magenta quad is the bounding proxy; only the blue region is raymarched.

Why WebGL2

The source comment says it (index.js): a bounded GLSL SDF, real fragment depth, MSAA and GPU elapsed-time queries on one portable path, with no duplicate WebGPU material implementation. The attachments module refuses to initialise on a WebGPU renderer. We shipped one shader path we could measure with EXT_disjoint_timer_query_webgl2 instead of two we could not.

The jelly look: one transmission pass

  • 1.

    A single world pass. Before the main pass we render the floor shadow, interior bubbles, far-side attachments and far-side arms (flat colour) into a half-float target; the floor grid is skipped because the clear colour already is the backdrop. The skin samples that target, offset along the screen-space normal by an optical depth. No recursive refraction, no blur pyramid.

  • 2.

    Half resolution at DPR 2. The target is sized in CSS pixels, so at DPR 2 it has half the canvas's linear resolution. Reduced quality halves it again.

  • 3.

    Beer-Lambert absorption with art-directed depth. The shader uses the view-ray chord through the body (analytic ellipsoid exit with one local radius for the flared base) and per-channel absorption. The source says so: "art-directed optical depth clears the skirt/edges; full curved-ray exit needs another depth pass."

  • 4.

    Everything else analytic. Wrapped diffuse for inner scattering, a warm floor bounce through the thin lower volume, Fresnel against an analytic studio environment (two soft boxes and a rim), a micro-normal for wetness, a tight second specular lobe, and four instanced bubbles that render only in the transmission pass.

It cannot refract real scene objects or produce true caustics. Our decision log: "analytic empty-studio refraction and occlusion, not scene-object refraction / true caustics / shadow maps; add only after measured visual need."

Two rows: an opaque gummy shading above and the transmission pass below, each at rest and lifted off the floor

Same camera, same pose. Top: an ablation, the release shader with the transmission-texture sample replaced by flat pigment. It is not a historical build. Bottom: the shipped transmission pass.

Floor, shadow and backdrop

No shadow map. The contact shadow is one plane under the body whose shader combines three Gaussians: a broad penumbra offset from the key light, a tight contact term (AO where body meets floor), and a lime-tinted term where light passes through the jelly, plus a faint caustic ring. A lift uniform from the body's height widens and fades each term at a different rate; contact falls off fastest. The plane renders in the transmission pass, so the skin refracts its own shadow.

Floor and backdrop share exactly one linear colour (floor.js), so there is no horizon line at any azimuth. The grid is one mipmapped 256 px tile on a radius-10.5 disc, faded out before the edge. Framing is aspect-aware: the camera distance is the larger of 7 and (4.95 / aspect ratio), using 4.35 under 600 px wide, and the view is shifted up (4.5% of height on desktop, 9% on mobile) so the body sits above the control dock.

Top: five azimuths around the blob on the same seamless floor with no horizon line. Bottom: contact shadow at rest, at 25 percent and at 75 percent of the steady lift height

Top: the release camera is fixed, so the orbit strip patches the azimuth constant at runtime for this figure only. Bottom: contact shadow at rest and at 25% and 75% of the steady lift height (nearest frames of a 240 Hz stepped capture).

Eyes and face are shader decals

Eyes, mouth and cheeks are quads on surface anchors with their own fragment shaders (face.js). The eye is a 2D SDF: an ellipse for the opening, a lower lid that rises into a joy crescent, a sloped upper lid for frowns, and a closed-lid arc that blends in as openness drops. A fake glass-bead normal gives a Fresnel-weighted reflection; catchlights are authored (one tall oval, one round dot) with a gentle shimmer and a four-point flare on emotion peaks. Hearts, stars, spirals, crosses and tears are icon branches in the same shader. Front-facing decals are hidden during the transmission capture.

Gaze caught us out. With eye-local gaze at zero, pupils looked roughly 19 degrees right of the camera (the figure in the code comment), because each eye sits on a curved surface whose rest normal is yawed outward: the two eyes' normals point about 8 and 31 degrees right of the body's forward axis. Aiming each eye from its own rest normal, -(atan2(n.x, n.z) - FACE_YAW) / 0.65 in body.js, removes that offset by construction, and a unit test pins the constants to the measured normals. Gaze zero should mean "at the viewer", not "along the normal".

Eye close-ups: open, joy crescent, frown, heart, star and tear, then a before frame with the per-eye aim correction disabled and gaze at -1, 0 and +1

Top: six eye shapes. Bottom: gaze at -1, 0 and +1, and "before": the release build with the per-eye aim correction zeroed. That frame is re-created for this post, not a historical capture, so treat it as an illustration of the mechanism.

The perform engine

The renderer takes one input, a pose: body parameters (squash, lean, offset, twist, wobble, puff), eyes, mouth, cheeks, arm descriptors, effects and tint. The perform engine produces it.

  • •

    One owner, one clock. Gestures are authored recipes. play() validates before it preempts, and blends from the current pose so back-to-back plays crossfade.

  • •

    Seeded randomness. Blinks, glances and micro-behaviours use a seeded PRNG whose state is saved and restored around dry runs.

  • •

    Layers. Conversation beats, gaze and orientation, and cue blinks apply after the sampled recipe. Audio owns the mouth last: while speaking, aperture is audio amplitude, blended in over 60 ms from any expression mouth.

  • •

    Everything is bounded. A bound() pass clamps every field and zeroes twist and vertical offset in reduced-motion mode.

  • •

    Prediction. A synchronous dry run estimates when a gesture's stroke lands, so the app can drop a cue that would miss its word.

Touch physics (springs, the pendulum, floor hops) lives in its own module; the renderer does not advance it.

Flow diagram: inputs (audio amplitude, touch events, decision model) feed the perform engine (recipe sample, conversation beats, orient, cue blink, mouth ownership), which produces a pose, which feeds the renderer (body update, arms, attachments, transmission pass, main pass)

A diagram of the per-frame data flow, not a capture.

Performance: what we measured

GPU numbers are p95 from timer queries at DPR 2 on an M1 Max in Chrome, 60 fps. The check rows use a 1512 by 982 viewport and 180 counted frames (240 in one harness); the harness for the early prototype rows is not recorded. Gate: 3 ms. Times in ms.

Date

Build

Rest

Two arms

Verdict

Oct 30

full SDF raymarch

-

9.4 (pose not recorded)

killed

Oct 30

full mesh

2.23 (pose not recorded)

-

killed on visuals

Oct 30

hybrid body, 0/1/2 arms

0.82

2.68 (1 arm: 1.79)

pass

Oct 30

jelly material pass

1.12

2.75

pass

Oct 30

face-safe effects and arm fixes

-

2.85

pass

Oct 30

photoreal studio pass, start

-

3.85

miss

Oct 30

same, frozen-heart worst case

-

4.91

miss

Oct 30

analytic body normal, new framing

-

2.54 (heart: 2.57)

pass

Oct 31

decision-model change; first run

-

3.04

miss

Oct 31

same change; rerun, then final

-

2.14, then 1.97

pass

Oct 31 (file date)

see-through jelly, standard check

2.25

2.62

pass

Oct 31 (file date)

same build, separate renderer harness

3.74

8.56 (heart-emoji pose)

miss

Nov 3

fresh checkout, standard check

3.86

4.74

miss

The Oct 30 rows and the first two Oct 31 rows are from our project log, written at the time; their raw samples were not kept. The later Oct 31 rows, the Nov 3 row and the release comparison below have saved result files.

The photoreal-pass miss was recovered by replacing six distance taps with the closed-form body normal, plus the aspect-aware framing: 3.85 and 4.91 ms became 2.54 and 2.57 ms without lowering DPR or loosening the gate.

Misses we did not resolve:

  • •

    Separate harness. For the see-through build, a renderer-only harness (240 samples) read 3.74 ms at rest and 8.56 ms in a heart-emoji pose; the previous build read 5.43 and 6.13 in the same harness. The same build passed the standard check at 2.25 and 2.62 ms. The harnesses disagree, and the result files do not record machine load, so we cannot say which to trust.

  • •

    Fresh checkout, Nov 3. The standard quick check gave 3.86 ms at rest and 4.74 ms with two arms, both failing, with JS p95 0.60 and 0.80 ms and 60 fps held. Our notes say GPU p95 flaps above 3 ms when load average exceeds about 5, but this run did not record load, so that explanation is unproven.

Headless Chrome's rAF timing is not proof of delivered display frame rate.

Release build, Nov 15. For release we simplified the character, fixed the camera and added a grid floor. We then compared the pre-release baseline (10adfb9) against the release build (2808d45; the character renderer is unchanged at 1ea1104 apart from a comment) in 10 alternating repetitions per condition, 180 samples each, DPR 2, viewport 1512 by 982, Chrome for Testing 154.

Condition

GPU p95, before

GPU p95, after

Gate passes, after

Rest

1.64 ms (1.64-1.65)

1.67 ms (1.65-1.67)

9/10

Two arms out

2.52 ms (2.41-2.55)

2.64 ms (2.62-2.71)

10/10

  • •

    The single miss was one rest run at 59.7 fps, with GPU and JS within budget, at a load average of 9.41. We did not repeat or drop it.

  • •

    The whole release delta is +0.02 ms at rest and +0.12 ms with two arms. This compares whole builds (character, camera and floor changed together), so we cannot attribute it to the grid floor alone.

  • •

    32 of the 40 runs started with a load average above 8, from other jobs on the same machine. GPU p95 did not track load in this set.

Do they feel alive?

We wrote twelve behavioural targets (whether Mintie shows they heard you, whether a gesture lands on its word, whether blinks are alive and not a metronome) from conversation and animation literature, then measured on an Oct 31 build, not the release. Method limits: scripted 8-turn sessions, synthetic input, a stand-in local voice (300 ms latency), software clock with output loopback, no speaker or display latency, 2 baseline runs and 3 performance-layer runs. Directional, not powered.

Final interleaved A/B: baseline (2 runs, 16 turns) vs the performance layer plus a faster end-of-turn setting (3 runs, 24 turns).

Metric

Baseline

Performance layer

Target

Met?

Hops per 8 turns

6, 6

1, 1, 1

2 or fewer

yes

Duplicate gestures played

2, 1

0

0

yes

Gesture onset error, p50 / p95

59 / 164 ms

14 / 25 ms

-150..+100 ms for 90%+

yes (17/17 vs 15/16)

Listening gaze at viewer, 80%+ of turn start

6/16 turns

22/24

80%+

yes

Speaking blinks per minute

6.7-7.5

19.1-21.6

15-25

yes

Mouth close vs audio end, p95

93-97 ms

18-20 ms

40 ms or less

yes

First visible uptake after speech ends, p50 / p95

385 / 744 ms

336 / 394 ms

250 / 500 ms

p95 yes, p50 no

First words audio, p50 / p95

1347 / 2108 ms

1153 / 1626 ms

700 / 1500 ms

no

Touch reaction, p95

19-52 ms

18-101 ms

50 ms or less

no

On that build the touch miss traced to one slowly sprung element that needed 36-100 ms to cross the motion threshold; contact itself reacted in 2-3 ms. We have not re-measured touch reaction on the release build. First-words latency is outside the renderer (end-of-turn detection, decision model, text model, synthesis). A real-voice rerun (3 runs each) agreed on gesture and gaze targets and improved p50, but had one 3.8 s provider outlier, and speaking blinks met target in 2 of 3 runs.

One fix is worth telling. Our first phrase-boundary blinks did nothing visible: sustained speaking faces blend the idle eye pose away, overwriting the blink. Layering the cue blink above the performance face lifted speaking blinks from 4.1-5.8 to 21-28 per minute (two runs). Shortening the mouth's amplitude release from 70 to 30 ms cut close lag from about +80/94 ms to +9/24 ms (one run with the stand-in voice; three later real-voice runs read the mouth's median close at 76-91 ms before the measured audio end, partly because the voice clips end in near-silence).

Nine small charts comparing baseline and the performance layer against their targets; the performance layer misses first-uptake p50, first-words p50 and p95, and touch reaction p95

One panel per metric because the units differ. Dots are the values in the table above; a red outline and the word "missed" mark targets the performance layer did not meet. Oct 31 build, synthetic fixtures, stand-in voice, 8 turns per run.

What we would do differently

Hindsight, not measurement:

  • •

    Record machine state with every perf number. Load, power source and thermal state decided several gate results, and we wrote them down after the fact. A check that refuses to report above a load threshold would have saved reruns.

  • •

    Interleave baselines from the start. Our cleanest results are the A/Bs where base and candidate alternated on one machine.

  • •

    Reconcile harnesses early. Two perf tools that disagree on the same build are worse than one slow tool.

  • •

    Keep headroom under the gate. Several passes sat at 2.5-2.9 ms, so one extra light or decal tipped a build over. A tighter internal target would have forced the analytic-normal fix sooner.

  • •

    Prototype the middle option first. The hybrid looked obvious once both extremes failed; we built the extremes first.

  • •

    Test on a phone. Every GPU number here is one laptop.

The repo has a one-command check (npm run check) that reports JS p95, GPU p95 and fps at DPR 2; its quick mode typically took 25 to 33 seconds in our logs of earlier builds. If you file a perf regression, run it on AC power, machine idle, and include the load average.