M4: fog: explored bitmap, vision cut-out and player markers #70

Closed
opened 2026-11-20 22:31:44 +01:00 by SirStone · 1 comment
Owner

Part of #63

Goal

Three-state fog from explored + vision, updated only for new cells and new polygons; markers above fog; GM no fog.

Acceptance criteria

  • Pixel probes: unexplored near-black, explored dim (~0.6), visible map colour
  • Fog follows a move with no reload
  • Markers appear at anchors and vanish on del
  • GM map unfogged
  • Only changed cells/polygons touched
  • Standing gate: full devbox run test green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at".

User stories covered

  • 20 — As a player, I want never-seen floor to be solid black, so that I cannot infer the map.
  • 21 — As a player, I want explored-but-not-visible floor dimmed, so that I remember the layout without seeing what happens there.
  • 22 — As a player, I want currently visible floor clear, so that I can see the scene I am in.
  • 23 — As a player, I want the fog to follow my token as it moves, so that I do not need a reload to see.
  • 24 — As a player, I want a window icon where I have seen a marked window, so that I remember it after walking away.
  • 25 — As a player, I want a marker to disappear when the GM removes the wall or turns its marker off, so that my memory matches the world.
  • 26 — As a GM, I want no fog over my map by default, so that I see everything while running the game.
  • 27 — As a player, I want fog to be cosmetic client-side presentation only, so that hidden things never reach my browser at all.

Proven at

fog/marker layer, reducer fog slice; e2e

Notes

  • Size: M (about one agent session, ~100K tokens). Lane: F (fog).
Part of #63 ## Goal Three-state fog from `explored` + `vision`, updated only for new cells and new polygons; markers above fog; GM no fog. ## Acceptance criteria - [ ] Pixel probes: unexplored near-black, explored dim (~0.6), visible map colour - [ ] Fog follows a move with no reload - [ ] Markers appear at anchors and vanish on `del` - [ ] GM map unfogged - [ ] Only changed cells/polygons touched - [ ] Standing gate: full `devbox run test` green on a clean checkout, no test weakened or skipped, and the behaviour above proven at the seam(s) listed under "Proven at". ## User stories covered - 20 — As a player, I want never-seen floor to be solid black, so that I cannot infer the map. - 21 — As a player, I want explored-but-not-visible floor dimmed, so that I remember the layout without seeing what happens there. - 22 — As a player, I want currently visible floor clear, so that I can see the scene I am in. - 23 — As a player, I want the fog to follow my token as it moves, so that I do not need a reload to see. - 24 — As a player, I want a window icon where I have seen a marked window, so that I remember it after walking away. - 25 — As a player, I want a marker to disappear when the GM removes the wall or turns its marker off, so that my memory matches the world. - 26 — As a GM, I want no fog over my map by default, so that I see everything while running the game. - 27 — As a player, I want fog to be cosmetic client-side presentation only, so that hidden things never reach my browser at all. ## Proven at fog/marker layer, reducer fog slice; e2e ## Notes - Size: M (about one agent session, ~100K tokens). Lane: F (fog).
SirStone added the ready-for-agentenhancement labels 2026-11-20 22:31:44 +01:00
SirStone added a new dependency 2026-11-20 22:31:45 +01:00
SirStone added a new dependency 2026-11-20 22:31:45 +01:00
SirStone added a new dependency 2026-11-20 22:31:46 +01:00
SirStone added a new dependency 2026-11-20 22:31:46 +01:00
Author
Owner

Implemented on main (2d9548c).

What landed

  • client/src/slices/fog.ts: pure fog slice for explored (full RLE + cell diffs), vision polygons and marker set/del; hello resets it with every other slice.
  • client/src/render/modules/fog.ts: one cell-resolution RGBA canvas holds explored (never-seen alpha 1.0, explored 0.6); the sprite texture is that canvas with the vision polygon union cut out via destination-out (recomposed only on explored/vision frames). Cell diffs mutate only the new bytes and upload the dirty rect. Markers are sprites above the fog; GM hides the layer.
  • Tile integration: a tile denied with 403 while unexplored is asked once more when the fog reports its cells explored; unexplored 403s still never retry.
  • Tests: reducer-seam fog slice tests (12) + browser e2e with screenshot pixel probes (unexplored black, explored dim, visible map colour, window see-through, one-way blind side, secret door, marker anchor + retraction, drag-driven fog with no reload, reconnect resync, GM unfogged).

Mechanism note — spec #63 decision 9 leaves the Pixi object to the build. A Graphics stencil mask was measured first and cost ~350 ms of the phone-class viewport-fill budget on the e2e's software renderer (fill 1049 ms vs 665 ms pre-fog), so the cut-out is baked into the fog canvas instead (fill 574–695 ms, at/below the pre-fog baseline). Edge granularity is the cell grid the server already uses.

Perf (e2e emulation: 412x869, dpr 2.625, 4x CPU, 4096 px map = 16 384 cells, 50 tokens)

  • connect explored snapshot: 0.6–1.4 ms (full repaint)
  • move diff: 0.0–0.8 ms for ~20 new cells
  • vision recompose: 0.0–0.9 ms
  • frame cadence: median 72–98 ms in headless SwiftShader (recorded, not a gate; the phone run is #77)
  • 16384 px map (262 144 cells): full repaint scales ~16x (single-digit-to-~20 ms); diffs stay O(new cells).

Gates (sequential, green on the pushed commit)

  • devbox run test: 159/159
  • devbox run client-test: 148/148
  • devbox run e2e: 22/22
Implemented on main (2d9548c). **What landed** - `client/src/slices/fog.ts`: pure fog slice for `explored` (full RLE + cell diffs), `vision` polygons and `marker` set/del; `hello` resets it with every other slice. - `client/src/render/modules/fog.ts`: one cell-resolution RGBA canvas holds explored (never-seen alpha 1.0, explored 0.6); the sprite texture is that canvas with the vision polygon union cut out via `destination-out` (recomposed only on explored/vision frames). Cell diffs mutate only the new bytes and upload the dirty rect. Markers are sprites above the fog; GM hides the layer. - Tile integration: a tile denied with 403 while unexplored is asked once more when the fog reports its cells explored; unexplored 403s still never retry. - Tests: reducer-seam fog slice tests (12) + browser e2e with screenshot pixel probes (unexplored black, explored dim, visible map colour, window see-through, one-way blind side, secret door, marker anchor + retraction, drag-driven fog with no reload, reconnect resync, GM unfogged). **Mechanism note** — spec #63 decision 9 leaves the Pixi object to the build. A Graphics stencil mask was measured first and cost ~350 ms of the phone-class viewport-fill budget on the e2e's software renderer (fill 1049 ms vs 665 ms pre-fog), so the cut-out is baked into the fog canvas instead (fill 574–695 ms, at/below the pre-fog baseline). Edge granularity is the cell grid the server already uses. **Perf (e2e emulation: 412x869, dpr 2.625, 4x CPU, 4096 px map = 16 384 cells, 50 tokens)** - connect explored snapshot: 0.6–1.4 ms (full repaint) - move diff: 0.0–0.8 ms for ~20 new cells - vision recompose: 0.0–0.9 ms - frame cadence: median 72–98 ms in headless SwiftShader (recorded, not a gate; the phone run is #77) - 16384 px map (262 144 cells): full repaint scales ~16x (single-digit-to-~20 ms); diffs stay O(new cells). **Gates (sequential, green on the pushed commit)** - `devbox run test`: 159/159 - `devbox run client-test`: 148/148 - `devbox run e2e`: 22/22
Sign in to join this conversation.