Abstract base class for a render graph pass.
Packs same-ish-height rectangles left-to-right into shelves of a fixed-width atlas, growing the height as needed. Simple and good enough for a one-shot glyph set (not online repacking).
A procedurally-drawn glyph (e.g. an icon) added to the atlas alongside the font glyphs: a code
point to register it under (use a private-use point, 0xE000+) and a Canvas2D drawer that fills it
in white, centered at (cx, cy) within radius r px. Rasterized + SDF'd exactly like a letter.
One glyph's place in the atlas + its typesetting metrics, all in atlas pixels.
A rasterized font: per-code-point glyphs + vertical metrics + the atlas size for UV normalizing.
One glyph quad: corner positions relative to the text origin (px, y-down) + atlas UVs (0..1).
A laid-out single line: the glyph quads (origin = pen start on the baseline) + extents.
CPU-precomputed font/word tables uploaded to GPU storage buffers so the
particle glyph_trail shader can typeset words along trails without doing
any string layout on the GPU. All metrics stay in atlas pixels; the shader
scales them to world units.
A label's screen AABB + priority. Lower rank = more important (placed first).
A glyph positioned on a road: the center of its quad + the tangent angle (radians, y-down).
Floats per glyph instance: center(2) + halfSize(2) + rot(2) + uvRect(4) + color(4).
In-place 2D squared-distance transform of a width×height grid (0 = seed, INF = empty).
Signed-distance field of an alpha-coverage bitmap (width×height, values 0..1), encoded to
0..255 with 128 ≈ the glyph edge and radius controlling the spread. Inside the glyph reads
above 0.5 (normalized), outside below — matching the shader's smoothstep(0.5, …).
Rasterizes a font into an SDF atlas texture (r8unorm) + FontMetrics. Browser-only (Canvas
2D). One glyph at a time: draw padded, read its alpha, distance-transform it, shelf-pack the SDF
into one big Uint8Array, then upload. Metrics place each glyph quad relative to the pen baseline.
Lays out one line of text. The origin is the pen start on the baseline; glyph quads are placed left-to-right by advance, y-up extents given by each glyph's offset. Missing glyphs are skipped but still advance by a space's width (or 0) so spacing degrades gracefully. UVs are normalized to the atlas size so the caller can swap atlas resolutions freely.
Lays out each word once (CPU) into flat tables the GPU glyph_trail particle
node uploads as storage buffers. Per glyph it stores the atlas UV rect plus
the quad's center + half-extents (all atlas px, baseline-relative, y-down);
the shader places each glyph by arc length along a particle's trail and scales
px → world. Words with no drawable glyphs contribute an empty run.
Greedy declutter: in ascending rank order, keep a label if its (padded) box doesn't overlap any
already-kept box; otherwise drop it. Returns the kept ids in placement order. O(n²) — fine for the
few-hundred candidates a viewport holds after frustum culling; swap for a grid if it ever isn't.
Ties on rank break by id for deterministic output.
Places a line of glyphs along a road polyline. Each glyph is sampled at its center's arc length, oriented to the local tangent. The text is centered on the polyline and, if the run would read right-to-left overall (tangent pointing left), the whole polyline is reversed first so labels stay upright. Returns null when the road is shorter than the text (caller skips it).
Engine-general SDF text rendering, reusable by any game (not just the geo map).
frame.hdrbefore tonemap). The caller builds the per-frame glyph instances (14 floats each — center, halfSize, rot, uvRect, rgba; see GLYPH_FLOATS).