Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(verse): stop surfaces flickering, let the commander climb low steps, keep monitor text one size (#959)
Ruben Lütkeb755bba96910
diff --git a/art/verse/lib/cook.py b/art/verse/lib/cook.pyindex b88a5339ca..21990b4849 100644--- a/art/verse/lib/cook.py+++ b/art/verse/lib/cook.py@@ -393,6 +393,23 @@ def _mesh_soup(roles_wanted: tuple[str, ...], skip_nav: str | None = None) -> Me# ---------------------------------------------------------------- nav grid+def cook_nav_only(deck_id: str, out_dir: Path) -> dict:+ """Only the nav grid of deck `deck_id` (the current scene): `nav.npy` + `nav.json` in `out_dir`.++ For changes to the walkability rules: the plate, its lighting and the+ realtime export stay as they are.+ """+ info = scene.deck_info()+ if info["deck_id"] != deck_id:+ raise CookError(f"scene holds deck {info['deck_id']!r}, not {deck_id!r}")+ out_dir = out_dir.resolve()+ out_dir.mkdir(parents=True, exist_ok=True)+ bpy.context.view_layer.update()+ nav = _cook_nav(info["bounds"], out_dir / "nav.npy")+ (out_dir / "nav.json").write_text(json.dumps(nav, indent=1), encoding="utf-8")+ return nav++def _cook_nav(bounds: scene.Bounds, path: Path) -> dict:"""Rasterise walkable floor (navgrid.CELL_M cells) with per-cell floor height."""soup = _mesh_soup(("Architecture", "Props"), skip_nav=naming.NAV_NONE)@@ -459,19 +476,21 @@ def _nav_trees(soup: MeshSoup) -> tuple[BVHTree, SolidTree]:def _column_floor(walk_bvh: BVHTree, solids: SolidTree, x: float, y: float, top: float, bottom: float) -> float:- """Height of the walkable floor under (x, y), or NaN when blocked or no floor."""- floors = [z for z, nz, _ in _column_hits(walk_bvh, x, y, top, bottom) if nz > 0.5]+ """Height of the walkable floor under (x, y), or NaN when blocked or no floor.++ A level walk face counts whichever way it faces: builders leave single+ gratings and treads with their normals flipped down, and the body then+ walked through them at the floor below.+ """+ floors = [z for z, nz, _ in _column_hits(walk_bvh, x, y, top, bottom) if abs(nz) > 0.5]if not floors:return math.nanfloor_z = floors[0]if solids.bvh is None:return floor_z- band_low, band_high = floor_z + NAV_STEP_M, floor_z + NAV_HEADROOM_Mhits = _column_hits(solids.bvh, x, y, top, bottom)- for low, high in _solid_intervals(hits, solids.owner, top):- if low < band_high and high > band_low:- return math.nan- return floor_z+ intervals = list(_solid_intervals(hits, solids.owner, top))+ return navgrid.stand_height(floor_z, intervals, NAV_STEP_M, NAV_HEADROOM_M)def _column_hits(@@ -494,18 +513,23 @@ def _solid_intervals(hits, owner_of: np.ndarray, top: float) -> Iterator[tuple[f"""Height intervals filled by solids, from entry/exit pairs per object.Going down, an up-facing hit enters an object and a down-facing hit leaves- it. Unpaired hits are treated conservatively (filled to the far end), and- steep faces hit at grazing angles count as a thin slab.+ it. A leaving hit without an entry fills up to the object's previous hit+ above it (an inner face of a closed part: a plinth under a cabinet, a+ plate on its base), or without one to the far end (an open shell, never a+ step). An entry without an exit fills down to the far end, and steep faces+ hit at grazing angles count as a thin slab."""entered: dict[int, float] = {}+ last: dict[int, float] = {}for z, nz, triangle in hits:owner = int(owner_of[triangle])if nz > 0.2:entered.setdefault(owner, z)elif nz < -0.2:- yield z, entered.pop(owner, top)+ yield z, entered.pop(owner, last.get(owner, math.inf))else:yield z - 0.01, z + 0.01+ last[owner] = zfor z in entered.values():yield -math.inf, zdiff --git a/art/verse/lib/navgrid.py b/art/verse/lib/navgrid.pyindex e55270d778..8b0651e371 100644--- a/art/verse/lib/navgrid.py+++ b/art/verse/lib/navgrid.py@@ -19,6 +19,46 @@ HEIGHT_ZERO = 128HEIGHT_STEP_M = 0.025+def stand_height(+ floor_z: float,+ intervals: list[tuple[float, float]],+ clear_m: float,+ headroom_m: float,+ max_step: float = MAX_STEP_M,+) -> float:+ """Where a body stands in one column, or NaN when it cannot.++ `floor_z` is the highest walk surface, `intervals` the (low, high) heights+ solids fill in the column. A solid lower than `clear_m` is stepped over;+ a solid that stands on the floor and ends at most `max_step` above it (a+ platform, a grating, a stair tread, a door sill that the builder did not+ tag as floor) is stepped ONTO, so its top becomes the floor. Everything+ else inside the headroom above the floor blocks. Thin slabs (a wall face+ hit at a grazing angle, 2 cm) are never stood on.+ """+ # A lone face lying on the floor with its normal flipped down (a plate or a+ # mat built as one quad) reads as a solid of unknown height: it is flat.+ intervals = [+ (low, high)+ for low, high in intervals+ if not (high == math.inf and abs(low - floor_z) <= 0.03)+ ]+ for _ in range(4): # a stack of treads at most+ band_low, band_high = floor_z + clear_m, floor_z + headroom_m+ blocking = [(low, high) for low, high in intervals if low < band_high and high > band_low]+ if not blocking:+ return floor_z+ steps = [+ high+ for low, high in blocking+ if low <= floor_z + clear_m and high <= floor_z + max_step and high - low > 0.021+ ]+ if not steps or max(steps) <= floor_z:+ return math.nan+ floor_z = max(steps) # stand on the tread, then look again from there+ return math.nan++def reduce_samples(samples: np.ndarray, k: int, max_step: float = MAX_STEP_M) -> np.ndarray:"""(rows*k, cols*k) sample heights -> (rows, cols) cell heights, NaN = blocked.diff --git a/docs/verse/pipeline.md b/docs/verse/pipeline.mdindex 58d9f3df62..3111d27657 100644--- a/docs/verse/pipeline.md+++ b/docs/verse/pipeline.md@@ -218,6 +218,19 @@ or hang over drops. One walk level per cell (`lib/navgrid.py`). Walk surfacesand solids are cast against separate ray trees, so a solid standing flush onthe floor (sill, inlay, wall bottom) never hides the floor under it.+Steps (`navgrid.stand_height`, 2026-10-27): a `block` solid that stands on+the floor and ends at most 0.3 m above it (a platform, a grating, a tread, a+lift housing's sill) is stepped onto, so its top becomes the floor there;+until then every untagged platform over 0.15 m was a wall the body could not+climb. A level `walk` face counts whichever way its normal points (single+gratings built with the normal down were walked through at the floor below).+A solid's leaving hit without an entry fills up to the object's previous hit+above it, and a lone flipped face lying on the floor is flat, not a block of+unknown height. After a change to these rules,+`python scripts/verse/cook.py deck <id> --nav-only` rebuilds only `nav.png`+and the manifest's `nav` block (about a minute per deck, no GPU, the plate+and the realtime export stay as they are).+Light probes: one per room at `probe_at` or the room centre, 1.4 m above its floor; a 64 × 32panorama projected to 9 RGB radiance coefficients in three.js`SphericalHarmonics3` order (`lightProbe.sh.fromArray(sh.flat())`).diff --git a/docs/verse/realtime.md b/docs/verse/realtime.mdindex dbf683157e..a9346ba1e8 100644--- a/docs/verse/realtime.md+++ b/docs/verse/realtime.md@@ -198,6 +198,24 @@ eye view clears to true black (AgX lifts the plate view's near-black clearcolour to a visible grey). Deck materials are double-sided: Cycles rendersboth sides of a face, and builders leave open quads (star fields, decals)facing either way.++Depth order (2026-10-27): the kit lays many faces in one plane (a raised+floor's edge flush with a wall, a recess panel on wall paint, a beam on the+hull plating, two rooms' walls back to back, 1,500 to 10,000 m² per deck),+and without an order the GPU picked one surface per pixel and per frame, so+whole strips of wall flickered as the camera moved. The deck shader moves+every vertex back along its view ray by a fraction of its distance (the+picture stays put, only the depth changes): each material of a deck gets+its own step (`depthOrder`: keys, lights and screens in front, then trims,+structure, walls and floors, the hull), back faces lose to all of them, and+the near plane is 8 cm (was 5 cm). Measured with a near-plane jitter (pixels+that change when only the depth mapping moves) over 30 to 40 random eye+points per deck: hangar 13,500 → 1,030, engineering 257 → 129, ops+11,663 → 10,087, bridge 819 → 799. A per-material polygon offset and larger+steps measured worse: they push surfaces that sit millimetres apart into+new ties. What is left in ops is wall panels that cross each other by a+millimetre or two (the int16 positions of two chunks round differently):+a fixed jagged edge, not a flicker.Tier "low" (a GPU that stays slower than ~45 fps for 2.5 s at "high"):direct render, no bloom, pixel ratio at most 1. `runtime.stats.tier` showsthe tier; `window.__verseStats` exposes the frame numbers in every build.diff --git a/dodaios/ui/web/frontend/public/verse/decks/engineering/manifest.json b/dodaios/ui/web/frontend/public/verse/decks/engineering/manifest.jsonindex 55bf3d5282..e7b623e908 100644--- a/dodaios/ui/web/frontend/public/verse/decks/engineering/manifest.json+++ b/dodaios/ui/web/frontend/public/verse/decks/engineering/manifest.json@@ -80,7 +80,7 @@"height_step": 0.025,"max_step": 0.3,"clearance": 0.25,- "walkable_cells": 69562+ "walkable_cells": 69679},"env": {"url": "env.hdr",diff --git a/dodaios/ui/web/frontend/public/verse/decks/engineering/nav.png b/dodaios/ui/web/frontend/public/verse/decks/engineering/nav.pngindex f77ea33d16..0d5b8f5219 100644Binary files a/dodaios/ui/web/frontend/public/verse/decks/engineering/nav.png and b/dodaios/ui/web/frontend/public/verse/decks/engineering/nav.png differdiff --git a/dodaios/ui/web/frontend/public/verse/decks/hangar/manifest.json b/dodaios/ui/web/frontend/public/verse/decks/hangar/manifest.jsonindex 228de2a7cd..b20f1c39a1 100644--- a/dodaios/ui/web/frontend/public/verse/decks/hangar/manifest.json+++ b/dodaios/ui/web/frontend/public/verse/decks/hangar/manifest.json@@ -80,7 +80,7 @@"height_step": 0.025,"max_step": 0.3,"clearance": 0.25,- "walkable_cells": 100106+ "walkable_cells": 101527},"env": {"url": "env.hdr",diff --git a/dodaios/ui/web/frontend/public/verse/decks/hangar/nav.png b/dodaios/ui/web/frontend/public/verse/decks/hangar/nav.pngindex 4a8d1a4b0d..cfd6e6a458 100644Binary files a/dodaios/ui/web/frontend/public/verse/decks/hangar/nav.png and b/dodaios/ui/web/frontend/public/verse/decks/hangar/nav.png differdiff --git a/dodaios/ui/web/frontend/public/verse/decks/ops/manifest.json b/dodaios/ui/web/frontend/public/verse/decks/ops/manifest.jsonindex 0e4a9b743f..9eab9c43b4 100644--- a/dodaios/ui/web/frontend/public/verse/decks/ops/manifest.json+++ b/dodaios/ui/web/frontend/public/verse/decks/ops/manifest.json@@ -80,7 +80,7 @@"height_step": 0.025,"max_step": 0.3,"clearance": 0.25,- "walkable_cells": 84061+ "walkable_cells": 86139},"env": {"url": "env.hdr",diff --git a/dodaios/ui/web/frontend/public/verse/decks/ops/nav.png b/dodaios/ui/web/frontend/public/verse/decks/ops/nav.pngindex b009d723ff..0893d44ed9 100644Binary files a/dodaios/ui/web/frontend/public/verse/decks/ops/nav.png and b/dodaios/ui/web/frontend/public/verse/decks/ops/nav.png differdiff --git a/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.test.ts b/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.test.tsindex 5632d66c23..4b817beb22 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.test.ts+++ b/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import { Terminal } from "@xterm/xterm";-import { drawGlyph, fitTerminal, gridShape, opaque, paletteFor, shownRows, snapshotText, snapshotXterm, type TermSnapshot } from "./terminalCanvas";+import { MIN_SHOWN_COLS, drawGlyph, fitTerminal, gridShape, opaque, paletteFor, shownRows, snapshotText, snapshotXterm, type TermSnapshot } from "./terminalCanvas";function write(term: Terminal, data: string): Promise<void> {return new Promise((resolve) => term.write(data, resolve));@@ -66,11 +66,17 @@ describe("text fallback and layout", () => {});it("fits the terminal's width and counts the rows that fit", () => {- const f = fitTerminal(80, 960, 400, 0.6);+ const f = fitTerminal(160, 1920, 400, 0.6);expect(f.font).toBe(20);expect(f.fit).toBe(Math.floor(400 / (20 * 1.22)));});+ it("never blows a narrow pane up: every monitor shows at least MIN_SHOWN_COLS columns", () => {+ const wide = fitTerminal(MIN_SHOWN_COLS, 960, 400, 0.6);+ expect(fitTerminal(50, 960, 400, 0.6).font).toBe(wide.font);+ expect(fitTerminal(80, 960, 400, 0.6).font).toBe(wide.font);+ });+it("chooses the grid that gives each pane the largest text", () => {expect(gridShape(1, 1000, 500, 0)).toEqual({ cols: 1, rows: 1 });expect(gridShape(4, 2048, 956, 10)).toEqual({ cols: 2, rows: 2 });diff --git a/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.ts b/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.tsindex 935f29ca9f..9e1cfa33ee 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.ts+++ b/dodaios/ui/web/frontend/src/components/society/verse/effects/terminalCanvas.ts@@ -283,9 +283,17 @@ export interface TileHeader {tone: ScreenTone;}+/**+ * A monitor always shows at least this many columns: a narrow pane (a side+ * split, a small IDE window) was blown up to a few huge words per line, so one+ * desk looked zoomed in and the next zoomed out. A narrower terminal keeps the+ * same text size and leaves the rest of its row dark.+ */+export const MIN_SHOWN_COLS = 110;+/** Font and rows for a terminal `cols` wide in a body `w` x `h`. Pure. */export function fitTerminal(cols: number, w: number, h: number, ratio: number): { font: number; cellW: number; lineH: number; fit: number } {- const font = Math.max(MIN_FONT, Math.min(MAX_FONT, w / (Math.max(20, cols) * ratio)));+ const font = Math.max(MIN_FONT, Math.min(MAX_FONT, w / (Math.max(MIN_SHOWN_COLS, cols) * ratio)));const cellW = font * ratio;const lineH = font * LINE_RATIO;return { font, cellW, lineH, fit: Math.max(1, Math.floor(h / lineH)) };diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/RealtimeBackdrop.tsx b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/RealtimeBackdrop.tsxindex 7613c344a7..1530c3aa82 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/RealtimeBackdrop.tsx+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/RealtimeBackdrop.tsx@@ -141,7 +141,9 @@ export function RealtimeBackdrop({ runtime, deck, active, commanderId, quality =}, [deck, gl, scene]);const camera = useMemo(() => {- const c = new PerspectiveCamera(50, 1, 0.05, 500);+ // Near plane 8 cm: the eyes never come closer to a wall (the body keeps 25 cm), and+ // every centimetre more buys depth precision against flicker between close surfaces.+ const c = new PerspectiveCamera(50, 1, 0.08, 500);c.layers.enable(0);c.layers.enable(REALTIME_LAYER);return c;diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/deckMaterial.ts b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/deckMaterial.tsindex 17f0c678e1..e7d90a4be6 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/deckMaterial.ts+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/deckMaterial.ts@@ -24,6 +24,53 @@ import type { RealtimeMaterial } from "../../content/deck";/** Runtime close-up layers (`detail` in the manifest). */export const DETAIL_KINDS = ["none", "deck_plates", "painted", "metal"] as const;+/**+ * Depth ties between surfaces in one plane. The kit lays many faces flush on+ * each other (a raised floor's edge on a wall, a recess panel on wall paint,+ * a beam on the hull plating, two rooms' walls back to back), and without an+ * order the GPU picked one surface per pixel and per frame, so whole strips+ * of wall flickered as the camera moved. Each surface is moved back along+ * its view ray by a small fraction of its distance (the picture does not+ * move, only the depth). Every material of a deck gets its own step, in+ * layers: keys, lights and screens in front, then trims, structure, walls and+ * floors, the hull, and back faces behind them all. A fraction of the+ * distance stays above the depth buffer's step out to about 25 m (8 cm near+ * plane), unlike a polygon offset, which measured worse: its slope term+ * pushed surfaces that sit millimetres apart into new ties.+ */+export const PUSH_STEP = 2e-5;+/** Back faces: behind every front face of a deck with up to 100 materials. */+export const BACK_FACE_PUSH = 2.5e-3;++/** 0 hull, 1 walls, floors, ceilings, 2 structure and bodies, 3 trims and small parts, 4 keys, indicators, lights, screens. Pure. */+export function surfaceLayer(material: string): number {+ const m = material.replace(/^M_(TMP_[A-Za-z]+_)?/, "");+ if (/^Hull/.test(m)) return 0;+ if (/^(Wall|Floor|Ceiling|Hangar_Deck|Deck_)/.test(m)) return 1;+ if (/^(Struct|Console_Body|Crate|Container|Recess)/.test(m)) return 2;+ if (/^(Indicator|Console_Keys|Screen|Light|Emit|Glass)/.test(m) || /Lamp/.test(m)) return 4;+ return 3;+}++/** Each material's place in the deck's depth order: 0 in front, by layer (front first), then name. Pure. */+export function depthOrder(materials: Iterable<string>): Map<string, number> {+ const names = [...new Set(materials)].sort((a, b) => surfaceLayer(b) - surfaceLayer(a) || (a < b ? -1 : a > b ? 1 : 0));+ return new Map(names.map((n, i) => [n, i]));+}++/** How far a material at `order` moves back, as a fraction of its distance. Pure. */+export function depthPush(order: number): number {+ return order * PUSH_STEP;+}++const DEPTH_PUSH = /* glsl */ `+{+ float versePushNow = verseDepthPush;+ if ( dot( transformedNormal, - mvPosition.xyz ) < 0.0 ) versePushNow = ${BACK_FACE_PUSH.toExponential()};+ gl_Position = projectionMatrix * vec4( mvPosition.xyz * ( 1.0 + versePushNow ), 1.0 );+}+`;+const LIGHTS_FRAGMENT_MAPS = ["#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )"," radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );",@@ -159,8 +206,8 @@ function replaceOnce(source: string, find: string, replacement: string): string* to onBeforeCompile (the `#include` lines still unexpanded). Pure.*/export function patchDeckShader(vertexShader: string, fragmentShader: string): { vertexShader: string; fragmentShader: string } {- let vs = replaceOnce(vertexShader, "#include <common>", "#include <common>\nvarying vec3 vVerseWorld;");- vs = replaceOnce(vs, "#include <project_vertex>", "#include <project_vertex>\nvVerseWorld = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;");+ let vs = replaceOnce(vertexShader, "#include <common>", "#include <common>\nvarying vec3 vVerseWorld;\nuniform float verseDepthPush;");+ vs = replaceOnce(vs, "#include <project_vertex>", `#include <project_vertex>\nvVerseWorld = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;\n${DEPTH_PUSH}`);let fs = replaceOnce(fragmentShader, "#include <common>", `#include <common>\n${FRAGMENT_HEAD}`);const envPars = replaceOnce(ShaderChunk.envmap_physical_pars_fragment,@@ -199,6 +246,8 @@ export interface DeckMaterialInputs {page: Texture;range: number;probe: ProbeBinding | null;+ /** The material's place in the deck's depth order (`depthOrder`). */+ order?: number;}/** Physical when the material needs a clear coat, a specular level other than 4 % or transparency; standard otherwise. */@@ -206,7 +255,7 @@ export function needsPhysical(p: RealtimeMaterial): boolean {return p.clearcoat > 0 || p.transparent || Math.abs(p.specular - 0.5) > 0.05;}-export function makeDeckMaterial({ name, params, page, range, probe }: DeckMaterialInputs): MeshStandardMaterial {+export function makeDeckMaterial({ name, params, page, range, probe, order = 0 }: DeckMaterialInputs): MeshStandardMaterial {const physical = needsPhysical(params);const m = physical ? new MeshPhysicalMaterial() : new MeshStandardMaterial();m.name = name;@@ -237,6 +286,7 @@ export function makeDeckMaterial({ name, params, page, range, probe }: DeckMaterconst uniforms = {...DECK_SHARED,verseRange: { value: range },+ verseDepthPush: { value: params.transparent ? 0 : depthPush(order) },verseBoxOn: { value: probe ? 1 : 0 },verseBoxMin: { value: new Vector3(...(probe?.boxMin ?? [0, 0, 0])) },verseBoxMax: { value: new Vector3(...(probe?.boxMax ?? [0, 0, 0])) },diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtime.test.ts b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtime.test.tsindex 4f12837be6..61a2ea8ca2 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtime.test.ts+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtime.test.ts@@ -7,7 +7,7 @@ import { realtimeContent } from "../../content/loadDeck";import { CommanderControl } from "../../life/control";import { arrivalYaw } from "../../actors/ActorsLayer";import { SHOULDER, ShoulderRig, verticalFov, type SegmentTest } from "./shoulderRig";-import { needsPhysical, patchDeckShader } from "./deckMaterial";+import { BACK_FACE_PUSH, PUSH_STEP, depthOrder, depthPush, needsPhysical, patchDeckShader, surfaceLayer } from "./deckMaterial";import { eyePick, rayCylinder } from "./eyePick";const BRIDGE = resolve(__dirname, "../../../../../../public/verse/decks/bridge/manifest.json");@@ -138,6 +138,35 @@ describe("deck shader patch", () => {expect(needsPhysical({ ...base, specular: 0.12 })).toBe(true);expect(needsPhysical({ ...base, transparent: true })).toBe(true);});++ it("settles depth ties along the view ray: the picture stays, back faces lose most", () => {+ const { vertexShader } = patchDeckShader(physical.vertexShader, physical.fragmentShader);+ const at = vertexShader.indexOf("gl_Position = projectionMatrix * vec4( mvPosition.xyz * ( 1.0 + versePushNow ), 1.0 );");+ expect(at).toBeGreaterThan(vertexShader.indexOf("#include <project_vertex>"));+ expect(vertexShader).toContain("uniform float verseDepthPush;");+ expect(vertexShader).toContain("if ( dot( transformedNormal, - mvPosition.xyz ) < 0.0 )");+ // Every front face of a deck with up to 100 materials stays in front of a back face.+ expect(depthPush(99)).toBeLessThan(BACK_FACE_PUSH);+ // One step is more than a 24-bit depth step at 25 m with an 8 cm near plane, and at 20 m under a millimetre.+ expect(PUSH_STEP * 25).toBeGreaterThan((25 * 25) / (0.08 * 2 ** 24));+ expect(PUSH_STEP * 20).toBeLessThan(0.001);+ });++ it("orders surfaces that share a plane: details over structure over walls over the hull, each material its own step", () => {+ expect(surfaceLayer("M_Hull_Structure")).toBe(0);+ expect(surfaceLayer("M_Wall_PaintedDark")).toBe(1);+ expect(surfaceLayer("M_Floor_GlossBlack")).toBe(1);+ expect(surfaceLayer("M_Recess_Dark")).toBe(2);+ expect(surfaceLayer("M_TMP_PropsInd_ContainerOlive")).toBe(2);+ expect(surfaceLayer("M_Trim_BrushedSteel")).toBe(3);+ expect(surfaceLayer("M_Indicator_Red")).toBe(4);+ expect(surfaceLayer("M_Hangar_FloorLamp")).toBe(4);+ const order = depthOrder(["M_Hull_Structure", "M_Wall_PaintedMid", "M_Floor_GlossBlack", "M_Recess_Dark", "M_Indicator_White"]);+ expect([...order.entries()]).toEqual([+ ["M_Indicator_White", 0], ["M_Recess_Dark", 1], ["M_Floor_GlossBlack", 2], ["M_Wall_PaintedMid", 3], ["M_Hull_Structure", 4],+ ]);+ expect(depthPush(order.get("M_Floor_GlossBlack") ?? 0)).not.toBe(depthPush(order.get("M_Wall_PaintedMid") ?? 0));+ });});describe("eye-level picking", () => {diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtimeScene.ts b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtimeScene.tsindex feefbe2dab..a58e7ab8d4 100644--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtimeScene.ts+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/realtimeScene.ts@@ -21,7 +21,7 @@ import { MeshBVH } from "three-mesh-bvh";import type { RealtimeContent, RealtimeProbe } from "../../content/deck";import { fetchImageBitmap } from "../imageFetch";import { REALTIME_LAYER } from "../renderOrder";-import { makeDeckMaterial, type ProbeBinding } from "./deckMaterial";+import { depthOrder, makeDeckMaterial, type ProbeBinding } from "./deckMaterial";export interface RealtimeScene {group: Group;@@ -190,6 +190,7 @@ export async function loadRealtimeScene(gl: WebGLRenderer, content: RealtimeContconst group = gltf.scene;group.name = "verse-realtime";const unused: Material[] = [];+ const order = depthOrder(Object.keys(content.materials));group.traverse((object) => {const mesh = object as Mesh;if (!mesh.isMesh) return;@@ -203,7 +204,7 @@ export async function loadRealtimeScene(gl: WebGLRenderer, content: RealtimeContconst key = `${info.material}|${info.room}|${info.page}`;let material = materials.get(key);if (!material) {- material = makeDeckMaterial({ name: key, params, page, range: content.range, probe: probes.get(info.room) ?? null });+ material = makeDeckMaterial({ name: key, params, page, range: content.range, probe: probes.get(info.room) ?? null, order: order.get(info.material) ?? 0 });materials.set(key, material);}for (const old of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) unused.push(old);diff --git a/scripts/verse/_cook_entry.py b/scripts/verse/_cook_entry.pyindex 8737299d5a..ef764477c4 100644--- a/scripts/verse/_cook_entry.py+++ b/scripts/verse/_cook_entry.py@@ -1,7 +1,7 @@"""Blender-side cook job: build a deck, optionally save the .blend, cook it.Run by scripts/verse/cook.py through scripts/verse/blender.py:- _cook_entry.py <deck_id> <raw_dir> <quality> [--blend <path.blend>]+ _cook_entry.py <deck_id> <raw_dir> <quality> [--blend <path.blend>] [--nav-only]"""from __future__ import annotations@@ -37,6 +37,7 @@ def main() -> None:parser.add_argument("raw_dir", type=Path)parser.add_argument("quality")parser.add_argument("--blend", type=Path)+ parser.add_argument("--nav-only", action="store_true")options = parser.parse_args(sys.argv[1:])started = time.monotonic()load_builder(options.deck_id).build()@@ -48,6 +49,10 @@ def main() -> None:print(f"[verse] stage save: {time.monotonic() - started:.1f} s ({options.blend})", flush=True)+ if options.nav_only:+ nav = cook.cook_nav_only(options.deck_id, options.raw_dir)+ print(f"[verse] nav {options.deck_id}: {nav['walkable_cells']} walkable cells", flush=True)+ returnresult = cook.cook_deck(options.deck_id, options.raw_dir, options.quality)print(f"[verse] cooked {options.deck_id}: {result['stats']}", flush=True)diff --git a/scripts/verse/cook.py b/scripts/verse/cook.pyindex 2c1085120a..00f37bcc47 100644--- a/scripts/verse/cook.py+++ b/scripts/verse/cook.py@@ -2,7 +2,7 @@python scripts/verse/cook.py deck <id> [--quality preview|final] [--keep-blend][--device auto|optix|cuda|cpu] [--out DIR]- [--realtime]+ [--realtime | --nav-only]Runs `art/verse/decks/<id>/build.py` and `lib.cook.cook_deck()` inside headlessBlender (holding the GPU lock), then packages the raw output into@@ -14,11 +14,16 @@ Blender (holding the GPU lock), then packages the raw output intoand `package_realtime.py` writes `<deck>/realtime/` and the manifest's`realtime` block (docs/verse/realtime.md). The plate stays as it is; thedeck must have been cooked once.++--nav-only rebuilds only the nav grid (nav.png and the manifest's `nav`+block) of a cooked deck, after a change to the walkability rules; the+plate, lighting and realtime export stay as they are."""from __future__ import annotationsimport argparse+import jsonimport shutilimport sysfrom pathlib import Path@@ -60,6 +65,36 @@ def cook_deck(return manifest+def cook_nav(deck_id: str, *, out_dir: Path | None = None) -> dict:+ """Rebuild only the nav grid of a cooked deck and return its manifest block."""+ raw_dir = blender.CACHE_ROOT / "cook" / deck_id / "nav"+ shutil.rmtree(raw_dir, ignore_errors=True)+ raw_dir.mkdir(parents=True)+ blender.run(+ ENTRY,+ [deck_id, str(raw_dir), "preview", "--nav-only"],+ lock=False,+ device="cpu",+ timeout=3600,+ )+ out_dir = out_dir or PUBLIC_DECKS / deck_id+ manifest_path = out_dir / "manifest.json"+ manifest = json.loads(manifest_path.read_text(encoding="utf-8"))+ nav = json.loads((raw_dir / "nav.json").read_text(encoding="utf-8"))+ old = manifest["nav"]+ for key in ("origin_x", "origin_z", "cell", "w", "h"):+ if old[key] != nav[key]:+ raise SystemExit(+ f"nav grid {key} changed ({old[key]} -> {nav[key]}): cook the whole deck"+ )+ manifest["nav"] = package.encode_nav(raw_dir / "nav.npy", out_dir, nav)+ manifest_path.write_text(json.dumps(manifest, indent=1) + "\n", encoding="utf-8")+ problems = validate.validate_deck_dir(out_dir)+ if problems:+ raise SystemExit("deck failed validation after the nav cook:\n " + "\n ".join(problems))+ return manifest["nav"]++def cook_realtime(deck_id: str,quality: str = "final",@@ -102,7 +137,18 @@ def _main(argv: list[str] | None = None) -> int:deck.add_argument("--realtime", action="store_true", help="realtime (eye-level) export instead of the plate")+ deck.add_argument(+ "--nav-only", action="store_true", help="rebuild only the nav grid of a cooked deck"+ )options = parser.parse_args(argv)+ if options.nav_only:+ try:+ nav = cook_nav(options.deck_id, out_dir=options.out)+ except blender.BlenderError as error:+ print(error, file=sys.stderr)+ return 1+ print(f"[verse] {options.deck_id} nav: {nav['walkable_cells']} walkable cells")+ return 0if options.realtime:try:block = cook_realtime(diff --git a/scripts/verse/package.py b/scripts/verse/package.pyindex 723e0afd65..202b9aad6e 100644--- a/scripts/verse/package.py+++ b/scripts/verse/package.py@@ -143,7 +143,7 @@ def _encode_plate(plate: Image.Image, out_dir: Path) -> dict:return levels-def _encode_nav(nav_npy: Path, out_dir: Path, nav: dict) -> dict:+def encode_nav(nav_npy: Path, out_dir: Path, nav: dict) -> dict:grid = np.load(nav_npy)if grid.shape != (nav["h"], nav["w"]):raise ValueError(f"nav grid shape {grid.shape} does not match {nav['h']}x{nav['w']}")@@ -221,7 +221,7 @@ def _write_deck(realtime: dict | None = None,) -> dict:plate = _encode_plate(assemble_plate(raw_dir, cook), staging)- nav = _encode_nav(raw_dir / "nav.npy", staging, cook["nav"])+ nav = encode_nav(raw_dir / "nav.npy", staging, cook["nav"])shutil.copyfile(raw_dir / "occluders.glb", staging / "occluders.glb")shutil.copyfile(raw_dir / "env.hdr", staging / "env.hdr")manifest = build_manifest(cook, plate, nav)diff --git a/tests/verse/test_verse_content.py b/tests/verse/test_verse_content.pyindex fcf7f88f6b..18a68178df 100644--- a/tests/verse/test_verse_content.py+++ b/tests/verse/test_verse_content.py@@ -233,6 +233,29 @@ def test_samples_reduce_to_cells_and_encode() -> None:assert codes.tolist() == [[0, 128, 152, 96]]+def test_low_solids_are_stepped_onto_and_tall_ones_block() -> None:+ stand = navgrid.stand_height+ clear, head = 0.15, 2.0+ # Nothing in the way, or a solid lower than the clearance: the floor.+ assert stand(0.0, [], clear, head) == 0.0+ assert stand(0.0, [(0.0, 0.1)], clear, head) == 0.0+ # A 22 cm grating or platform on the floor (not tagged walk): its top is the floor.+ assert stand(0.0, [(0.0, 0.22)], clear, head) == pytest.approx(0.22)+ # A solid open at its bottom (only its top was hit) counts the same.+ assert stand(0.0, [(-math.inf, 0.25)], clear, head) == pytest.approx(0.25)+ # A single flipped face lying on the floor (only its underside was hit) is flat.+ assert stand(0.0, [(0.0, math.inf)], clear, head) == 0.0+ # Two treads stacked: up both.+ assert stand(0.0, [(0.0, 0.2), (0.2, 0.42)], clear, head) == pytest.approx(0.42)+ # Too high to step onto, a cabinet over a low plinth, a wall face hit at a grazing angle,+ # a solid with no known top, a shelf hanging in the headroom: blocked.+ assert math.isnan(stand(0.0, [(0.0, 0.45)], clear, head))+ assert math.isnan(stand(0.0, [(0.0, 0.08), (0.08, 2.2)], clear, head))+ assert math.isnan(stand(0.0, [(0.19, 0.21)], clear, head))+ assert math.isnan(stand(0.0, [(0.5, math.inf)], clear, head))+ assert math.isnan(stand(0.0, [(0.0, 0.2), (1.2, 1.3)], clear, head))++plate_post = _load("verse_plate_post", REPO_ROOT / "art" / "verse" / "lib" / "plate_post.py")