[PR #4256] [CLOSED] Terrain: greedy-merge exposed faces of plain cubes in section meshes #5521

Closed
opened 2026-11-03 05:13:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4256
Author: @levzzz5154
Created: 10/30/2026
Status: ❌ Closed

Base: main ← Head: perf/greedy-section-meshing


📝 Commits (1)

  • 75339c4 Terrain: greedy-merge exposed faces of plain cubes in section meshes

📊 Changes

9 files changed (+423 additions, -34 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/native_material.rs (+3 -3)
📝 crates/horizon-client-render/src/gfx/pack_atlas.rs (+1 -1)
📝 crates/horizon-client-render/src/mesher.rs (+386 -21)
📝 crates/horizon-client-render/src/streaming.rs (+6 -0)
📝 crates/horizon-client-render/src/terrain.wgsl (+8 -6)
📝 crates/horizon-client/examples/chunk_load_bench.rs (+1 -0)
📝 crates/horizon-client/examples/probe/section_mesh_fixture.rs (+2 -0)
📝 crates/horizon-client/src/game/shader_packs.rs (+15 -3)
📝 crates/horizon-client/tests/streaming_meshes.rs (+1 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 themselves. The code is googte344's, from googte344/enhanced-rendering, and the commit credits them as author.

Draft: the measured gain is small (below). Open so the maintainer can decide whether it's worth the extra mesher path.

What

The section mesher merges coplanar exposed faces of plain cubes into larger quads, as far terrain already does:

  • Only blocks whose single model passes models::cube_styles qualify: opaque, untinted, non-emissive full-texture unit cubes with no random offset. Slabs, stairs, plants, fluids, cutout and translucent blocks keep the normal path.
  • Faces merge only when sprite, UV transform, colour and light all match and the four corners are uniform, so no AO, light, tint or texture boundary is lost.
  • Merged quads set mesher::TILED_UV_LAYER (layer bit 14) and use the far-terrain UV scale, so the sprite repeats once per block. terrain.wgsl and the native material shaders decode it. Bit 14 is free: the sprite arrays hold 8 × 2048 = 16,384 layers.
  • Third-party shader packs expect one sprite per quad, so merging is off while one is picked, and sections remesh when that changes. The section_mesh parity probe keeps it off, so it still compares vanilla's per-face quads.

Measurements

chunk_load_bench --radius 6 --rounds 3 (2,328 sections, same seed), merging on vs off:

vertices mesh CPU
smooth lighting on (default), off 1,429,396 110.0 ms
smooth lighting on (default), on 1,364,064 (−4.6%) 115.9 ms (+5%)
smooth lighting off, off 1,429,396 90.4 ms
smooth lighting off, on 1,192,440 (−16.6%) 123.1 ms (+36%)

With smooth lighting most faces have uneven corner shading, so few merge. GPU frame time was not measured.

Review notes

  • The archive was made from main at 791d8b895 (2026-10-28) and never compiled ("cargo unavailable"). I rebased it onto the horizon-client-render split and added greedy_meshing to every Mesher built outside the game: on in chunk_load_bench and streaming_meshes, off in section_mesh_fixture.
  • I left out the archive's apply_settings hook in game.rs. It duplicated the per-frame check in shader_packs.rs and ignored HORIZON_SHADER_PACK, so the two could fight and remesh repeatedly.
  • The rest of the archive is not here: a "Hydrogen" renderer option that only changes the depth test on Metal, an occlusion-culling threshold applied to every GPU (main measured it for Metal only), a "LOD Billboard Distance" setting that does nothing yet, coloured dynamic lights, audio log messages, a maxperf profile and scripts, and notes at the repo root. The LOD CPU changes are in #4255.

Testing

  • cargo test -p horizon-client-render --lib: 580 passed (including the 4 new greedy_meshing_tests)
  • cargo test -p horizon-client --test streaming_meshes: 2 passed
  • python3 tools/parity.py section_mesh translucency block_tint environment_render light: 5 passed
  • cargo clippy -p horizon-client-render -p horizon-client --all-targets -- -D warnings and cargo fmt --all --check: clean
  • Not run: an in-game visual comparison.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4256 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `perf/greedy-section-meshing` --- ### 📝 Commits (1) - [`75339c4`](https://github.com/horizon-rust/horizon/commit/75339c473ea457fda44048f1579d33a8e4d59e8f) Terrain: greedy-merge exposed faces of plain cubes in section meshes ### 📊 Changes **9 files changed** (+423 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+3 -3) 📝 `crates/horizon-client-render/src/gfx/pack_atlas.rs` (+1 -1) 📝 `crates/horizon-client-render/src/mesher.rs` (+386 -21) 📝 `crates/horizon-client-render/src/streaming.rs` (+6 -0) 📝 `crates/horizon-client-render/src/terrain.wgsl` (+8 -6) 📝 `crates/horizon-client/examples/chunk_load_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/probe/section_mesh_fixture.rs` (+2 -0) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+15 -3) 📝 `crates/horizon-client/tests/streaming_meshes.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 themselves. The code is googte344's, from [googte344/enhanced-rendering](https://github.com/googte344/enhanced-rendering), and the commit credits them as author. **Draft: the measured gain is small (below). Open so the maintainer can decide whether it's worth the extra mesher path.** ## What The section mesher merges coplanar exposed faces of plain cubes into larger quads, as far terrain already does: - Only blocks whose single model passes `models::cube_styles` qualify: opaque, untinted, non-emissive full-texture unit cubes with no random offset. Slabs, stairs, plants, fluids, cutout and translucent blocks keep the normal path. - Faces merge only when sprite, UV transform, colour and light all match and the four corners are uniform, so no AO, light, tint or texture boundary is lost. - Merged quads set `mesher::TILED_UV_LAYER` (layer bit 14) and use the far-terrain UV scale, so the sprite repeats once per block. `terrain.wgsl` and the native material shaders decode it. Bit 14 is free: the sprite arrays hold 8 × 2048 = 16,384 layers. - Third-party shader packs expect one sprite per quad, so merging is off while one is picked, and sections remesh when that changes. The `section_mesh` parity probe keeps it off, so it still compares vanilla's per-face quads. ## Measurements `chunk_load_bench --radius 6 --rounds 3` (2,328 sections, same seed), merging on vs off: | | vertices | mesh CPU | |---|---|---| | smooth lighting on (default), off | 1,429,396 | 110.0 ms | | smooth lighting on (default), on | 1,364,064 (**−4.6%**) | 115.9 ms (+5%) | | smooth lighting off, off | 1,429,396 | 90.4 ms | | smooth lighting off, on | 1,192,440 (**−16.6%**) | 123.1 ms (+36%) | With smooth lighting most faces have uneven corner shading, so few merge. GPU frame time was not measured. ## Review notes - The archive was made from main at 791d8b895 (2026-10-28) and never compiled ("cargo unavailable"). I rebased it onto the `horizon-client-render` split and added `greedy_meshing` to every `Mesher` built outside the game: on in `chunk_load_bench` and `streaming_meshes`, off in `section_mesh_fixture`. - I left out the archive's `apply_settings` hook in `game.rs`. It duplicated the per-frame check in `shader_packs.rs` and ignored `HORIZON_SHADER_PACK`, so the two could fight and remesh repeatedly. - The rest of the archive is not here: a "Hydrogen" renderer option that only changes the depth test on Metal, an occlusion-culling threshold applied to every GPU (main measured it for Metal only), a "LOD Billboard Distance" setting that does nothing yet, coloured dynamic lights, audio log messages, a `maxperf` profile and scripts, and notes at the repo root. The LOD CPU changes are in #4255. ## Testing - `cargo test -p horizon-client-render --lib`: 580 passed (including the 4 new `greedy_meshing_tests`) - `cargo test -p horizon-client --test streaming_meshes`: 2 passed - `python3 tools/parity.py section_mesh translucency block_tint environment_render light`: 5 passed - `cargo clippy -p horizon-client-render -p horizon-client --all-targets -- -D warnings` and `cargo fmt --all --check`: clean - Not run: an in-game visual comparison. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5521
No description provided.