Skip to content

feat: three-state fog of war rendering - #8

Closed
JJiang28 wants to merge 2 commits into
feat/terrain-renderingfrom
feat/fog-of-war
Closed

feat: three-state fog of war rendering#8
JJiang28 wants to merge 2 commits into
feat/terrain-renderingfrom
feat/fog-of-war

Conversation

@JJiang28

@JJiang28 JJiang28 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Renders the server's fog of war in three states instead of desaturating the whole world.
  • Unexplored ground draws as shroud. Explored ground stays charted and draws dimmed from memory — you remember the coastline and mountains but not what's on them, so no buildings render there. Lit ground (a unit currently has eyes there) draws bright with its structures.
  • Fog is a single source of truth again: the client no longer recomputes distance-from-cities to decide what's fogged, which disagreed with the server once armies granted vision and troops gained different sight ranges.

Notes for reviewers

  • The world keeps two masks: explored (only grows) and visible (the live set, shrinks as well as grows). A stream MapVisibility charts newly-seen tiles into permanent memory (applyVisibility writes the reveal planes and never clears them) and replaces the live set wholesale — an army walking away must dim the ground it was lighting even though the terrain stays known.
  • Buildings render only where visible, which is automatically consistent: the server sends entities for lit tiles alone, so there's no building data on a dimmed tile to draw.
  • The tile panel reports remembered terrain for any charted tile, and distinguishes "unexplored" from "out of sight" in the empty-tile message.

Verification

The dim (remembered) state only arises once a unit charts ground and leaves, which needs an army — so beyond the live check below, I confirmed the render path by temporarily flipping half the visible set to unwatched in the browser: those tiles correctly dropped to the dim tint and lost their buildings while staying drawn, then reload restored the real state.

Depends on the backend fog PR — merge and deploy that first, or GetTerrain returns the old shape.

Test plan

  • yarn check and yarn build clean; yarn generate reproduces committed output
  • Verified against a local backend: a fresh city lights its 11×11 disk (explored 121 / visible 121), no console errors
  • Dim-state render confirmed (see above); reload restores live state
  • Tile panel shows remembered terrain (e.g. "Grassland"); city/building cards and overlays render inside the lit area

JJiang28 and others added 2 commits August 3, 2026 20:47
Terrain arrived unfiltered and the client merely desaturated whatever
lay outside vision. The server now sends a proper fog model, so the map
draws in three states instead of one.

Unexplored ground is unknown and draws as shroud. Explored ground stays
charted even when no unit is watching, and draws dimmed from memory —
you remember the coastline and the mountains, but not what is on them,
so no buildings render there. Only where a unit currently has eyes is a
tile bright and its structures shown; the server sends entities for lit
tiles alone.

The world keeps two masks now: explored, which only grows, and visible,
the live set that shrinks as readily as it grows. A stream update charts
newly seen tiles into permanent memory and replaces the live set as a
whole — an army walking away must dim the ground it was lighting even
though the terrain stays known.

Fog is a single source of truth again. The client used to recompute
Chebyshev distance from owned cities to decide what was fogged, which no
longer agrees with the server now that armies grant vision and different
troops see different distances. Both the shroud and the vision-edge glow
read the server's set.

The tile panel reports remembered terrain for any charted tile, and its
empty-tile wording now distinguishes unexplored ground from ground that
is simply out of sight.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Three small readability passes on the fog.

A minimap in the bottom-left paints the whole world from the same
planes the map draws — shroud for unknown, dimmed for remembered,
bright for lit — with owned cities as gold pips and a box for the
current view. Click it to jump. The terrain layer is cached to an
offscreen buffer and only repainted when vision changes, so panning
just reblits it.

The shroud was dark green and passed for unlit grass; it is now a cool
slate fog, clearly unlike any terrain, so the edge of the charted map
reads at a glance.

Remembered ground was dimmed to a fairly dark cool grey; lightened so
it stays legible while still obviously a step below what a unit is
currently watching.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JJiang28 JJiang28 closed this Aug 5, 2026
@prayujt
prayujt deleted the feat/fog-of-war branch August 5, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant