Skip to content

Nauvis: terrain matches a real surface, with tile correction and allowed_neighbors (#454) - #563

Merged
wormeyman merged 1 commit into
mainfrom
nauvis/real-surface-tiles
Nov 27, 2026
Merged

wormeyman merged 1 commit into
mainfrom
nauvis/real-surface-tiles

Conversation

@wormeyman

Copy link
Copy Markdown
Collaborator

Nauvis's terrain now matches a real Nauvis surface at every tile, where before it matched only the game's map preview. It takes tile correction plus one rule the game enforces: deepwater may only touch water (allowed_neighbors).

Against a real surface (tiles wrong out of 65,536)

window raw argmax (what the preview draws) after after, without the deepwater rule
spawn, -128..127 (committed fixture) 89 0 0
coast, x 384..639, y -320..-65 (committed fixture) 326 0 73
whole 1024 preview window (uncommitted capture) 2,810 0 of 1,048,576 59

Both fixtures come from a fresh game.create_surface with Nauvis's settings at seed 123456, on 2.1.23. The game's own nauvis surface generates spawn chunks before the probe runs, so it can't be used. Both re-capture byte-identical and have PROVENANCE entries.

The deepwater rule

The raw tiles put deepwater next to land 173 times in the 1024 window. From the 2.1.23 binary:

  • TilePrototype::postLoadSetup makes allowed_neighbors two-way.
  • isTileConsistentWithFixedTiles fails a tile at once when a neighbour does not allow it.
  • correctFromTile then takes a replacement from a table that GlobalContext::postPrototypesConstructedSetup builds by breadth-first search. Between deepwater and land, that replacement is always water.

correction.rs gains a Neighbours type (from_allowed) as an Option on Area. correct_window and correct_chunks_with take it, and Gleba and Aquilo pass None and stay at 0. The forbidden-neighbour check comes after the n == c test, so #562's skip of no-op walks stays exact; its lazy-vs-eager and skip tests now also run with a rule active. One limit: the replacement search runs over the planet's own tiles, where the game's runs over every tile. That is enough for Nauvis, because water is the only tile that allows deepwater.

Nauvis has no tile ties: none in the spawn window plus its margin (asserted), and none in a 1024 window or four 512 windows out to 8,000 tiles.

Planted breaks

  • Rows order: spawn 0 -> 2.
  • sand-1's layer set to 176: 0 -> 21.
  • The neighbour used instead of the replacement: coast 0 -> 8,907.
  • No forbidden-neighbour check: coast 0 -> 73.
  • Poison: all three new tests fail, and they are in POISONED_TESTS.

What moved

  • 1024 preview PNG (now a reference): 0 -> 2,810, exactly where the real surface differs from it.
  • Spawn window against the PNG: the render differs at the same 89 pixels as the real surface, asserted pixel by pixel.
  • None of the 75 nauvis:render rows moved, because none is at 1 tile per pixel on a whole-tile origin.
  • No tier-2 fold moved.
  • Tiling: 128 px and 100 px tiles stitch back to the whole render byte for byte.

Cost and what users see

The app opens Nauvis at 1 tile per pixel in all, so every user gets the corrected terrain by default. Other zooms draw the raw argmax.

render (WASM in Node, median of 5 interleaved rounds) raw first eager wiring this PR
all 1024, the app default, 64 tiles of 128, one thread 5,974 ms 14,237 ms 9,290 ms (1.56x)
terrain 1024, same tiles 2,445 ms 10,727 ms 5,825 ms

Most of what remains is the raw tiles in each worker tile's margin. Whether larger worker tiles help is a separate, measured follow-up.

Not covered yet: the resource, rock and enemy overlays still test water against the raw tile.

Gate

pnpm run verify:lint, the full pnpm vp test (1,364 passed) and scripts/verify-rust.sh pass locally. cargo deny is not installed on hammond; CI runs it.

Refs #454.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kd6o1dTdCEZ5JSjytamwMZ

…wed_neighbors

At one tile per pixel on a whole-tile origin, the Nauvis render now runs tile
correction through correct_window (lazy raw reads, the uniform-seed skip)
with a one-chunk margin, and matches get_tile on a real surface at every tile.

- Two committed real-surface fixtures from fresh Nauvis surfaces (seed
  123456, terrain-only, one radius request): the spawn window -128..127 (raw
  argmax 89 off, corrected 0) and a coast window 384..639, -320..-65 where the
  raw tiles put deepwater beside land (326 off, corrected 0).
- correction.rs gains Neighbours: allowed_neighbors and the replacement table
  read from the 2.1.23 binary. Area::lazy, correct_chunks_with and
  correct_window take the rule; Gleba and Aquilo pass None and stay at 0.
  Without the rule the coast window is 73 off. The lazy-vs-eager and skip
  unit tests also run with a neighbour rule active.
- The probe takes FMW_PLANET=nauvis, FMW_X0, FMW_Y0 and FMW_SIDE, and records
  each tile's forbidden neighbours. Gleba's and Aquilo's fixtures re-capture
  byte-identical.
- The 1024 preview PNG count moves 0 -> 2,810, exactly where a scratch real
  surface of that window differs from the PNG (corrected tiles differ from it
  at 0 of 1,048,576). No tier-2 fold or frozen render row moved.
- No argmax ties anywhere checked, so the tie rule is untested on Nauvis.
- Cost at the app's default view (all, 1024, 64 tiles of 128, Node): 5.97 s
  raw, 14.24 s with the first eager wiring, 9.29 s now (1.56x).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1dTdCEZ5JSjytamwMZ
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 38 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 65d1ec24-06ba-4964-84ee-bfad736ac6e9
Commits

Reviewing files that changed from the base of the PR and between 1b09393 and 0895902.

Files ignored due to path filters: 1

  • src/noise/wasm/engine.wasm is excluded by !**/*.wasm
Files selected for processing: 18

  • crates/fmw-noise/src/expressions/aquilo_stack.rs
  • crates/fmw-noise/src/expressions/gleba_stack.rs
  • crates/fmw-noise/src/fixtures.rs
  • crates/fmw-noise/src/fixtures/nauvis_real_surface.rs
  • crates/fmw-noise/src/tiles/correction.rs
  • crates/fmw-noise/src/tiles/mod.rs
  • crates/fmw-noise/src/tiles/nauvis_catalog.rs
  • crates/fmw-noise/src/tiles/nauvis_correction.rs
  • crates/fmw-wasm/src/render.rs
  • docs/noise/tile-correction-NOTES.md
  • docs/rust-wasm-port.md
  • scripts/probes/gleba-real-surface/README.md
  • scripts/probes/gleba-real-surface/capture.ts
  • scripts/verify-rust.sh
  • test/fixtures/PROVENANCE.json
  • test/fixtures/oracle-nauvis-real-surface-coast.seed123456.json
  • test/fixtures/oracle-nauvis-real-surface.seed123456.json
  • test/wasmNauvisRenderParity.spec.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@claude

claude Bot commented Nov 27, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@wormeyman
wormeyman merged commit 55146ed into main Nov 27, 2026
16 checks passed
@wormeyman
wormeyman deleted the nauvis/real-surface-tiles branch November 27, 2026 02:48
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