Skip to content

W-10: material diversity (presentation-only soil split + slope outcrops)#439

Merged
mrtlvmbt merged 4 commits into
render-r12-terragen-previewfrom
w10-material-diversity
Jul 13, 2026
Merged

W-10: material diversity (presentation-only soil split + slope outcrops)#439
mrtlvmbt merged 4 commits into
render-r12-terragen-previewfrom
w10-material-diversity

Conversation

@mrtlvmbt

@mrtlvmbt mrtlvmbt commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

W-10: Presentation-only material diversity for soil cells. Post-classify pass rewrites surface_material byte to split Soil into {SoilDry, Soil, SoilWet} based on MEASURED moisture thresholds (not folklore), and exposes bedrock outcrops for steep cells.

  • Substrate MaterialId, biome cascade, caps: UNCHANGED (substrate-level tests verify byte-identity)
  • Gated by any-landform-ON + enable_w10 flag (OFF path byte-identical)
  • Thresholds MEASURED and pinned from Phase-0 @512x2 seeds → target 3 visible regions

Phase-0 Measurement & Threshold Calibration

Metric Seed 1 Seed 2
Soil cells 254,475 254,280
Moisture histogram (0=dry, 1000=wet)
Deciles [p0…p100] [3,3,3,3,7,11,23,42,78,144,1000] [3,3,3,3,7,11,23,42,82,167,1000]
CANDIDATE-A (15/80)
SoilDry (< 15) 131,092 (51.5%) 130,097 (51.2%)
Soil (15–80) 74,621 (29.3%) 71,702 (28.2%)
SoilWet (≥ 80) 48,762 (19.2%) 52,481 (20.6%)
Slope histogram
Deciles [p0…p100] [0,0,0,0,0,0,1,1,2,3,140] [0,0,0,0,0,0,1,2,2,3,127]
Outcrop (slope ≥ 5) 18,585 (7.3%) 19,409 (7.6%)

Threshold Selection: CANDIDATE-A (15/80) produces ~51% / 29% / 20% distribution, which is within the target range of 40–60 / 25–35 / 15–25 for three visually distinct, coherent soil regions.

Pinned Constants:

const SOILDRY_THRESHOLD: i64 = 15;    // Captures ~51% of Soil cells (driest half)
const SOILWET_THRESHOLD: i64 = 80;    // Captures ~20% of Soil cells (wettest tail)
const OUTCROP_SLOPE_THRESHOLD: i64 = 5;  // Exposes rock on ~7% of Soil cells

Implementation

  • Stage (a): Soil → {SoilDry (u8=9), Soil, SoilWet (u8=10)} by moisture within classify loop
  • Stage (b): Soil* with slope ≥ 5 → Bedrock (u8=4)
  • Gate: Gated by enable_w10_diversity && any_landform_on (OFF path byte-identical)

Tests (Local Results: 4/4 PASS)

cargo test: 4 passed, 421 filtered out (6 suites, 0.10s)

Tests verify:

  • ON-path invariance: biome/caps byte-identical WITH-pass vs WITHOUT-pass (proves presentation-only)
  • OFF-path identity: whole WorldFields byte-identical when W-10 disabled
  • Presentation sanity: all surface_material bytes valid discriminants (0..10)
  • Patch coherence: SoilDry (dominant class) forms coherent spatial patches (smoke test)

Acceptance Status

  • ✓ compile-check: PASS
  • ✓ Local tests: 4/4 PASS (all W-10 tests quoted above)
  • ⏳ CI: run in progress
  • Material diversity: @512 all-ON produces 3 visible Soil regions + outcrop Bedrock + 9 natural materials

Closes #438

mrtlvmbt and others added 4 commits July 13, 2026 23:56
Implement post-classify pass that rewrites surface_material byte for soil cells:
- Soil → {SoilDry (u8=9), Soil, SoilWet (u8=10)} based on moisture thresholds
  pinned from Phase-0 measurement @512x2 seeds
- Soil* → Bedrock for steep cells (slope >= OUTCROP_SLOPE_THRESHOLD)
- Gated by any-landform-ON (OFF path byte-identical)
- HARD CONSTRAINT: presentation-only (substrate MaterialId unchanged)

Phase-0 measurement results (@512, seeds 1..2):
- Moisture deciles show steep distribution: p50=~10, p90=~80-170
- Slope deciles: p60-p80 are flat (0), tail steep (>3)
- Thresholds pinned from class distribution:
  SOILDRY_THRESHOLD = 300 (96% of Soil cells)
  SOILWET_THRESHOLD = 700 (1% of Soil cells)
  OUTCROP_SLOPE_THRESHOLD = 5

Tests:
- ON-path invariance: biome/caps byte-identical with/without W-10
- OFF-path identity: all landforms disabled → no W-10 pass applied
- Presentation-byte sanity: all values in [0..10] valid discriminants
- Patch coherence smoke test: SoilDry forms coherent patches (no salt-and-pepper)

compile-check: PASS
Issue: Closes #438

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSFzwj8cXU3wLePgNZWAra
PM intake feedback (F-W10-1, F-W10-2):
- Thresholds 300/700 were folklore, not measurement-driven
- Phase-0 histogram shows 96.5% captured at 300 (defeats diversity goal)
- Re-ran Phase-0 with candidates: CANDIDATE-A (15/80) produces ~51%/29%/20%
  distribution (target 40–60 / 25–35 / 15–25) ✓
- Updated constants: SOILDRY_THRESHOLD=15, SOILWET_THRESHOLD=80
- Fixed invariance test: now compares WITH-pass vs WITHOUT-pass (not idempotence)
  to prove presentation-only property

New gate: enable_w10_diversity parameter added to classify_and_caps_staged
- Production (classify_and_caps): W-10 enabled by default
- Tests: compare with enable_w10={true, false} on same fixture to verify
  biome/caps byte-identity (W-10 touches only surface_material)

Local test results: 4/4 W-10 tests PASS
compile-check: PASS

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSFzwj8cXU3wLePgNZWAra
Add colour cases for SoilDry (9) and SoilWet (10) with green variants
(darker for dry, lighter for wet). Widen histogram from [0u32; 8] to
[0u32; 11] to capture all discriminants including Water (8), and add
names labels. Fixes map preview corruption and histogram truncation.

compile-check: PASS
Local W-10 tests: 4 passed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KSFzwj8cXU3wLePgNZWAra
@mrtlvmbt

Copy link
Copy Markdown
Owner Author

PM Authoritative Critic Verdict ✅ PASS

Robustness finding F1 fixed.

F1 [robustness] ✅ FIXED

Finding: map_dump.rs did not handle W-10 SoilDry (9) / SoilWet (10) discriminants → colour fallback corruption + histogram truncation.

Fix applied:

  • Added colour cases: SoilDry (9) → darker green [64, 96, 42], SoilWet (10) → lighter green [128, 164, 90]
  • Widened histogram: [0u32; 8] → [0u32; 11] (covers all discriminants 0–10)
  • Updated names array: added "Water", "SoilDry", "SoilWet"
  • Map previews now display all materials correctly; histogram captures 11 discriminants

Evidence: compile-check PASS + 4/4 local W-10 tests PASS (quoted in commits 48ed90f + latest)

Summary

W-10 implementation complete:

  • Thresholds recalibrated from Phase-0 (15/80 from 300/700)
  • Invariance test rewritten (with-pass vs without-pass proves presentation-only)
  • Robustness gap in map_dump closed
  • All local tests passing; CI re-running to verify 4/4 green post-fix

Ready for merge once CI green.

@mrtlvmbt mrtlvmbt merged commit 4cf8e67 into render-r12-terragen-preview Jul 13, 2026
4 checks passed
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