# Sponza as a voxel reference scene — research + plan Research only (2026-10-31). Nothing in the repo was changed. Downloads are in `research/sponza/downloads/` (untrusted data, nothing in them was executed). Measurements from my own trial voxelization are in `research/sponza/voxelize-out/`. ## TL;DR - **Nobody has published a usable voxel Sponza.** The only downloadable one is vengi's `.qb` set, built from the Khronos glTF. That copy is under the CRYENGINE licence, not CC BY, and no licence is stated for the voxel files. There is no `.vox` Sponza anywhere I looked. - **Voxelize it ourselves from McGuire's Crytek Sponza OBJ.** That file is CC BY 3.0, so we owe only attribution. Run it through a small offline importer of our own: mesh → per-object `.vox` (or straight to `.vplib`), then the existing `scripts/import-vox.ts` path. Use vengi-voxconvert only as a quick look. The importer needs a wall-thicken pass: most Sponza walls and floors are single-sided meshes and voxelize as 1–2-voxel skins (§2.2). - **Native scale fits the engine comfortably.** The Khronos 0.008 m/unit scale gives a 29.8 × 12.4 × 18.3 m atrium. At 1/16 m that is 476 × 199 × 293 voxels: **2 × 1 × 2 regions**. Doubling the scale (20–24 regions, ~13 MB) buys back the column and relief detail, but the building becomes 60 m long and out of scale with the 1.8 m avatar. - **The building shell goes into terrain. Pots, hanging vases with their chains, and curtains/drapes become separate structures (constructs). Flagpoles and rods are open: decision D5.** The split follows what is naturally a separate object. It also suits fracture, because a curtain's hinge line anchored to terrain is exactly Douglas Dwyer's "joint follows the body it is attached to". - **Curtains: static opaque cloth first. Then a translucent ("camera-opaque, light-transmissive") cloth class. Joints come later.** The renderer already carries RGB transmittance on shadow and GI rays for glass. Cloth needs a second material class that the camera and GI rays *hit* but sun-shadow rays *pass through*, plus a back-lit term in lighting. About 400–600 lines across material.ts, voxel-core node bits, the shadow walker's mask, and lighting. It is a renderer change, so it needs the surface-GI gate. **Key numbers at 1×:** | quantity | value | |---|---| | solid voxels | 0.83 M | | material SVT | ~3 MB | | regions | 4 | | ground column shaft | 8 voxels | | lion relief | 35 × 33 voxels | | curtains | 10 ground-floor (38 × 37 v) + 16 upper drapes | | jointed bodies if simulated | ~130 | Decisions are in §6. Artefacts: - `voxelize-out/`: stats JSON, component census, orthographic preview PNGs (`view_long_section_x1.png` shows the colonnade and curtains). - `voxelize-out-with-backdrop/`: an earlier run before the backdrop shell was excluded. It is wrong, because the shell enclosed the scene and got filled; kept for the record. - `downloads/`: the Khronos glTF and base-colour textures, measurement only. --- ## 1. Existing voxel copies and the source meshes ### 1.1 Voxelized Sponzas that exist | Copy | URL | Licence | Resolution / format | Colours | Verdict | |---|---|---|---|---|---| | vengi `voxelized` | github.com/vengi-voxel/voxelized (`voxelized/sponza-scale-{0.04,0.1,0.3}.qb`, Git LFS, 0.3 = 56 MB) | **None stated** for the files. vengi itself is MIT. The source is Khronos's glTF, which is under the CRYENGINE licence (§1.2), so the copy inherits that. | `.qb` (Qubicle), made with `vengi-voxconvert -set voxformat_scale S`. The scale applies to raw mesh units, so 0.3 ≈ 1116×467×686, 0.1 ≈ 372×156×229 and 0.04 ≈ 149×62×92 (inferred from the bbox; file not opened). | RGBA per voxel, sampled through the UVs. No material semantics. | **Don't use.** The licence is unclear, there are no materials, it is one monolithic grid, and it is easy to regenerate. Fine as a visual cross-check only. I couldn't fetch the preview PNG (LFS 404). | | Teknologicus "Hantverk'n/Vorxel" devlog | teknologicus.itch.io/hantverkn/devlog/703036 | — | 9.0 M non-air voxels | ? | Screenshots only, no download. | | VCT / VXGI demos (AdamYuan/VcTest 512×256×256, Friduric, …) | GitHub | various | voxelize at runtime | — | No file to take. | | SVDAG papers (Kämpe 2013; van der Laan lossy-DAG suppl., Sponza 2K³–64K³) | — | — | tables only | — | No data published. | | MagicaVoxel `.vox`, Sketchfab, Teardown, Avoyd model repo | — | — | — | — | **None found.** Sketchfab has only mesh Sponzas, one of them CC BY-NC. | | dubiousconst282 VoxelRT (our renderer's ancestor) | github.com/dubiousconst282/VoxelRT | — | Bistro at ~4k/8k, materials off | — | No Sponza. | **Conclusion:** there is no quality, licensed, material-aware voxel Sponza. We have to make one. That suits us anyway, because the owner's questions (materials, object split, fabric) need per-object, per-material output that no generic voxelizer gives. ### 1.2 Source meshes | Source | Licence | Attribution we'd owe | Size | Notes | |---|---|---|---|---| | **Crytek Sponza, McGuire Computer Graphics Archive** (casual-effects.com/data → `crytek_sponza/sponza.zip`) | **CC BY 3.0** (from `info.js` in the archive) | "Crytek Sponza © 2010 Frank Meinl, Crytek. CC BY 3.0. Via the McGuire Computer Graphics Archive (casual-effects.com/data)". McGuire also asks publications to cite `McGuire2017Data`. If we use Pestana's PBR maps, credit Alexandre Pestana too. | 78 MB (OBJ + PNG) | 262,267 tris, 25 named materials (`sponza.mtl`). McGuire moved the masks into the diffuse alpha and split out the long untextured banner as `banner.obj`. **Recommended source.** | | Crytek Sponza, Khronos glTF-Sample-Assets `Models/Sponza` | Model files: **"CRYENGINE Limited License Agreement"** (`LICENSE.md`; the terms link is cryengine.com/ce-terms). Only the metadata is CC BY 4.0. | per the CRYENGINE terms (**not read; may restrict use outside CryEngine**) | 9.5 MB .bin + 167 KB .gltf + textures (the 25 base-colour maps I fetched are 18 MB) | Same mesh. One node at scale 0.008, 103 primitives, 25 materials with **names stripped**, 6 alphaMode MASK. I used this copy **only for local measurement** (§2); nothing derived from it should be committed. | | Dabrovic Sponza (2002) | CC BY-NC | — | 3.6 MB | Non-commercial. Avoid. | | **Intel Sponza 2022** (intel.com → Graphics Research Samples) | "Creative Commons Attribution", **version not stated on the page**. The packaged licence file would settle it. Ignore the mirrors' NC / "no AI" labels. | Intel asks for a citation of the "Intel Sample Library". Credits per mirrors: Meinl, Putica, Siqueira, Heath, Prazen, Herholz, Cherniak, Kaplanyan. | Base 3.7 GB. Add-ons: Curtains 0.75 GB, Ivy 1.29 GB, Trees 0.9 GB, Candles 2.97 GB (+ Knight, Flood, Explosion) | ~3.7 M tris photogrammetry PBR with 4K maps. At 6 cm voxels that detail is lost, and the downloads are far beyond this task's budget. **Not downloaded.** The **Curtains** add-on (draped, coloured cloth) is the most interesting part for us. Revisit it if the owner wants Intel's look. | ### 1.3 Tooling recommendation Does the repo already have an import path? **Partly:** - `scripts/import-vox.ts`: `.vox` → `.vplib` prefab library. It goes through `common/src/import/vox-to-prefab.ts`, which unions the scene graph, swaps Z-up to Y-up, and **throws above 256³** (`VoxTooLargeError`). - Palette colours map to built-in `VoxelType`s by nearest RGB against 13 anchors (`vox-materials.ts`), or through a `--material-map` JSON of palette index → VoxelType. - `.vplib` entries go into the prefab catalog (`PREFAB_DIR`). From there they can be **spawned as constructs** or **stamped into terrain** with `CsgStamp` brushes (`stamp-resolver.ts` resolves the key). A fixture can do both through `api.applyBrushes` and `api.spawnConstruct`. - `common/src/import/` also has a BlockBench → `.modellib` path, with palette clustering and `*.materials.json` sidecars. It is for actor models, not world geometry. - **No mesh (OBJ/glTF) importer exists.** Recommended pipeline: 1. **Our own small offline voxelizer (tooling, not runtime):** `scripts/sponza/voxelize-mesh.ts`, or a Python/Rust tool under `tools/`. - It reads McGuire's OBJ + MTL and samples each triangle densely, the same way my measurement script does (`voxelize-out/`). - Each voxel gets the **source material name**, a texture-sampled sRGB colour, and the alpha mask. - It solid-fills closed interiors. - It writes **one output per object group** (§4), each ≤ 256³, as `.vox` or straight into `.vplib`. - It needs no new runtime code. Name + colour → material id is a mapping table (§3). - Our tool is preferable to vengi/FileToVox because we need the per-voxel material *name* (a .vox palette loses it) and the per-object split. vengi is a good second opinion: `vengi-voxconvert --split 256:256:256`. 2. **Extend `import-vox.ts` → `vox-to-prefab`** so a palette entry can map to *any* 16-bit material id. It is u8 VoxelType today (`material-map` values are limited to 0..255), and it rejects ids such as the stained-glass family at 0x6000. This is a small change. 3. **A `sponza` fixture** (`server/src/fixtures/scenes/sponza.ts`). It stamps the terrain prefabs into the slab world and spawns the object prefabs as constructs. That reuses the existing fixture + GI-gate machinery. --- ## 2. Scale ### 2.1 Engine units - **1 voxel = 1/16 m** (`VOXEL_SIZE`, `common/src/voxel.ts`). The 1.8 m avatar is 28.8 voxels tall. - **Region = 256³ voxels = 16 m**, a 4-level SVT64 (L0 leaf 4³, L1 16³, L2 64³, L3 root). The GPU allocation unit is the super-region (1024³ = 64 m). - **A structure (construct / prefab) is one region tree, at most 256³ = 16 m per axis** (`PHYSICS_PLAN.md` §15; `VoxTooLargeError` in the importer). Larger dynamic constructs ("super-region structure") are deferred. Terrain has no such cap, because regions tile. - Storage per voxel: - an L0 mixed leaf costs a 16 B node + a 64 B data block (8-bit palette indices); - a uniform node at any level is 16 B; - a region palette costs 0 B when every material is < 256 (GLOBAL tier), otherwise 512 B per region; a leaf that fits neither falls back to RAW16 (128 B). - The normals SVT is roughly the same order again. ### 2.2 Candidate scales The mesh's raw extent is 3720.9 × 1555.9 × 2288.2 units. Khronos uses 0.008 m/unit; the "1 unit = 1 cm" reading gives 0.01. Measured with my trial voxelizer (`voxelize-out/voxelize.py`, run as `EXCL=5,2 python3 -I voxelize.py `): - Every triangle is sampled at ≤ 0.4-voxel spacing. Base-colour textures and alpha masks are sampled through the UVs. - Each voxel takes the majority material. - Empty space not 6-connected to the grid border is solid-filled. - The backdrop shell and gi_flag are excluded. - Run on the Khronos copy of the same mesh, for measurement only. - **SVT size** is an upper-bound estimate: 16 B per L0 node + 64 B per mixed leaf + 16 B per L1/L2 node, material tree only. The normals SVT adds about the same again, and the server's deflated wire tier is smaller. | | **1× (0.008 m/unit, Khronos)** [rec] | 1.25× (0.01 m/unit, "cm") | 2× (0.016 m/unit) | |---|---|---|---| | atrium size (m) | 29.8 × 12.4 × 18.3 | 37.2 × 15.6 × 22.9 | 59.5 × 24.9 × 36.6 | | voxels (x × y × z) | 477 × 200 × 294 | 596 × 250 × 367 | 953 × 399 × 586 | | regions (16 m) | **2 × 1 × 2 = 4** | 3 × 1 × 2 = 6 (y 250 of 256: tight) | 4 × 2 × 3 = 24 (20 non-empty) | | solid voxels (surface + fill) | 0.83 M (0.71 M surface) | 1.43 M | 4.59 M | | L0 leaves (mixed) / L1 / L2 nodes | 37.3 k (36.5 k) / 2.1 k / 113 | 60.7 k / 3.2 k / 156 | 170 k / 8.3 k / 502 | | material SVT, est. | **~3.0 MB** | ~4.8 MB | ~12.9 MB | | storey (floor → gallery floor) | 54 v = 3.4 m | 4.2 m | 6.8 m | | ground-floor column shaft Ø | **8 v** (0.5 m) | 10 v | 16 v | | lion relief panel / head | 35×33 v / 23×20 v, 11 v deep | ~44×41 | ~70×66 / 46×40 | | ground-floor curtain | 38 × 37 v, 4–5 v deep with folds | 47 × 46 | 76 × 74 | | distinct texture shades (5-bit quantised) | 994 | 1100 | 1311 | **Reading the table:** - **The size is trivial at every scale.** Even 2× is ~13 MB of material tree across 20 regions. The engine streams thousands of terrain regions, so memory or storage does not decide the scale. - **What decides it is human scale vs detail.** - At 1× the arcade storey is 3.4 m and the curtains are 2.3 m: right against the 1.8 m avatar. - Column shafts are 8 voxels across. That reads as a round column (with a stepped silhouette, the intended aesthetic), and the bases, capitals and arches survive. - Any flutes or fine mouldings are sub-voxel and will not survive. I couldn't tell from the 8×8 cross-sections whether the Crytek shafts are fluted in geometry at all; the fine detail is mostly normal-mapped. - The lion relief is ~35 voxels across with a head that projects 11 voxels: readable as a lion head, but blocky. - 2× doubles every feature: 16-voxel columns, a 70-voxel lion. But it makes a 60 m palace with a 6.8 m ground storey, so the avatar is a child in it. Owner decision D2. - **Recommendation:** 1×. The GI-relevant features — open roof, deep arcades, galleries, coloured cloth — are all well resolved, and it matches the scale everyone quotes for the scene. - **Solid fill needs importer work.** Only 119 k of 0.83 M voxels at 1× are enclosed interior. Most of Sponza's walls and floors are open-backed or single-sided meshes, so they voxelize as 1–2-voxel skins (e.g. the floors are 350 × **1** × 157). The importer needs a **thicken/solidify** pass: - extrude each architectural surface away from the courtyard by a set wall thickness (e.g. floors 6 v, walls 8 v), or - run a morphological closing per material group. - Without it, fracture would see paper walls, and sun could leak through 1-voxel skins at grazing angles. ### 2.3 Object census (1×, from 26-connected components per material) | Khronos mat # | identification (check vs `sponza.mtl`) | pieces | piece size (voxels) | |---|---|---|---| | 17 / 18 / 19 | ground-floor curtains: blue / red / green | 3 + 4 + 3 = **10** | 38 × 37 × 4–5 (2.4 × 2.3 m) | | 14 / 15 / 16 | upper-gallery drapes: green / blue / red (swags 43×24×13, flat hangings 42×21×2, ties 17×12×13) | **16** ≥ 200 v | see left | | 13 | curtain rods | 18 | 41 × 3 × 4 | | 22 | big floor vases | 4 | 20 × 19 × 20 | | 1 + 0 + 3 | small plant pots + plants (alpha-masked leaves) | 8 pots, ~18 plant clumps | pot 7 × 8 × 7; plant up to 16 × 27 × 13 | | 21 + 20 | hanging bowls + short chain pieces (MASK) | 4 + 4 | 10 × 6 × 8; chain 7 × 10 × 2 | | 4 + 23 | lion relief panels + lion heads | 3 panels, 2 heads | 4 × 35 × 33; 11 × 23 × 20 | | 6, 8, 10, 12 | arcades/arches; ground column bases; gallery columns; top colonnade | 12 + 12 + 12 columns | Ø 8 v (ground), 14 v (gallery), 9 v (top) | | 7, 9, 11, 24 | walls/vaults; floors; doors/details; hip roof | — | — | - **Alpha-masked parts** (plants, chain) come out sparse, from 5.3 k leaf voxels. - The chains lose most of their alpha-cut links, which are sub-voxel. Re-author them as a 1-voxel `Iron` rod instead of trusting the voxelization. --- ## 3. Materials ### 3.1 What a material is in this engine Materials live in one registry, `common/src/material.ts` `MATERIALS`, keyed by a 16-bit id. Each entry (`MaterialDef`) has the following fields. | group | fields | consumed by | |---|---|---| | opaque PBR | `baseColor` (linear RGB), `metallic`, `roughness`, `reflectance` | lighting. Note: `metallic` is decoded but not used by world lighting yet; only the visual-card overlay reads it. | | emission | `emissiveColor`, `emissiveStrength` | lighting + surface GI (a light source) | | transmission | `iorClass` (> Opaque ⇒ transparent), `absorption` (per-voxel Beer–Lambert σ, RGB), `tint` | transparent walker; RGB sun-shadow transmittance (cached RGB565 in the VSC); GI rays (`T = exp(-τ)`) | | texture | `textureId` | dormant (triplanar on the ROADMAP) | | flags | Unlit, Liquid, Animated (GPU); CA flags (CPU) | | | physics | `density` (per voxel volume; stone 2.5, wood 0.7), `friction` (combined √(fA·fB)), `restitution` (combined max) | physics-rs | | acoustics | transmission, reflectivity, footstep / impact class | audio | | combustion | optional | CA (off) | - The GPU entry is 32 B. Word `u7` is **reserved** ("IOR, subsurface, textureScale, future PBR"), and the 16-bit flags field has spare bits. - The tint and absorption fields are **inert for opaque materials**. - Stained glass is a generated sparse family at 0x6000 (16 hues × 8 recipes, `common/src/stained-glass.ts`). That is **the precedent for a generated family of shade variants**. - A region carries at most 256 distinct ids in its palette. Ids < 256 cost nothing. ### 3.2 Colour detail: flat materials vs shade ramps Sponza's look comes from its textures: brick and mortar, floor tiles, the patterned banners. At 6 cm voxels, one voxel covers ~1/16 of a brick course, so texture colour per voxel still reads as mortar lines and tile seams. There are two options: - **A. One flat colour per material (~12 ids).** The architecture reads, but brick, tile and banner patterns disappear. Cheapest. Reference GI scenes usually want flat albedo anyway, because albedo variation is noise in a GI comparison. - **B. Shade ramps:** each base material gets N colour variants, quantized from the sampled texture by k-means in LAB. All variants share the base material's physics, acoustics and roughness; only `baseColor` differs. - The pattern follows stained glass: a generated family, e.g. at 0x7000. - Per region this fits the 256-entry palette easily: ~10 base × 8 shades + 3 cloth × 16 ≈ 130 ids. - Storage is almost unchanged, because surface leaves are mixed anyway. - **Recommended:** B. Keep a per-voxel switch in the importer that collapses every variant to its base id, so a "flat albedo" GI variant of the same scene is one flag away (owner decision D3). ### 3.3 Mapping Sponza's materials I used McGuire's `sponza.mtl` names; the Khronos copy strips them. Mean colours are measured from the voxelized textures (sRGB, §2 run). **About the colours below:** - Mean texture colour is measured per material over its voxels. It is the Khronos texture ÷ its 0.588 `baseColorFactor`, i.e. the raw texture, in sRGB. - The linear value is what would go into `baseColor`. - The Khronos factor of ~0.59 is an artistic darkening that Pestana's PBR pack inherited. Whether our reference uses it is **owner decision D3b**: GI brightness scales with it. | Sponza material (likely mtl name) | Khronos # | voxels (1×) | texture mean sRGB | → linear baseColor | engine material | |---|---|---|---|---|---| | floor | 9 | 92 k | 180,163,138 | 0.46, 0.37, 0.25 | `Limestone` shade ramp (or `Marble` for polish) | | bricks / walls + vaults | 7 | 125 k | 170,153,122 (σ 4: near-flat) | 0.40, 0.32, 0.20 | `Sandstone`/`Limestone` ramp. Use new `Brick` only if the owner wants the reddish brick read; the measured colour is beige. | | arch / column_a–c / ceiling / details | 6, 8, 10, 12 | 112 k | 138–153, 128–145, 109–128 | ~0.25–0.32, 0.22–0.28, 0.15–0.22 | `Limestone` ramp | | doors / dark details | 11 | 5 k | 102,95,87 | 0.13, 0.11, 0.10 | `Wood`/`Planks` (doors) or dark stone; check against the mtl | | roof | 24 | 314 k | 107,104,104 | 0.15, 0.14, 0.14 | new `Terracotta` (darker grey-brown shade); mostly outside the GI view | | lion panel / lion head | 4 / 23 | 4 k / 1.4 k | 133,121,99 / 124,111,85 | 0.24, 0.19, 0.13 / 0.20, 0.16, 0.09 | `Limestone` ramp (part of the wall) | | big floor vases (`vase_round`) | 22 | 7.6 k | 163,148,124 | 0.37, 0.30, 0.20 | new `Ceramic` (stone-coloured) | | plant pots (`vase`) | 1 | 1.5 k | 100,88,87 | 0.13, 0.10, 0.10 | new `Terracotta` | | plants (`leaf`, MASK) / pot greenery | 0 / 3 | 5.3 k / 0.4 k | 61,60,46 / 87,122,39 | 0.05, 0.05, 0.03 / 0.10, 0.20, 0.02 | `Leaves` with a darker shade ramp | | hanging bowls (`vase_hanging`) | 21 | 0.6 k | 37,41,41 | 0.02, 0.02, 0.02 | new `Iron` | | chain (MASK) | 20 | 0.1 k | 102,68,49 | 0.13, 0.06, 0.03 | new `Iron` (re-authored rod) | | curtain rods / flagpoles | 13 | 1.9 k | 94,80,65 | 0.11, 0.08, 0.05 | `Wood` | | curtains red / green / blue | 18 / 19 / 17 | 10.3 / 8.1 / 8.1 k | 129,29,20 / 34,90,14 / 44,85,143 | 0.22,0.012,0.007 / 0.016,0.10,0.004 / 0.025,0.09,0.28 | new `Cloth` red / green / blue | | upper drapes red / green / blue | 16 / 14 / 15 | 3.7 / 5.8 / 5.4 k | 116,46,29 / 39,104,31 / 44,80,114 | 0.18,0.03,0.01 / 0.02,0.14,0.01 / 0.03,0.08,0.17 | `Cloth` (shade ramp; drapes carry a patterned border) | | backdrop shell (`Material__298`), `gi_flag` | 5, 2 | — | — | — | **dropped** | ### 3.4 New materials needed (proposed values) Sponza is a **scene**, so these are general materials, not Sponza-specific ones. Values are first guesses in the style of the existing table. | name | id block | baseColor (linear) | rough | metal | density | friction | restitution | notes | |---|---|---|---|---|---|---|---|---| | `Brick` | 0x2d (hard rock) | [0.38, 0.17, 0.10] | 0.9 | 0 | 1.9 | 0.8 | 0.08 | Footstep Stone. Fracture: brittle. | | `Terracotta` | 0x2e | [0.55, 0.25, 0.13] | 0.85 | 0 | 1.9 | 0.7 | 0.1 | Roof tiles, plant pots. | | `Ceramic` (glazed) | 0x2f | per shade | 0.35 | 0 | 2.3 | 0.4 | 0.15 | Vases. Brittle: the first natural shatter test once fracture lands. | | `Iron` (wrought) | 0x54 (metals block) | [0.17, 0.16, 0.15] | 0.55 | 1.0 | 7.8 | 0.6 | 0.1 | Chains, brackets. Footstep/impact Metal. `metallic` is not consumed by lighting yet (see 3.1). | | `Cloth` (opaque, stage 1) | sparse family, e.g. 0x7100 + colour | from texture (red / green / blue / banner patterns) | 0.95 | 0 | **0.05** (see §5.1) | 0.7 | 0 | acoustics transmission ~0.3, reflectivity 0.1 (soft). Flammable later. | | `Cloth` translucent (stage 2) | same ids | as above | 0.95 | 0 | 0.05 | 0.7 | 0 | Adds `diffuseTransmission` RGB and per-voxel σ for sun rays; see §5.2. | Existing materials that cover the rest: - `Limestone` (0.84, 0.82, 0.77, r 0.7): walls, columns, arches, ceiling, floor, lion relief, in shade variants. `Sandstone` for the warmer stone. `Marble` (r 0.3) if the owner wants a glossier floor. - `Wood` / `Planks`: flagpoles, beams. - `Leaves`: potted plants. `Dirt`: pot soil. **Dropped:** - the backdrop / sky-dome material (`Material__298`, a 796-tri shell around the scene); - the `gi_flag` helper (18 tris, white); - the untextured centre banner (already gone in McGuire's copy). Lights: Sponza ships none. The scene is sun + sky only, which is the right first GI reference: an open roof, a bright courtyard floor, and deep shaded arcades with multi-bounce. Torches or candles (Intel's add-on) could come later as an emissive variant. --- ## 4. Breaking the scene into objects ### 4.1 The rule - Terrain (regions) and constructs (entity structures) render, shade, cast shadows and take GI through the same code (`docs/entity-system.md`: "two independent geometry sources … the ray march hits whichever is closer"; VSC keys are (partId, localCoord) for both). - The owner's parity rule is that **no behaviour may depend on which kind an object is**. So the split must not be a rendering trick. It should follow **what is naturally a separate object in the real building**: things that are built in are terrain, and things that were carried in and set down or hung up are objects. - Two engine facts reinforce this split: - **Size:** a construct is at most 16 m per axis, and the building shell is 29.8 m long, so the shell can only be terrain. Pots and banners fit easily. - **Physics semantics:** terrain is the static world collider. A construct is a body that can be dynamic, static or kinematic (`spawnConstruct(…, dynamic)`, `spawnKinematic`), can sleep, and can later be jointed or fractured. ### 4.2 Proposed split | Group | Goes to | Why | |---|---|---| | Floor, walls, ground and upper colonnades (columns, capitals, arches), vaults / ceiling, roof and roof tiles, balustrades / "details", **lion reliefs** | **Terrain**: stamped in 4 tiles at native scale (`CsgStamp` of ≤ 256³ prefabs) | Built-in masonry. The lion is a carved relief *in* the wall: carving is part of the wall, not an object on it. Under fracture, a column or relief that gets cut free is detached by the terrain-detachment path (connected component → new construct, `PHYSICS_PLAN.md` §13). That is exactly the right behaviour, and it needs nothing Sponza-specific. | | Floor vases (`vase_round`) and plant pots with plants (`vase` + `leaf` + soil) | **Constructs, dynamic, spawned asleep** (one structure each: pot + soil + plant together) | Carried in and set down. Pushable, can be knocked over, and become the first shatter test for ceramic. Leaves in the same structure keep a plant attached to its pot without joints. | | Hanging vases (`vase_hanging`) + their chains | **Stage 1:** one static construct per vase including its chain. **Joints stage:** chain = 1 kinematic-free body or a few links, distance/ball joint to the ceiling hook (terrain) and to the vase | A pendulum is the simplest joint test (1–3 bodies), simpler than cloth. At 6 cm voxels a chain link (~3–5 cm) is sub-voxel, so the chain becomes a 1-voxel rod line of `Iron`. | | Curtains (ground and upper arcade fabric) and the long banners on flagpoles | **Constructs, static** (stage 1) → strip chains with hinge joints (later, §5.1) | Hung-up objects. The future joints test case. | | Flagpoles | Construct, static, jointed (weld) to the wall later. Simplest: **terrain**, since it is set into the masonry. | Owner decision. Physically a pole is a separate object, but it is built in. Terrain is fine now, and fracture would free it naturally. | | Backdrop sky shell, gi_flag | **Dropped** | Not geometry. | ### 4.3 Notes for the fracture work - Keep walls **solid-filled**, not shells. My measurement script fills the closed interiors (§2), so the connectivity analysis sees real masonry thickness. A hollow shell would fracture into paper. - Columns sit on the floor and carry the arches, so they are one connected component with the building. A "loose-piece detection" pass run right after the stamp should find **zero loose terrain components**. Anything it does find is an importer bug, such as a floating moulding left over from non-watertight mesh pieces. That gives the fracture work a free sanity test. - Constructs resting on terrain (pots) and hanging from it (curtains, hanging vases) are exactly the attachments that fracture has to re-target. Douglas #30 shows this: "the joint has been transferred to the new rigid body that spawned when I cut it apart … if I delete the part of the door that had the hinge, the door is free". The same rule applies with terrain as one side. That matches the parity rule: a joint anchors to *a body or the world grid*, and when either side's voxels change, the joint follows the connected component that holds its anchor voxel. --- ## 5. The hanging fabric ### 5.1 As a joints test case **What exists today.** - `PHYSICS_PLAN.md` §1 puts cloth, soft bodies and "articulated joints beyond simple constraints" out of scope. Phase 6 (destruction) is pending. No joint solver exists. - The TGS solver (4 substeps at 60 Hz), islands, sleep and the 20:1 mass-ratio clamp are the machinery a joint row would join. **Cost references** (`docs/physics-stability-notes.md`): | scene | bodies | step cost | |---|---|---| | `pile-big` | 20 dice in one island | ~2.8 ms | | `stack-tall` | 20 | ~2.6 ms | | `pile-huge` | 500 | 12.3–16.5 ms per 60 Hz step, mostly during landing; i.e. at the frame budget | **Model (Douglas #30, mapped onto our solver).** - Douglas uses one generic form: every joint is a smooth error function C, with Jacobian J = ∂C/∂x and λ solved from JM⁻¹Jᵀ. He offers 16 joint types built from {weld, line/prismatic, distance} × {free, axis/revolute, cone}. - In our TGS, a joint is one more constraint row type, solved in the same substep loop as contacts and warm-started by joint id. - A curtain is **a vertical chain of rigid horizontal strips**: - each strip is a construct the curtain's full width (e.g. 24–48 v) and 4–8 v tall (25–50 cm), **2 voxels thick**; - consecutive strips are joined by a **revolute (hinge) joint** about the shared horizontal edge, or by two ball/distance joints at the edge's ends. Two ball joints let the strip also twist a little, which reads more like cloth; - the top strip hinges to the rod or arch: terrain or the flagpole construct. - Adjacent strips in a joint must **not collide with each other**: joints need a "disable collision between jointed pair" filter, the standard feature. - The strips are thin bodies, so give them low but non-tiny density (Cloth 0.05). That makes a 3 m × 1.5 m × 2 v curtain ≈ 0.56 m³ of voxels × 50 kg/m³ ≈ 28 kg: a heavy velvet curtain. A realistic 300 g/m² cloth would be ~1.4 kg, and density 0.0024 makes the 20:1 mass-ratio clamp kick in against anything it touches. **Owner decision D6.** - Folding along the vertical axis (a curtain bunching sideways) needs a 2D grid of pieces (×3–4 bodies) or, better, staying with 1D strips. Real heavy curtains mostly swing as a pendulum chain; 1D strips are the defensible "matches human intuition" cheat. **Body counts for Sponza** (cloth pieces counted in §2.3 from the voxelized mesh): | piece | count | strips each | bodies | |---|---|---|---| | ground-floor curtains (38 × 37 v) | 10 | 6 strips of ~6 v | 60 | | upper drapes / hangings (≥ 200 v pieces) | 16 | ~3–4 | ~55 | | hanging bowls + chains | 4 | 1 bowl + 1–3 chain links | 8–16 | | **total jointed** | | | **~125–130** | | (unjointed dynamic: floor vases + plant pots) | 12 | — | 12 | - Rule of thumb: **~100–200 jointed bodies**, ~1/3–1/5 of `pile-huge`. Asleep they cost nothing, and a draught or a push wakes one curtain (~10 bodies, one island). - **Worst case** is everything awake at once. With the joint rows at ~1–2 per strip pair, that is probably 3–6 ms/step on the per-island parallel solve. - That is an **estimate to measure, not a promise**. Long hinge chains are where Gauss-Seidel converges slowly. Mitigations: TGS substeps already help; solve each chain top-down; or later an "articulated chain" direct solve. **Static first, physics later.** Stage 1 spawns each curtain as one static construct with its draped shape baked from the mesh. The GI reference gets its cloth at no physics cost, and the stage-2 translucency work doesn't wait on joints. The jointed version replaces the static construct with N strip constructs **cut from the same voxels**, cut horizontally every k voxels. The shape at rest is then the authored drape, which the solver will hold only if the rest pose is an equilibrium. A flat hanging curtain is; Sponza's draped/tied curtains are not, so they would "fall straight" when simulated (owner decision D7: authored drape kept static vs simulated hang). **Order relative to fracture.** The owner's queue is impact → cracking → shattering → joints → hinges. The curtain needs only joints + hinges and no fracture. The hanging vase needs a distance joint and is the smaller first joint test: 1 joint, 1–3 bodies, a pendulum with a known period. The fracture → joint handoff, a joint following its anchor's connected component, becomes testable when the arch that holds a curtain is broken. ### 5.2 Light through cloth **What the renderer does today.** Sources: `docs/surface-gi-workstream.md` "Ray Semantics", `docs/celestial-lighting.md` §3, `ROADMAP.md`, `wgsl-svt.ts` `traceShadowTransmissionSuperRegion`, `voxel-shadow-refresh-pass.ts`. - **Opaque voxels:** - The primary ray stops at the first voxel whose material is not in the 8 KB transparency bitmask. - Each visible voxel gets **one VSC shading cell** (keyed per voxel, not per face) with a smooth normal. - Sun visibility per cell is one hard ray toward the light centre. Its **RGB565 transmittance** is cached in the VSC tail. Entity casters are traced inline; the P2 screen filter re-derives visibility near edges. - Indirect light is surface GI on proxy cells: `contribution = T · (emission + directSun + albedo · previousIrradiance)`. - **Transparent voxels (water, ice, glass, quartz):** - They are skipped by the opaque walk and integrated by the transparent walk (Beer–Lambert `absorption` per voxel, `tint` body colour, a first-interface glint). - **Shadow rays accumulate their RGB optical depth.** The walker returns 0 on an opaque voxel and multiplies through transparent ones, which is how stained glass already throws coloured, per-cell shadows. - **GI rays carry `T = exp(-τ)`** through them. - **Facing-away cells** (`VSC_FACING_AWAY_BIT`) skip the sun trace entirely. **Why glass semantics are wrong for cloth.** - Fabric is a **diffuse translucent**. You cannot see through it; you see its own lit surface. - Back-lit, it **glows**: light that crosses it is re-emitted diffusely from the far face, so a curtain lit from behind shows its colour on the dark side. - It throws a **coloured, attenuated shadow** behind it. Thin silk lets some direct light through; velvet almost none. - So cloth must be **opaque to the camera** (a gbuffer hit with its own per-voxel shading cell, keeping the aesthetic) and **partly transmissive to light**. **Minimal design: "translucent" = camera-opaque, light-transmissive.** 1. **Material data** (`common/src/material.ts`, mirrored in voxel-core `material.rs`). - Add a GPU-visible `MaterialFlags.Translucent` bit (spare bit in the 16-bit flags; the shader reads only Unlit/Liquid/Animated today). - Add an RGB `diffuseTransmission` k_t, packed unorm8×3 into reserved word `u7`. - The sun-ray attenuation σ reuses the existing `absorption` field, which opaque materials leave inert. - **No buffer growth, no new binding.** `iorClass` stays `Opaque`, so the normals classifier, physics, the IOR/refraction code and the primary transparent walk are untouched. 2. **A second 8 KB bitmask, "transmits light"** = transparent ∪ translucent. - It is bound *in place of* the transparency mask for **sun-shadow rays only**: the VSC shadow refresh and lighting's inline entity shadow ray (`traceShadowTransmission*`). - The walker code is unchanged. It already tests `matIsTransparent(mat)` per voxel or uniform node and accumulates `absorption × span`. - Primary rays and **GI rays keep the current mask, so they hit cloth**. That is the right physics for a diffuse transmitter: a GI ray from the floor behind a curtain should see the curtain's glowing far face, not the sky through it. - Where a pass needs both masks, pack them as 2 bits per material in one 16 KB uniform. That is well inside WebGPU's 64 KB default `maxUniformBufferBindingSize`, so binding counts are unchanged. 3. **Node bits** (voxel-core `svt64_write.rs` / `svt64_edit.rs` and the TS mirror). - Bit 17 `hasTransparent` must mean "subtree contains a light-transmitting voxel", so shadow walks descend into cloth instead of taking a solid-subtree shortcut. Cloth also sets bit 16 `hasOpaque`, so the primary walk stops on it. - The voxel-level masks keep each walker correct. The bits only gate skipping. **To verify:** any fast path that reads `hasOpaque ∧ ¬hasTransparent` as "certain blocker". - Existing worlds contain no cloth, so **stored bytes and `svtStateHash` are unchanged**: no DB wipe, and `--raw` / corpus goldens are unaffected. 4. **Lighting** (`lighting-worklist-pass`). - For a Translucent cell: E_sun = E⊥ · [ max(N·L,0) · T_front + k_t · max(−N·L,0) · T_through ]. - T_through is the cell's own cached shadow ray. For a cell facing away from the sun, that ray leaves through the cloth's own far side, so it accumulates the cloth's σ: one or two voxels of the curtain, then anything beyond. That gives "glows red when back-lit, dark when a wall is behind it" with no new ray type. - Change: Translucent slots must **not** be skipped by the facing-away rule in the shadow refresh. 5. **GI.** - **Stage 2a (minimal): no GI change.** GI rays already hit the cloth and read its cell radiance, which now includes the transmitted direct sun, so back-lit curtains bounce coloured light into the arcade. Sun through the cloth onto the floor already arrives tinted through the shadow ray. - **Stage 2b: what is missing** is *indirect* light crossing the cloth, i.e. sky or bounce from the far side. - The fix: a translucent cell's GI gather samples the **full sphere** (half the rays per hemisphere) and stores E_front + k_t·E_back. - That touches ray generation and accumulation in the surface-GI update passes; per-cell ray count is unchanged. - It only matters for curtains lit mostly by sky from behind. - Ship 2a, measure 2b. 6. **Shadow-cell aesthetic.** - Everything stays per voxel: the cloth's cells are ordinary VSC cells, and the coloured shadow lands per receiver cell, exactly as stained glass does today. - The P2 sun-shadow filter treats a partly transmitting cell the way it treats a glass shadow (blocker bit only for opaque blockers). Nothing is smoothed beyond the existing ≤2-voxel contact-hardened penumbra. - **Thickness:** make curtains **2 voxels thick**. A VSC cell is per voxel, so a 1-voxel sheet has one cell, and one ambiguous normal, for both faces. Its front and back would then shade identically, which defeats the back-lit term. Two voxels gives each face its own cell. (A 1-voxel sheet could work with a "flip N toward the viewer" rule like double-sided planes. That would be a per-view rule; avoid it.) 7. **Safari / WebGPU.** - Nothing new is required: storage and uniform buffers as today, `unpack4x8unorm` for k_t, no f16 shader feature, no new bindings if the masks are packed. - It runs wherever stained-glass shadows run today, including Safari 26 WebGPU. 8. **Physics / audio.** - Cloth voxels are ordinary solid voxels for collision. - Acoustics: transmission ~0.3 (soft), low reflectivity. That is already data-driven. **Proposed cloth values** (stage 2; tune against a fixture): | | baseColor (lin) | k_t (diffuse transmission) | σ per voxel (sun ray) | T at 2 voxels, normal incidence | |---|---|---|---|---| | red velvet curtain | [0.45, 0.05, 0.04] | [0.30, 0.03, 0.02] | [0.8, 2.5, 2.8] | [0.20, 0.007, 0.004] | | green | [0.06, 0.25, 0.07] | [0.03, 0.20, 0.04] | [2.5, 1.0, 2.4] | [0.007, 0.14, 0.008] | | blue | [0.05, 0.08, 0.35] | [0.02, 0.05, 0.25] | [2.6, 2.0, 0.9] | [0.006, 0.02, 0.17] | | thin silk banner | per pattern shade | 0.5 × baseColor | 0.35 × (1 − baseColor) + 0.1 | ~0.5–0.8 tinted | **Estimate of what changes where:** | area | files | size | |---|---|---| | material data, flag, k_t pack, mask builder, cloth family | `common/src/material.ts`, `common/src/voxel.ts`, voxel-core `material.rs` | ~120 lines | | node-bit predicate (transmits light) | voxel-core `svt64_write.rs`, `svt64_edit.rs` (+ wasm rebuild) | ~30 lines + tests | | shadow walkers get the light mask | `voxel-shadow-refresh-pass.ts`, lighting entity-shadow binding, `wgsl-svt.ts` | ~60 lines | | back-lit term + facing-away exception | `lighting-worklist-pass` WGSL, `voxel-shadow-refresh-pass.ts` | ~40 lines | | debug view (k_t / translucent mask), fixture station (back-lit / front-lit curtain, coloured shadow, curtain against a wall) | `transparency.ts` or a new `cloth` fixture | ~150 lines | | GI 2b (later) | surface-GI update passes | ~100–200 lines | - Total **~400 lines for stage 2a**, plus tests; one agent round. - **This is a renderer change: it needs the surface-GI gate's GPU lane before merge**, plus a new gate scenario for back-lit cloth with its own baseline. Existing scenarios must not move, because no current material becomes translucent. --- ## 6. Staged plan and owner decisions ### Stages | # | Stage | Code touched | Gate | Rough size | |---|---|---|---|---| | S0 | **Licence + source.** Fetch McGuire's `sponza.zip` (78 MB, CC BY 3.0) into `research/`. Record the attribution in a `CREDITS` entry. | — | — | trivial | | S1 | **Importer.** Offline mesh voxelizer (`scripts/sponza/` or `tools/`): per-material-name sampling, texture shade, alpha mask, solid fill, per-object groups, ≤ 256³ tiles. Extend `vox-to-prefab` / `import-vox.ts` to 16-bit material ids. | tooling + `common/src/import/` | `check` / `test` / `lint` | 1 round | | S2 | **Materials.** Add `Brick`, `Terracotta`, `Ceramic`, `Iron`, opaque `Cloth` family; shade-ramp families (generated like stained glass). | `common/src/material.ts` (+ voxel-core mirror if needed) | The GI gate: new ids touch the material buffer, but existing ids are unchanged, so it should pass. | small | | S3 | **`sponza` fixture.** Stamp the 4 terrain tiles; spawn pots and vases (dynamic, asleep), curtains, banners and hanging vases (static constructs). Sun + sky config chosen for a classic shaft through the roof. | `server/src/fixtures/scenes/sponza.ts`; the `.vplib` asset | Fixture loads; physics settles (pots asleep). | 1 round | | S4 | **GI reference.** Add Sponza poses as surface-GI gate scenarios: arcade in shade, courtyard floor, upper gallery, curtain front. Record baselines. Optionally compare against an offline path-traced reference of the same voxels. | gate script + baselines | Its own rebaseline commit with explanation | 1 round | | S5 | **Translucent cloth (2a).** §5.2 items 1–4, 6–8. | renderer + material + voxel-core | **GPU lane + new back-lit scenario** | ~400 lines, 1 round | | S6 | **Cloth GI through (2b).** Full-sphere gather for translucent cells. | surface-GI passes | GPU lane | measure first | | S7 | **Joints** (after fracture): distance joint → hanging vase; revolute chain → curtains; joints follow anchor components through fracture. | physics-rs, host, wire (joint component) | `physics-suite --raw` (new fixtures only; existing unchanged) | big; its own design doc | ### Owner decisions - **D1 Source:** McGuire OBJ (CC BY 3.0) [rec] vs Khronos glTF (CRYENGINE licence, unread) vs Intel 2022 (3.7 GB + add-ons, CC BY version unconfirmed). - **D2 Scale:** native 0.008 m/unit (29.8 m, 4 regions) [rec] vs 0.01 (37 m, 6 regions) vs 2× (60 m, 24 regions, more detail, out of human scale). Numbers are in §2.2. - **D3 Colour:** shade ramps from textures [rec, with a flat-albedo switch] vs flat per-material colour. - **D3b Albedo level:** the raw texture means (floor sRGB 180,163,138 → linear 0.46) vs Khronos/Pestana's ×0.588 darkening. The darkened version matches most published Sponza renders. Either way, GI brightness depends on it. - **D4 Asset in git:** commit the derived `.vplib` (~3 MB material SVT at 1×, CC BY 3.0 allows it with attribution; the forge repo is private) vs keep it out of git and fetch + build on demand. Committing is needed for the GI gate to use the scene. - **D5 Flagpoles:** terrain [rec, simplest] vs constructs. - **D6 Cloth density:** 0.05 (heavy velvet, stable against the mass clamp) [rec] vs a realistic ~0.0025. - **D7 Curtain drape:** keep the authored draped shape static [rec for S3] vs simulate it falling straight once joints land. - **D8 Cloth thickness:** 2 voxels [rec] vs 1 voxel plus a per-view normal flip. - **D9 Translucent design:** camera-opaque / light-transmissive class with GI 2a [rec] vs reusing the glass path as is (zero code, but it looks like tinted glass) vs opaque cloth only.