[GH-ISSUE #5322] Renderer: reduce see-through leaves frame cost without changing pixels #1640

Closed
opened 2026-11-02 15:48:34 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @elythepreciouscat on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5322

Originally assigned to: @elythepreciouscat on GitHub.

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

Rendering with see-through leaves enabled emits every leaf face so alpha-cutout holes remain visible. Dense trees can therefore multiply terrain work and frame time. Profile the path and reduce its cost while preserving the vanilla 26.3 image and setting behavior exactly.

Originally created by @elythepreciouscat on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5322 Originally assigned to: @elythepreciouscat on GitHub. > 🤖 Filed by elythepreciouscat's AI agent (Codex, GPT-6), not by elythepreciouscat personally. Rendering with see-through leaves enabled emits every leaf face so alpha-cutout holes remain visible. Dense trees can therefore multiply terrain work and frame time. Profile the path and reduce its cost while preserving the vanilla 26.3 image and setting behavior exactly.
Author
Owner

@elythepreciouscat commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6547056563 --> @elythepreciouscat commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim
Author
Owner

@elythepreciouscat commented on GitHub (Oct 31, 2026):

🤖 Agent: Update from PR #5519: the current optimization is useful, but it is intentionally only a partial answer to this issue.

The PR keeps every fancy-leaf face and every canonical SectionMesh vertex. When a section contains solid cutout terrain, it uploads the existing quads in stable front-to-back order within the existing side buckets. That lets the depth buffer reject more hidden leaf fragments before the expensive terrain shading work. It measured about 13% higher FPS and 12–16% lower render time in the dense LeafCloud scene, while keeping the shared index buffer and the original draw batching.

It does not remove the underlying source of the cost: fancy leaves still emit and submit all of their interior faces. A parity-safe smart leaf culler would pair well with this PR. The culler could conservatively remove only faces whose visibility is provably covered by neighboring opaque/leaf volume, while retaining exposed faces, cutout boundaries, holes, and model-specific faces that can affect the image. The remaining visible faces would then benefit from the front-to-back ordering already implemented here. That would reduce both vertex submission and fragment work without relying on greedy geometry changes.

The first optimization prototype was a greedy 1x1-to-2x1 leaf-face merge. I discarded it because it changed the canonical vertex topology and could not guarantee Java Edition pixel parity: it introduced T-junctions, changed interpolation/triangle diagonals for AO and tint gradients, and required careful fixed-point UV and mip-gradient handling at the tile boundary. The section-mesh parity corpus showed new missing/extra geometry categories when that prototype was enabled, so it was removed rather than weakening the parity requirement.

I also tested two render-only alternatives and discarded them for batching reasons:

  • A per-section opaque/cutout pipeline split increased indirect section draw calls from 3 to 239.
  • A custom per-section index-page order increased them from 3 to 22 and added index memory/bandwidth.

Both costs outweighed their potential gain on the target GPU. The submitted approach keeps the one shared index buffer and changes only the upload order, which is why it is a safe incremental optimization rather than the complete smart-culling solution this issue calls for.

The rebased branch still passes section-mesh parity with client and Rust quad counts both at 1,008,927; the remaining work is to design and validate conservative leaf visibility culling without changing the vanilla fancy-leaf image.

<!-- gh-comment-id:6549905718 --> @elythepreciouscat commented on GitHub (Oct 31, 2026): 🤖 Agent: Update from [PR #5519](https://github.com/horizon-rust/horizon/pull/5519): the current optimization is useful, but it is intentionally only a partial answer to this issue. The PR keeps every fancy-leaf face and every canonical `SectionMesh` vertex. When a section contains solid cutout terrain, it uploads the existing quads in stable front-to-back order within the existing side buckets. That lets the depth buffer reject more hidden leaf fragments before the expensive terrain shading work. It measured about 13% higher FPS and 12–16% lower render time in the dense `LeafCloud` scene, while keeping the shared index buffer and the original draw batching. It does not remove the underlying source of the cost: fancy leaves still emit and submit all of their interior faces. A parity-safe smart leaf culler would pair well with this PR. The culler could conservatively remove only faces whose visibility is provably covered by neighboring opaque/leaf volume, while retaining exposed faces, cutout boundaries, holes, and model-specific faces that can affect the image. The remaining visible faces would then benefit from the front-to-back ordering already implemented here. That would reduce both vertex submission and fragment work without relying on greedy geometry changes. The first optimization prototype was a greedy 1x1-to-2x1 leaf-face merge. I discarded it because it changed the canonical vertex topology and could not guarantee Java Edition pixel parity: it introduced T-junctions, changed interpolation/triangle diagonals for AO and tint gradients, and required careful fixed-point UV and mip-gradient handling at the tile boundary. The section-mesh parity corpus showed new missing/extra geometry categories when that prototype was enabled, so it was removed rather than weakening the parity requirement. I also tested two render-only alternatives and discarded them for batching reasons: - A per-section opaque/cutout pipeline split increased indirect section draw calls from 3 to 239. - A custom per-section index-page order increased them from 3 to 22 and added index memory/bandwidth. Both costs outweighed their potential gain on the target GPU. The submitted approach keeps the one shared index buffer and changes only the upload order, which is why it is a safe incremental optimization rather than the complete smart-culling solution this issue calls for. The rebased branch still passes section-mesh parity with client and Rust quad counts both at `1,008,927`; the remaining work is to design and validate conservative leaf visibility culling without changing the vanilla fancy-leaf image.
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#1640
No description provided.