[PR #1290] [MERGED] Java shader packs: occlusion culling while the pack draws the terrain #3480

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1290
Author: @ludovic111
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @ludovic111

Base: main ← Head: feat/java-terrain-cull


📝 Commits (4)

  • c344a26 Java shader packs: occlusion culling while the pack draws the terrain
  • a8c21c2 Merge feat/java-gbuffers-terrain into feat/java-terrain-cull
  • 0bbe50c Merge remote-tracking branch 'origin/main' into feat/java-terrain-cull
  • 5ec40c8 Merge remote-tracking branch 'origin/main' into feat/java-terrain-cull

📊 Changes

7 files changed (+261 additions, -101 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+54 -29)
📝 crates/horizon-client/src/gfx/cull.rs (+122 -44)
📝 crates/horizon-client/src/gfx/cull.wgsl (+22 -0)
📝 crates/horizon-client/src/gfx/flat.rs (+4 -1)
📝 crates/horizon-client/src/gfx/java_stages.rs (+32 -22)
📝 crates/horizon-client/src/gfx/java_terrain.rs (+21 -3)
📝 docs/shader-packs.md (+6 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #1277 (feat/java-gbuffers-terrain), which is stacked on #1267.

What

#1277 turned GPU occlusion culling off while a Java pack draws the terrain. This PR turns it back on, with the same two phases as Horizon's world pass:

  1. The pack's terrain program draws the solid sections the last test saw.
  2. The other sections' boxes are tested against the pack's depth. This runs in a depth-only pass of its own, because the pack's colour targets vary.
  3. The pack's program draws the sections the test found in sight, from the culling's phase 2 draws.

Changes:

  • The pack's depth is in OpenGL's layout: y is flipped and depth runs from 0 near to 1 far. gfx/cull.wgsl gains vs_box_gl and fs_box_depth for it, and Cull gains a second, depth-only pipeline (LessEqual, front face Cw) and Cull::test_gl.
  • java_terrain::Layer (Solid, Revealed, Translucent) replaces the translucent: bool of DrawTerrain. JavaWorld::occlusion carries the test when the frame culls.
  • The flat path (Apple GPUs) has no occlusion culling and is unchanged.

Proof (RTX 4080, Vulkan, MakeUp Ultra Fast 9.6, 1280x720)

Sections hidden (culled_sections: hidden boxes of tested, share of solid indices hidden):

View Hidden boxes Solid indices hidden
ground level (-30,70,0), yaw 270 397 of 419 62%
the wide view (-30,100,0), pitch 25 242 of 307 24%
the water view 326 of 396 32%

Picture: cull on and cull off give the same image, within the pack's frame-to-frame noise.

Pair Mean difference Pixels over 40
off vs off, 2 s apart 7.96 9227
on vs on, 2 s apart 6.27 10128
off vs on 6.60 9527

Frame time (20 s, p50 / p95). Each mode was run twice, alternating cull on, cull off (HORIZON_GPU_CULL=0) and vanilla:

still, noon, wide view flying, sun moving
vanilla 0.15–0.20 / 0.17–0.22 ms 0.14 / 0.16–0.17 ms
MakeUp, culling 0.69–0.70 / 0.71 ms 0.64 / 0.68–0.74 ms
MakeUp, no culling 0.72 / 0.74–0.76 ms 0.63–0.64 / 0.69–0.85 ms

The gain is small in this view, because most of the pack's cost is its full-screen passes. It grows with the hidden share: 62% of the terrain is skipped at ground level.

The Mac mini isn't affected (flat path). There, section-cull on answers "occlusion culling is off on this device".

Tests

  • cargo test -p horizon-client -- cull java passes; gfx::cull::tests::shader_validates covers the new entry points.
  • cargo clippy --all-targets and cargo fmt are clean.
  • docs/shader-packs.md describes the culling and drops it from the limits.

🤖 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/1290 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/java-terrain-cull` --- ### 📝 Commits (4) - [`c344a26`](https://github.com/horizon-rust/horizon/commit/c344a26e80c4b85c39775d54e7727d7babdae9d5) Java shader packs: occlusion culling while the pack draws the terrain - [`a8c21c2`](https://github.com/horizon-rust/horizon/commit/a8c21c27df9bbf4dacda17da084cb4dfe62467d1) Merge feat/java-gbuffers-terrain into feat/java-terrain-cull - [`0bbe50c`](https://github.com/horizon-rust/horizon/commit/0bbe50c6e88241b0299f142682679fb476293cfb) Merge remote-tracking branch 'origin/main' into feat/java-terrain-cull - [`5ec40c8`](https://github.com/horizon-rust/horizon/commit/5ec40c8004bea64adade81e9e45b3229bc72a5ff) Merge remote-tracking branch 'origin/main' into feat/java-terrain-cull ### 📊 Changes **7 files changed** (+261 additions, -101 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+54 -29) 📝 `crates/horizon-client/src/gfx/cull.rs` (+122 -44) 📝 `crates/horizon-client/src/gfx/cull.wgsl` (+22 -0) 📝 `crates/horizon-client/src/gfx/flat.rs` (+4 -1) 📝 `crates/horizon-client/src/gfx/java_stages.rs` (+32 -22) 📝 `crates/horizon-client/src/gfx/java_terrain.rs` (+21 -3) 📝 `docs/shader-packs.md` (+6 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1277 (`feat/java-gbuffers-terrain`), which is stacked on #1267. ## What #1277 turned GPU occlusion culling off while a Java pack draws the terrain. This PR turns it back on, with the same two phases as Horizon's world pass: 1. The pack's terrain program draws the solid sections the last test saw. 2. The other sections' boxes are tested against the pack's depth. This runs in a depth-only pass of its own, because the pack's colour targets vary. 3. The pack's program draws the sections the test found in sight, from the culling's phase 2 draws. Changes: - The pack's depth is in OpenGL's layout: y is flipped and depth runs from 0 near to 1 far. `gfx/cull.wgsl` gains `vs_box_gl` and `fs_box_depth` for it, and `Cull` gains a second, depth-only pipeline (`LessEqual`, front face `Cw`) and `Cull::test_gl`. - `java_terrain::Layer` (`Solid`, `Revealed`, `Translucent`) replaces the `translucent: bool` of `DrawTerrain`. `JavaWorld::occlusion` carries the test when the frame culls. - The flat path (Apple GPUs) has no occlusion culling and is unchanged. ## Proof (RTX 4080, Vulkan, MakeUp Ultra Fast 9.6, 1280x720) **Sections hidden** (`culled_sections`: hidden boxes of tested, share of solid indices hidden): | View | Hidden boxes | Solid indices hidden | | --- | --- | --- | | ground level (-30,70,0), yaw 270 | 397 of 419 | 62% | | the wide view (-30,100,0), pitch 25 | 242 of 307 | 24% | | the water view | 326 of 396 | 32% | **Picture:** cull on and cull off give the same image, within the pack's frame-to-frame noise. | Pair | Mean difference | Pixels over 40 | | --- | --- | --- | | off vs off, 2 s apart | 7.96 | 9227 | | on vs on, 2 s apart | 6.27 | 10128 | | off vs on | 6.60 | 9527 | **Frame time** (20 s, p50 / p95). Each mode was run twice, alternating cull on, cull off (`HORIZON_GPU_CULL=0`) and vanilla: | | still, noon, wide view | flying, sun moving | | --- | --- | --- | | vanilla | 0.15–0.20 / 0.17–0.22 ms | 0.14 / 0.16–0.17 ms | | MakeUp, culling | **0.69–0.70 / 0.71 ms** | 0.64 / 0.68–0.74 ms | | MakeUp, no culling | 0.72 / 0.74–0.76 ms | 0.63–0.64 / 0.69–0.85 ms | The gain is small in this view, because most of the pack's cost is its full-screen passes. It grows with the hidden share: 62% of the terrain is skipped at ground level. The Mac mini isn't affected (flat path). There, `section-cull on` answers "occlusion culling is off on this device". ## Tests - `cargo test -p horizon-client -- cull java` passes; `gfx::cull::tests::shader_validates` covers the new entry points. - `cargo clippy --all-targets` and `cargo fmt` are clean. - `docs/shader-packs.md` describes the culling and drops it from the limits. 🤖 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 04:09:50 +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#3480
No description provided.