[PR #296] [MERGED] Render the world with reversed depth like vanilla (far fire no longer flickers) #2465

Closed
opened 2026-11-02 15:56:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/reversed-z-depth


📝 Commits (1)

  • 1bfef88 Render the world with reversed depth like vanilla

📊 Changes

2 files changed (+34 additions, -16 deletions)

View changed files

📝 crates/horizon-client/src/camera.rs (+3 -3)
📝 crates/horizon-client/src/gfx.rs (+31 -13)

📄 Description

Fixes #272

What

The world (and the first-person hand) now render with reversed depth, like vanilla 26.3: the projection maps the near plane to 1 and the far plane to 0, depth clears to 0, every depth test is GREATER_THAN_OR_EQUAL, and the two depth biases (block cracks, world border) flip sign to vanilla's positive values (1, 10 and 3, 3).

Why

Vanilla's Projection.getMatrix passes its planes reversed (near = zFar, far = zNear) and every world pipeline in RenderPipelines tests GREATER_THAN_OR_EQUAL. Horizon kept forward depth with a 0.05 near plane, where a float depth buffer has almost no precision left at distance. Fire is built from quads a hair apart: template_fire_side sits 0.01 pixel (1/1600 block) inside its block, so neighbouring fire blocks put two flame quads 1/800 block apart, and a quad against a wall sits 1/1600 block in front of it. At 60 blocks forward depth can only separate surfaces about 0.004 blocks apart, and at 150 blocks about 0.03, so those quads z-fought and the flames flickered. Reversed float depth keeps them apart at any render distance.

How tested

  • Before/after on the Mac mini (--offscreen, horizon-ctl screenshot): a 16×10 netherrack fire field seen through a spyglass from 150 blocks. Before: the flame columns break into a blocky, flickering mosaic. After: clean flame columns.
  • New unit test gfx::tests::far_faces_a_hair_apart_keep_their_depth_order: a quad 0.01 pixel in front of a block at 150 blocks gets a distinct, nearer depth. It fails with the old forward projection and passes with the new one.
  • Vanilla could not be captured side by side here (the Mac session is locked and vanilla can't be driven without Accessibility). The change follows Projection and RenderPipelines line for line.

Self-check (Mac mini, all three fixes on main)

cargo fmt --all --check                                   ok
cargo clippy --workspace --all-targets -- -D warnings     ok (also each branch alone: clippy -p horizon-client --all-targets)
cargo test -p horizon-client                              ok (628 lib + bins, 0 failed)
python3 tools/parity.py --changed origin/main             79 passed, 0 failed in 64.9 min

Needs Ludovic

Nothing.

🤖 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/296 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/reversed-z-depth` --- ### 📝 Commits (1) - [`1bfef88`](https://github.com/horizon-rust/horizon/commit/1bfef8847779d450dd2a7300346cd53d265d9e18) Render the world with reversed depth like vanilla ### 📊 Changes **2 files changed** (+34 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/camera.rs` (+3 -3) 📝 `crates/horizon-client/src/gfx.rs` (+31 -13) </details> ### 📄 Description Fixes #272 ## What The world (and the first-person hand) now render with reversed depth, like vanilla 26.3: the projection maps the near plane to 1 and the far plane to 0, depth clears to 0, every depth test is `GREATER_THAN_OR_EQUAL`, and the two depth biases (block cracks, world border) flip sign to vanilla's positive values (`1, 10` and `3, 3`). ## Why Vanilla's `Projection.getMatrix` passes its planes reversed (`near = zFar`, `far = zNear`) and every world pipeline in `RenderPipelines` tests `GREATER_THAN_OR_EQUAL`. Horizon kept forward depth with a 0.05 near plane, where a float depth buffer has almost no precision left at distance. Fire is built from quads a hair apart: `template_fire_side` sits 0.01 pixel (1/1600 block) inside its block, so neighbouring fire blocks put two flame quads 1/800 block apart, and a quad against a wall sits 1/1600 block in front of it. At 60 blocks forward depth can only separate surfaces about 0.004 blocks apart, and at 150 blocks about 0.03, so those quads z-fought and the flames flickered. Reversed float depth keeps them apart at any render distance. ## How tested - Before/after on the Mac mini (`--offscreen`, `horizon-ctl screenshot`): a 16×10 netherrack fire field seen through a spyglass from 150 blocks. Before: the flame columns break into a blocky, flickering mosaic. After: clean flame columns. - New unit test `gfx::tests::far_faces_a_hair_apart_keep_their_depth_order`: a quad 0.01 pixel in front of a block at 150 blocks gets a distinct, nearer depth. It fails with the old forward projection and passes with the new one. - Vanilla could not be captured side by side here (the Mac session is locked and vanilla can't be driven without Accessibility). The change follows `Projection` and `RenderPipelines` line for line. ## Self-check (Mac mini, all three fixes on main) ``` cargo fmt --all --check ok cargo clippy --workspace --all-targets -- -D warnings ok (also each branch alone: clippy -p horizon-client --all-targets) cargo test -p horizon-client ok (628 lib + bins, 0 failed) python3 tools/parity.py --changed origin/main 79 passed, 0 failed in 64.9 min ``` ## Needs Ludovic Nothing. 🤖 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-02 15:56:23 +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#2465
No description provided.