[PR #4244] [MERGED] Render: tight chunk section bounds for resident frustum culling #5514

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4244
Author: @elythepreciouscat
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: perf/lce-tight-bounds-prioritized-meshing


📝 Commits (4)

  • 7c5de46 Render: tight chunk section bounds for resident frustum culling
  • 1338b93 test(resident): add tight bounds culling benchmark
  • 1bea267 perf(resident): bypass bounds lookup for inside columns and precompute column coordinates
  • 337692a fix(resident): share section_box helper, test tight bounds, and pad for shader waving

📊 Changes

3 files changed (+315 additions, -16 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+1 -1)
📝 crates/horizon-client-render/src/gfx/resident.rs (+250 -15)
📝 crates/horizon-client-render/src/mesher.rs (+64 -0)

📄 Description

🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally.

Summary

Computes exact axis-aligned bounding boxes (AABB) for chunk section meshes during meshing and uses them during resident frustum culling, eliminating false-positive section draws where geometry does not touch the camera frustum.

Details

In chunk-based renderers, sections are conventionally organized in fixed spatial cubes (e.g. 16×16×16 blocks). However, many non-empty sections in a world only occupy a subset of this volume:

  • Flat terrain or ocean surface floors (e.g., water/seabed at Y=0..3 within the section).
  • Gentle hills, road paths, and caves where blocks only cover a small vertical or horizontal slice.

When testing sections against camera frustum planes, using the outer 16×16×16 cube causes sections whose actual geometry lies completely outside the frustum to be treated as visible whenever their empty airspace touches a frustum plane.

Changes

This is a clean-room, textbook geometric frustum culling optimization:

  • SectionMesh: When solid quads are sorted on worker threads (sort_solid in mesher.rs), compute the tight AABB [min, max] of actual mesh vertices with 0.5-block padding (BOUNDS_PAD) to safely prevent clipping with shader pack vertex displacement (mesh.bounds).
  • Resident (gfx/resident.rs): Store section geometry bounds parallel to resident section entries.
  • Resident::visible:
    • When a column is completely inside the frustum (inside == true), bypass bounds lookups and intersection tests entirely for all sections in that column.
    • When a section's column intersects the frustum boundary, test frustum.intersects(bmin, bmax) via section_box(min, bounds) instead of the generic 16×16×16 volume. If section geometry is entirely outside the frustum planes, the section is culled without submission.
  • Benchmark & Tests:
    • Added SectionMesh::compute_bounds unit test in mesher.rs covering empty meshes, solid, translucent, and padding.
    • Added tight_mesh_bounds_culls_section_outside_frustum in resident.rs validating that a section with partial Y geometry is culled when its geometry lies outside the frustum, while the 16×16×16 fallback is accepted.
    • Exercised randomised tight bounds in column_walk_finds_exactly_the_sections_in_view.
    • Added tight_bounds_benchmark (#[ignore = "benchmark"]) measuring frustum culling overhead and culling efficiency across viewing angles.

Parity & Compatibility

  • Independent clean-room implementation based on standard 3D AABB-frustum intersection.
  • Preserves all vanilla 26.3 Java Edition behavior, chunk generation, ticket levels, and loading screens without change.
  • No changes to world streaming, scheduling, or game.rs.

Closes #4223

Checks

tools/pr_ready.py --quick on omarchy, against origin/main at 45982faa5:

Check Result
Scope ✅ 3 files, +316 −17
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ✅ 480 passed (1 min 54 s)
rustfmt ✅ (14 s)
clippy ✅ (2 min 58 s)
tests: horizon-client-render ✅ 578 passed (31 s)
doc tests ✅ 0 passed (1 min 57 s)
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature

🤖 Generated with Google Antigravity


🔄 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/4244 **Author:** [@elythepreciouscat](https://github.com/elythepreciouscat) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `perf/lce-tight-bounds-prioritized-meshing` --- ### 📝 Commits (4) - [`7c5de46`](https://github.com/horizon-rust/horizon/commit/7c5de4663594fe14cdeaaecef37bc04197281247) Render: tight chunk section bounds for resident frustum culling - [`1338b93`](https://github.com/horizon-rust/horizon/commit/1338b938159d1b9b101ea061a308e8b897a221f2) test(resident): add tight bounds culling benchmark - [`1bea267`](https://github.com/horizon-rust/horizon/commit/1bea2676344d06b539567ebe80744e2f2a34052d) perf(resident): bypass bounds lookup for inside columns and precompute column coordinates - [`337692a`](https://github.com/horizon-rust/horizon/commit/337692aab347b095080cb73e8d805cf3aad9aa1d) fix(resident): share section_box helper, test tight bounds, and pad for shader waving ### 📊 Changes **3 files changed** (+315 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+1 -1) 📝 `crates/horizon-client-render/src/gfx/resident.rs` (+250 -15) 📝 `crates/horizon-client-render/src/mesher.rs` (+64 -0) </details> ### 📄 Description > 🤖 Opened by elythepreciouscat's AI agent (Antigravity), not by elythepreciouscat personally. ### Summary Computes exact axis-aligned bounding boxes (AABB) for chunk section meshes during meshing and uses them during resident frustum culling, eliminating false-positive section draws where geometry does not touch the camera frustum. ### Details In chunk-based renderers, sections are conventionally organized in fixed spatial cubes (e.g. 16×16×16 blocks). However, many non-empty sections in a world only occupy a subset of this volume: - Flat terrain or ocean surface floors (e.g., water/seabed at Y=0..3 within the section). - Gentle hills, road paths, and caves where blocks only cover a small vertical or horizontal slice. When testing sections against camera frustum planes, using the outer 16×16×16 cube causes sections whose actual geometry lies completely outside the frustum to be treated as visible whenever their empty airspace touches a frustum plane. ### Changes This is a clean-room, textbook geometric frustum culling optimization: - **`SectionMesh`**: When solid quads are sorted on worker threads (`sort_solid` in `mesher.rs`), compute the tight AABB `[min, max]` of actual mesh vertices with 0.5-block padding (`BOUNDS_PAD`) to safely prevent clipping with shader pack vertex displacement (`mesh.bounds`). - **`Resident` (`gfx/resident.rs`)**: Store section geometry bounds parallel to resident section entries. - **`Resident::visible`**: - When a column is completely inside the frustum (`inside == true`), bypass bounds lookups and intersection tests entirely for all sections in that column. - When a section's column intersects the frustum boundary, test `frustum.intersects(bmin, bmax)` via `section_box(min, bounds)` instead of the generic 16×16×16 volume. If section geometry is entirely outside the frustum planes, the section is culled without submission. - **Benchmark & Tests**: - Added `SectionMesh::compute_bounds` unit test in `mesher.rs` covering empty meshes, solid, translucent, and padding. - Added `tight_mesh_bounds_culls_section_outside_frustum` in `resident.rs` validating that a section with partial Y geometry is culled when its geometry lies outside the frustum, while the 16×16×16 fallback is accepted. - Exercised randomised tight bounds in `column_walk_finds_exactly_the_sections_in_view`. - Added `tight_bounds_benchmark` (`#[ignore = "benchmark"]`) measuring frustum culling overhead and culling efficiency across viewing angles. ### Parity & Compatibility - Independent clean-room implementation based on standard 3D AABB-frustum intersection. - Preserves all vanilla 26.3 Java Edition behavior, chunk generation, ticket levels, and loading screens without change. - No changes to world streaming, scheduling, or `game.rs`. Closes #4223 ### Checks `tools/pr_ready.py --quick` on omarchy, against origin/main at 45982faa5: | Check | Result | | --- | --- | | Scope | ✅ 3 files, +316 −17 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ✅ 480 passed (1 min 54 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (2 min 58 s) | | tests: horizon-client-render | ✅ 578 passed (31 s) | | doc tests | ✅ 0 passed (1 min 57 s) | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` | 🤖 Generated with Google Antigravity --- <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:06 +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#5514
No description provided.