[PR #5926] [MERGED] Graphics: add configurable leaf culling modes #6566

Closed
opened 2026-11-03 06:23:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5926
Author: @elythepreciouscat
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/leaf-culling


📝 Commits (7)

  • 4af3055 Add configurable leaf culling (Hollow, Solid, SolidAggressive)
  • 4ca4473 Merge origin/main into feat/leaf-culling
  • 81862bb Merge origin/main into feat/leaf-culling; add benchmark screenshots
  • 2a9a6c1 Graphics: capture leaf culling modes
  • 5c8a415 Merge remote-tracking branch 'origin/main' into feat/leaf-culling
  • cf2c59e Leaf culling: account for active server packs
  • d662711 Merge branch 'main' into feat/leaf-culling

📊 Changes

22 files changed (+1371 additions, -22 deletions)

View changed files

📝 crates/horizon-client-render/src/graphics.rs (+190 -2)
📝 crates/horizon-client-render/src/graphics_ui.rs (+103 -4)
📝 crates/horizon-client-render/src/mesher.rs (+53 -8)
➕ crates/horizon-client-render/src/mesher/leaf_culling.rs (+656 -0)
➕ crates/horizon-client-render/src/mesher/leaf_culling_tests.rs (+293 -0)
📝 crates/horizon-client-render/src/mesher/reuse_tests.rs (+2 -0)
📝 crates/horizon-client-render/src/mesher/visibility_tests.rs (+1 -0)
📝 crates/horizon-client-render/src/streaming.rs (+7 -0)
📝 crates/horizon-client/examples/chunk_load_bench.rs (+2 -0)
📝 crates/horizon-client/examples/probe/section_mesh_fixture.rs (+2 -0)
📝 crates/horizon-client/src/game.rs (+15 -4)
📝 crates/horizon-client/src/game/entity_culling.rs (+1 -1)
📝 crates/horizon-client/src/game/packs.rs (+20 -0)
📝 crates/horizon-client/src/game/world_loading.rs (+3 -0)
📝 crates/horizon-client/tests/streaming_meshes.rs (+2 -0)
📝 crates/horizon-client/tests/tall_column.rs (+2 -0)
📝 docs/graphics.md (+14 -3)
➕ docs/media/leaf-culling-hollow.png (+0 -0)
➕ docs/media/leaf-culling-off.png (+0 -0)
➕ docs/media/leaf-culling-solid.png (+0 -0)

...and 2 more files

📄 Description

🤖 Opened by elythepreciouscat's AI agent (Codex, GPT-6), not by elythepreciouscat personally.

What and why

Add an opt-in Leaf Culling control under Advanced Graphics → Culling for dense canopies. It is off by default, so the default leaf mesh stays the vanilla 26.3 path. The other modes trade some visual differences for less cutout work or fewer internal faces. A resource pack that can replace vanilla block models forces the effective mode back to Off.

The worker builds a conservative leaf/opaque/open/unknown mask from its padded section snapshot. It classifies leaf interiors while meshing, so there is no per-frame or render-thread culling pass. Unknown data, section boundaries, column edges, cavities and partial models remain conservative.

  • Off: keep every leaf quad and render as vanilla fancy leaves.
  • Solid: leaves surrounded on all six sides by leaves or full opaque cubes use the opaque layer. The quad count and silhouette stay the same, but the layers behind interior leaves no longer show through.
  • Solid Aggressive: also makes a leaf opaque when it has exactly one open side, thinning the cutout shell by one layer.
  • Hollow: remove a quad only when its neighbor is a known leaf in the same section. Faces toward openings, cavities, partial blocks, unknown data and section boundaries remain.

This complements the front-to-back terrain ordering work discussed in #5322: ordering can reduce fragment work for quads that remain, while these modes can reclassify or remove interior leaf work. The earlier 1×1-to-2×1 greedy-merge prototype was discarded: it changed quad topology, created T-junction risks at adjacent unmerged faces, and could change AO/tint interpolation and tiled-UV mip behavior. It also failed the section-mesh parity checks, so it was removed instead of weakening the vanilla default.

Fixes #5924

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • feature: something new for players
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only setting. Off is the default and retains the existing vanilla leaf mesh; the opt-in modes intentionally change how canopy interiors are rendered. The section-mesh parity harness exercises the Off path. No vanilla classes or methods are added.

Other projects' code

No external source code was copied.

Self-check

The author-provided pr_ready --quick result was run on omarchy against origin/main at 521614fc7 and took 61 min 19 s.

Check Result
Scope ⚠️ 18 files, +1,314/−22; 1,310 lines of code, over 500 (split if it can ship in parts)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (53 s)
rustfmt ✅ (14 s)
clippy ✅ (3 min 52 s)
horizon-client, horizon-client-render tests ✅ 2,479 passed (55 min 46 s)
doc tests ✅ 0 passed (25 s)
content root tests ➖ content root untouched
tokens.css ➖ theme untouched
launcher rustfmt, clippy, tests ➖ launcher untouched
Parity ➖ 357 affected harnesses deferred by --quick: active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 345 more
Label player-facing feature

The four modes share one worker-side mask and setting, so they are kept as a single feature. After the reported check, the branch merged origin/main at c1f4a7c and added the screenshots below. The current head built successfully with cargo build --profile fast -p horizon-client for the live benchmark; the full quick suite was not rerun after that merge.

Live benchmark

Ran the current branch through horizon-ctl on the same saved, fixed-seed world for all modes: 1,568 persistent oak leaves in a 14×8×14 volume, render distance 2, camera at (8, 104, 18) facing the canopy. Each mode had a 5-second warm-up and three 10-second samples. VSync was off and presentation was Immediate. The table shows the median FPS and median CPU average from the three samples; mesh bytes are the renderer's total resident terrain vertex bytes, not leaf-only bytes.

Hardware: Intel HD Graphics 4000 (IVB GT2), Vulkan, Mesa 26.2.4.

Mode Median FPS Change vs Off CPU avg (ms) Resident terrain vertex bytes
Off 124.5 baseline 1.93 9,082,560
Solid 131.8 +5.9% 1.85 9,082,656
Solid Aggressive 141.1 +13.4% 1.80 9,082,560
Hollow 185.7 +49.2% 1.70 7,748,544

Hollow reduced total resident terrain vertex bytes by 14.7% in this scene. The two Solid modes keep the geometry and gain throughput by making enclosed leaf faces opaque. This is one dense-canopy scene on one integrated GPU, not a general FPS guarantee. The Ivy Bridge Mesa driver does not provide usable timestamp queries here, so the GPU-time fields are zero and are not reported as measurements.

Screenshots

Same saved scene and camera in each mode; the FPS overlay is the live value at capture time, not the three-sample median above.

Off Solid
Leaf culling Off Leaf culling Solid
Solid Aggressive Hollow
Leaf culling Solid Aggressive Leaf culling Hollow

🤖 Generated with Codex


🔄 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/5926 **Author:** [@elythepreciouscat](https://github.com/elythepreciouscat) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/leaf-culling` --- ### 📝 Commits (7) - [`4af3055`](https://github.com/horizon-rust/horizon/commit/4af30557424f43d215fa71364277ca7197ea9c99) Add configurable leaf culling (Hollow, Solid, SolidAggressive) - [`4ca4473`](https://github.com/horizon-rust/horizon/commit/4ca447371bfa2cd80dcc46a0e2f9e252053e9b40) Merge origin/main into feat/leaf-culling - [`81862bb`](https://github.com/horizon-rust/horizon/commit/81862bbc39ccecee145ec4d2bad6faa06e1b1594) Merge origin/main into feat/leaf-culling; add benchmark screenshots - [`2a9a6c1`](https://github.com/horizon-rust/horizon/commit/2a9a6c1e6656b8253d81a778369008380e2de6c1) Graphics: capture leaf culling modes - [`5c8a415`](https://github.com/horizon-rust/horizon/commit/5c8a4156ffff8a9eb81a6d76ded268ab7398e516) Merge remote-tracking branch 'origin/main' into feat/leaf-culling - [`cf2c59e`](https://github.com/horizon-rust/horizon/commit/cf2c59e1bd1835cee0d3bafeaa11cae7d5796453) Leaf culling: account for active server packs - [`d662711`](https://github.com/horizon-rust/horizon/commit/d66271131c0f5e4f522ea72af323d832a46b2e4c) Merge branch 'main' into feat/leaf-culling ### 📊 Changes **22 files changed** (+1371 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/graphics.rs` (+190 -2) 📝 `crates/horizon-client-render/src/graphics_ui.rs` (+103 -4) 📝 `crates/horizon-client-render/src/mesher.rs` (+53 -8) ➕ `crates/horizon-client-render/src/mesher/leaf_culling.rs` (+656 -0) ➕ `crates/horizon-client-render/src/mesher/leaf_culling_tests.rs` (+293 -0) 📝 `crates/horizon-client-render/src/mesher/reuse_tests.rs` (+2 -0) 📝 `crates/horizon-client-render/src/mesher/visibility_tests.rs` (+1 -0) 📝 `crates/horizon-client-render/src/streaming.rs` (+7 -0) 📝 `crates/horizon-client/examples/chunk_load_bench.rs` (+2 -0) 📝 `crates/horizon-client/examples/probe/section_mesh_fixture.rs` (+2 -0) 📝 `crates/horizon-client/src/game.rs` (+15 -4) 📝 `crates/horizon-client/src/game/entity_culling.rs` (+1 -1) 📝 `crates/horizon-client/src/game/packs.rs` (+20 -0) 📝 `crates/horizon-client/src/game/world_loading.rs` (+3 -0) 📝 `crates/horizon-client/tests/streaming_meshes.rs` (+2 -0) 📝 `crates/horizon-client/tests/tall_column.rs` (+2 -0) 📝 `docs/graphics.md` (+14 -3) ➕ `docs/media/leaf-culling-hollow.png` (+0 -0) ➕ `docs/media/leaf-culling-off.png` (+0 -0) ➕ `docs/media/leaf-culling-solid.png` (+0 -0) _...and 2 more files_ </details> ### 📄 Description > 🤖 Opened by elythepreciouscat's AI agent (Codex, GPT-6), not by elythepreciouscat personally. ## What and why Add an opt-in Leaf Culling control under Advanced Graphics → Culling for dense canopies. It is off by default, so the default leaf mesh stays the vanilla 26.3 path. The other modes trade some visual differences for less cutout work or fewer internal faces. A resource pack that can replace vanilla block models forces the effective mode back to Off. The worker builds a conservative leaf/opaque/open/unknown mask from its padded section snapshot. It classifies leaf interiors while meshing, so there is no per-frame or render-thread culling pass. Unknown data, section boundaries, column edges, cavities and partial models remain conservative. - **Off:** keep every leaf quad and render as vanilla fancy leaves. - **Solid:** leaves surrounded on all six sides by leaves or full opaque cubes use the opaque layer. The quad count and silhouette stay the same, but the layers behind interior leaves no longer show through. - **Solid Aggressive:** also makes a leaf opaque when it has exactly one open side, thinning the cutout shell by one layer. - **Hollow:** remove a quad only when its neighbor is a known leaf in the same section. Faces toward openings, cavities, partial blocks, unknown data and section boundaries remain. This complements the front-to-back terrain ordering work discussed in #5322: ordering can reduce fragment work for quads that remain, while these modes can reclassify or remove interior leaf work. The earlier 1×1-to-2×1 greedy-merge prototype was discarded: it changed quad topology, created T-junction risks at adjacent unmerged faces, and could change AO/tint interpolation and tiled-UV mip behavior. It also failed the section-mesh parity checks, so it was removed instead of weakening the vanilla default. Fixes #5924 ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [x] feature: something new for players - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only setting. Off is the default and retains the existing vanilla leaf mesh; the opt-in modes intentionally change how canopy interiors are rendered. The section-mesh parity harness exercises the Off path. No vanilla classes or methods are added. ## Other projects' code No external source code was copied. ## Self-check The author-provided pr_ready --quick result was run on omarchy against origin/main at 521614fc7 and took 61 min 19 s. | Check | Result | | --- | --- | | Scope | ⚠️ 18 files, +1,314/−22; 1,310 lines of code, over 500 (split if it can ship in parts) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (53 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (3 min 52 s) | | horizon-client, horizon-client-render tests | ✅ 2,479 passed (55 min 46 s) | | doc tests | ✅ 0 passed (25 s) | | content root tests | ➖ content root untouched | | tokens.css | ➖ theme untouched | | launcher rustfmt, clippy, tests | ➖ launcher untouched | | Parity | ➖ 357 affected harnesses deferred by --quick: active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 345 more | | Label | player-facing feature | The four modes share one worker-side mask and setting, so they are kept as a single feature. After the reported check, the branch merged origin/main at c1f4a7c and added the screenshots below. The current head built successfully with cargo build --profile fast -p horizon-client for the live benchmark; the full quick suite was not rerun after that merge. ## Live benchmark Ran the current branch through horizon-ctl on the same saved, fixed-seed world for all modes: 1,568 persistent oak leaves in a 14×8×14 volume, render distance 2, camera at (8, 104, 18) facing the canopy. Each mode had a 5-second warm-up and three 10-second samples. VSync was off and presentation was Immediate. The table shows the median FPS and median CPU average from the three samples; mesh bytes are the renderer's total resident terrain vertex bytes, not leaf-only bytes. Hardware: Intel HD Graphics 4000 (IVB GT2), Vulkan, Mesa 26.2.4. | Mode | Median FPS | Change vs Off | CPU avg (ms) | Resident terrain vertex bytes | | --- | ---: | ---: | ---: | ---: | | Off | 124.5 | baseline | 1.93 | 9,082,560 | | Solid | 131.8 | +5.9% | 1.85 | 9,082,656 | | Solid Aggressive | 141.1 | +13.4% | 1.80 | 9,082,560 | | Hollow | 185.7 | +49.2% | 1.70 | 7,748,544 | Hollow reduced total resident terrain vertex bytes by 14.7% in this scene. The two Solid modes keep the geometry and gain throughput by making enclosed leaf faces opaque. This is one dense-canopy scene on one integrated GPU, not a general FPS guarantee. The Ivy Bridge Mesa driver does not provide usable timestamp queries here, so the GPU-time fields are zero and are not reported as measurements. ## Screenshots Same saved scene and camera in each mode; the FPS overlay is the live value at capture time, not the three-sample median above. | Off | Solid | | --- | --- | | ![Leaf culling Off](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/leaf-culling/docs/media/leaf-culling-off.png) | ![Leaf culling Solid](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/leaf-culling/docs/media/leaf-culling-solid.png) | | Solid Aggressive | Hollow | | --- | --- | | ![Leaf culling Solid Aggressive](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/leaf-culling/docs/media/leaf-culling-solid_aggressive.png) | ![Leaf culling Hollow](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/leaf-culling/docs/media/leaf-culling-hollow.png) | 🤖 Generated with [Codex](https://openai.com/codex) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:23:09 +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#6566
No description provided.