Skip to content

Vulcanus: round every layer to f32; the terrain render matches the game (#521) - #529

Merged
wormeyman merged 12 commits into
mainfrom
f32-521-vulcanus
Nov 25, 2026
Merged

wormeyman merged 12 commits into
mainfrom
f32-521-vulcanus

Conversation

@wormeyman

@wormeyman wormeyman commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stack 4 of 5 for #521. Base #528. Merge that first; this then retargets to main.

The Vulcanus terrain render now matches the game's own preview on every pixel: 0 of 1,048,576 differ, down from 1.

This rounds every Vulcanus expression layer to f32 one step at a time: the helpers, cracks, elevation, climate, spawn, biomes, resources, rocks, cliff fields and every tile score. Four agents each did a share. Each measured its share against unrounded neighbours. Combined, the layers lift each other well past any one share's numbers.

Results (tier 1, exact f32 matches)

field before after
aux / moisture (of 61) 51 / 35 61 / 61
the four crack fields (of 61) 55 / 51 / 34 / 37 61 each
elev and elevation (of 434) 171 423
temperature (of 434) 252 429
cliff tile-channel elevation (of 12,675) 786 12,675
startingCircle / ashlandsStart (of 410) 247 / 61 410 / 410
mountain_volcano_spots (of 434) 359 434
the four favorabilities and sulfuric acid patches (of 1,085) 989 to 1,004, and 867 1,085 each
tungsten / coal / calcite / sulfuric acid regions 1033 / 1026 / 999 / 1020 1059 / 1043 / 1028 / 1039
rocks huge / big / density (of 434) 178 / 205 / 412 303 / 297 / 421

No Vulcanus count is below its value on main. In the last-pixel tests, volcanic-cracks now wins as it does in the game, and its point-kernel score equals the game's to the ULP (it was 60,387 low).

How it came together

  • The rock gain was mostly order, not rounding. The Lua adds each rock's -1.2 or -1.0 first, then the noise terms. The port summed the noise terms first.
  • The volcano cone in the spawn layer now uses the game's arithmetic: an f32 distance, the game's pi of 3.1416, and the peak rounded once. That alone took mountain_volcano_spots from 380 to 434.
  • The tile scores use range_select_base, a Lua function, not the expression_in_range builtin. So Nauvis terrain matches the game on every pixel: expression_in_range's real form (#521) #523's center form does not apply to Vulcanus tiles.
  • Merging: the four branches conflicted only on frozen counts in fixtures.rs. Those were measured again on the combined tree in one pass, and one commit re-freezes them with the combined numbers.

What is still short

  • One sine is one f32 step off. The basalts bearing is -239.8965 degrees. The correctly rounded sine is 0.86512095, and the game's is 0.86512089. As an experiment, nudging that one value took startingArea to 410 of 410 and all eight biome fields to 434. It is not committed. Trig crosses into the engine as values computed in V8 (The un-narrowed slider_rescale diverges between the wasm libm and V8 at 1 of 600 positions #270), so the fix belongs in AngleTrig::from_degrees and trigOf in src/noise/wasm/request.ts. It needs its own issue.
  • The remaining elevation and temperature misses read a fractional volcano-spot or biome weight, which is downstream of that sine.
  • Starting coal (974) and starting calcite (969) did not move.

Checks

  • cargo test -p fmw-noise --lib: 538 passed. scripts/verify-rust.sh: passed.
  • engine.wasm rebuilt. Tier 2: 310 Vulcanus rows re-recorded. Tier 3: four Vulcanus render rows. No other planet moved.
  • test/wasmVulcanusRenderParity.spec.ts: DIFFERING_PX 1 -> 0. The control with the ore levers at their defaults moved 10,605 -> 10,636; it only has to stay far from the real count.
  • Full pnpm vp test: green. pnpm vp check: clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC

@coderabbitai

coderabbitai Bot commented Nov 25, 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 23 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: cf675c28-dc8f-4be2-955a-a5e27fcc45c0
Commits

Reviewing files that changed from the base of the PR and between 52f3a76 and 4d3996a.

Files ignored due to path filters: 1

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

  • crates/fmw-noise/src/cliffs/vulcanus_fields.rs
  • crates/fmw-noise/src/expressions/vulcanus_biomes.rs
  • crates/fmw-noise/src/expressions/vulcanus_climate.rs
  • crates/fmw-noise/src/expressions/vulcanus_cracks.rs
  • crates/fmw-noise/src/expressions/vulcanus_elevation.rs
  • crates/fmw-noise/src/expressions/vulcanus_helpers.rs
  • crates/fmw-noise/src/expressions/vulcanus_resources.rs
  • crates/fmw-noise/src/expressions/vulcanus_spawn.rs
  • crates/fmw-noise/src/fixtures.rs
  • crates/fmw-noise/src/resources/vulcanus_catalog.rs
  • crates/fmw-noise/src/rocks/vulcanus_field.rs
  • crates/fmw-noise/src/tiles/vulcanus_catalog.rs
  • test/fixtures/tier2-checksums.json
  • test/fixtures/tier3-render-checksums.json
  • test/wasmVulcanusRenderParity.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 25, 2026

Copy link
Copy Markdown

Code review

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

wormeyman and others added 12 commits November 25, 2026 07:37
vulcanus_plasma's abs(A - B) is now one f32 subtraction of its two
basis_noise values. vulcanus_threshold and vulcanus_contrast round each
step in the Lua's order (1 - threshold, the subtraction, 1 / threshold,
the product; the f32 knee and the f32 subtraction), with their arguments
narrowed first. The unit tests that bounded these by 1e-12 use 1e-6, since
the functions are f32 now.

Tier 1 (counts only; the fixtures.rs comments are updated in the last
commit of the series): floodCracksA 55 -> 56, floodCracksB 51 -> 52,
floodPaths 34 -> 41, floodBasaltsFunc 37 -> 39, climate aux 51 -> 52 and
moisture 35 -> 36, elev and elevation 171 -> 180, temperature 252 -> 251,
rock_huge 178 -> 180, rock_big 205 -> 203, tile-channel elevation 786 ->
813. The helper fixture (38 of 38 on all three) does not move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
The lerps are lerp_f32, 0.2, 0.4, 0.125, 0.3 are narrowed before use,
and each subtraction, sum and product is rounded in the Lua's order
(flood_cracks_b's min - 0.5, flood_paths' 0.4 - plasma before the detail
term, flood_basalts_func's final sum).

Tier 1 (cumulative with the helpers commit; fixtures.rs comments are
updated in the last commit of the series): all five crack fields reach
61 of 61 (was 61, 55, 51, 34, 37). The fields that read them move too:
elev and elevation 171 -> 213, temperature 252 -> 253, tile-channel
elevation 786 -> 996, climate moisture 35 -> 37 (aux stays 51, it was 52
after the helpers commit), rock_huge 178 -> 179, rock_big 205 -> 199,
rock density 412 -> 411.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
mountain_elevation (lerp_f32, 0.7 and the flattening factor),
volcano_inverted_peak, vulcanus_mountains_func (700 and 200 products,
(aux - 0.5) and (spots + 0.5) before they meet), vulcanus_ashlands_func
(the 1 / 50 / 3 input scale as two f32 divisions, 0.001 narrowed),
vulcanus_basalt_lakes, the two outer lerps, 120 *, 20 + * 1.5, and
vulcanus_temperature all go through f32r one step at a time in the Lua's
order. volcano_spots, aux and the biome weights are narrowed on entry:
they are f32 fields in the game.

Tier 1: elev and elevation 213 -> 327 of 434 (171 at the start of the
series; unsnapped 169 -> 321), temperature 253 -> 355 of 434 (252 at the
start; unsnapped 244 -> 346), tile-channel elevation 996 -> 1,392 of
12,675, corners where the two grids differ 2,346 -> 2,649. The 107
positions still short all read a fractional biome or volcano-spot input,
which the spawn and biome layers own. The last-pixel diagnostics move
(19,197 -> 19,200 ULPs; -60,441/784 -> -60,544/884). fixtures.rs comments
now carry the whole series' before -> after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
aux and moisture now round each subtraction and product, and the
literals 0.3, 0.6 and 0.2, to f32 in the Lua's order.

Tier 1: aux 51 -> 56 of 61, moisture 35 -> 60 of 61. Downstream counts
moved because their own glue is still f64: elev and elevation 171 ->
169, temperature 252 -> 250, tile-channel elevation 786 -> 784,
rock_big 205 -> 214, rock_huge 178 -> 174, density 412 -> 411.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
Spawn: the starting-area radius is folded then rounded to f32 before any
product reads it, the wobble sums and distortion products and
starting_circle round per step. Biomes: volcanism, the starting weights,
every lerp and *_full subtraction, the volcano query position (walked one
add at a time) and distortion round per step, and the volcano cone uses
the game's own arithmetic (f32 distance, the double 3.1416, peak in f64).

Tier 1 (spawn, of 410): startingArea 371 -> 392, startingCircle 247 ->
410, ashlandsStart 61 -> 410.
Tier 1 (biomes, of 434): mountain_volcano_spots 359 -> 434, mountains_raw
174 -> 343, mountains_full 135 -> 354, ashlands_full 114 -> 365,
basalts_full 134 -> 343, mountains_biome 404 -> 428, ashlands_biome 404 ->
429, basalts_biome 408 -> 426.
Downstream: elev 169 -> 203, temperature 250 -> 278, tile-channel
elevation 784 -> 5311 of 12675, resource favorabilities and regions up
9 to 54 each, rock_huge 174 -> 175, rock_big 214 -> 218, density 411 ->
415. The last Vulcanus pixel now picks the game's tile.

One test is left red on purpose: the_shared_spot_query_is_the_vulcanus_
one_bit_for_bit in vulcanus_resources.rs, whose frozen fold depends on
this layer. New value 0x37cd_8605_5f45_a0ef; that file is another worker's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
vulcanus_rock_huge and vulcanus_rock_big now evaluate one f32 operation
per step. The game reads `-1.2 + 1.2 * min(..) + rock_noise + 0.5 * knockout`
left to right, so each rock adds its own offset before the noise terms;
the port had summed the three shared terms first and added the offset last.
The caps `0.2 * (1 - k * ashlands)` and every literal are narrowed too.

Tier 1 (434 positions): rock_huge 178 -> 287, rock_big 205 -> 284,
density 412 -> 417. The knockout stays 434. The remainder is upstream
(climate, biomes, rock_noise).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
`0.025 * ((patchy > 0) + 2 * patchy)` now narrows 0.025, the product
and the sum as the game does. Ungraded: no tier-1 count moves (the geyser
peak at the measured argmax shifts by 2.7e-9, a half f32 step, and its
unit test is updated to match).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
`clamp(0.5 * log2(r) + noise, 0, 1) + 0.5` now rounds each step as the
game does. Ungraded: cliffiness was already 12,675 of 12,675 exact and
stays there, and the cliff placement counts do not move. Kept because it
matches the Lua. cliff_elevation is the planet elevation, which another
worker owns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
Every arithmetic step of the resource layer is one f32 operation in the
Lua's order: the resource wobble, the four favorabilities (0.01, 0.78,
the buffers and the contrast narrowed, and the upstream biome_full
rounded on the way in), ore_dist, the size expression, spot density,
quantity and the `> 0.9` favorability, the cone distortion weights, the
two spot-placer caps, `1 - starting_circle`, the sulfur patches and the
patchy region. metal_tile now uses the same f32 `ore_probability` chain
as the overlay (rp still approximated as 1).

Tier 1 (1,085 positions), before -> after: basalts favorability 994 ->
1029, mountains 1004 -> 1016, mountains sulfur 989 -> 1007, ashlands 997
-> 1036, starting tungsten 1082 -> 1085, starting sulfur 1049 -> 1050,
tungsten region 1033 -> 1036, coal 1026 -> 1030, calcite 999 -> 1000,
sulfuric acid region 1020 -> 1022, patches 867 -> 1085, patchy 1020 ->
1025. Starting coal, starting calcite and metalTile do not move.

The spot-query fold in the unit tests is re-frozen on purpose. No tile,
cliff or rock count moves from this module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
All 19 tile ranges from tiles-vulcanus.lua, plus mountain_lava_spots,
now evaluate one f32 operation at a time in the Lua's order, with each
non-exact literal (0.05, 0.3, 0.15, 0.85, 0.35, 0.2, 0.8, 0.25, 0.6,
0.66, 0.01, 0.1, 1.95, 0.95, 0.4, 1.8) narrowed first. Each range's
final sum is rounded too. A private range_select_base_f32 holds the
f32 form of clamp(min(input - from, to - input) / slope, lo, hi); the
shared f64 helper is left alone. Vulcanus tile ranges use no
expression_in_range builtin, so the center/half-width form (#523) does
not apply.

Tier 1: tile argmax 374/381, saves-surface-seed 368/381 and lava
classification 49/49 with 0 mismatches do not move. The last-pixel
argmax gap moves 19,301 -> 19,300 ULPs. On the point kernel warm stays
exact to the game and cracks moves -60,387 -> -60,388 ULPs (grid shift
627 -> 628). The 60k cracks gap is not step rounding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
Each Vulcanus worker measured its own layer against unrounded neighbours.
Combined, the layers lift each other well past any single branch's numbers.
Before #521 -> now:

- climate: aux 51 -> 61 of 61, moisture 35 -> 61 of 61
- elevation surface: elev and elevation 171 -> 423 of 434 (unsnapped
  169 -> 405); temperature 252 -> 429 (unsnapped 244 -> 411)
- cliff tile-channel elevation: 786 -> 12,675 of 12,675
- resources (of 1,085): the four favorabilities and sulfuric acid patches
  all reach 1,085; tungsten region 1033 -> 1059, coal 1026 -> 1043,
  calcite 999 -> 1028, sulfuric acid region 1020 -> 1039, patchy
  1020 -> 1040
- rocks: huge 178 -> 303, big 205 -> 297, density 412 -> 421 of 434
- the last Vulcanus pixel: the game's tile (volcanic-cracks) now wins, and
  its point-kernel score equals the game's to the ULP (was 60,387 low)

No Vulcanus count is below its value on main. The shared spot query's
frozen fold is re-frozen to the combined value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
…me (#521)

The Vulcanus terrain render now matches the game's own terrain-only preview
on every pixel: 0 differ, down from 1. The last pixel was a volcanic-cracks
against volcanic-cracks-warm swap, and the combined rounding put the game's
tile first.

- tier 2: 310 Vulcanus rows moved, all in the layers this branch rounds
  (climate, cracks, spawn, biomes, elevation, temperature, resources,
  rocks, cliffs and every tile score). No other planet moved, and no key
  was added or removed.
- tier 3: four Vulcanus render rows moved (terrain, cliffs, rocks and
  resources).
- The control that leaves the ore levers at their defaults moved
  10,605 -> 10,636; it only has to stay far from the real count.

The full vitest suite passes after the re-record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
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