[PR #2615] [MERGED] client: retune the entity-shadow depth bias to kill its rim flicker #4477

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

📋 Pull Request Information

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

Base: main ← Head: shadow-depth-bias


📝 Commits (1)

  • c3a12bf client: retune the entity-shadow depth bias to kill its rim flicker

📊 Changes

1 file changed (+9 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+9 -7)

📄 Description

🤖 Opened by Silas Lunsford's AI agent (GLM), not by Silas himself.

What and why

The entity shadows' rim flickered away from the vanilla look: as the camera drifts even a subpixel, the shadow's rim speckle re-rolls frame by frame - players reported it most on decorated pots (the pieces there straddle several block tops), but it reproduces on any entity over flat ground.

The Entity shadows pipeline draws the quads exactly on the block tops like vanilla (EntityRenderer.extractShadow), but the terrain under them and the shadow quads come from two separate draw paths, so their fp32 depth interpolations disagree by a few dozen ulps of the fragment depth. The pipeline's constant depth bias of 16 ulps covers the coarse case (whole shadows undertest the block top after a slant), but the re-roll of the residual few-ulps disagreement flickers: every subpixel camera change re-rolls which rim pixel wins.

Raising the constant to 128 ulps silences the rim across all camera pitches while staying far below what the 0.001 a model's feet sit higher measures in depth, so shadows still never bleed onto the feet. Measured with subpixel yaw glides (~0.0005 deg/step, world frozen) with a static camera and a cobblestone item over stone at camera pitches 70/45/20 down: the shadow-region flips >40 gray levels between consecutive frames were ~88/~60/~26 pixels at 16-ulp bias (all on the shadow's rim) and ~0 (the ambient cloud/water noise floor) at a 128-ulp bias; noEntity baselines matched the after-count. The slope-scale bias is untouched.

Vanilla reference

  • EntityRenderer.extractShadow + ShadowFeatureRenderer (decompiled client sources): shadow pieces lie on the block top itself, no offset.
  • RenderPipelines.ENTITY_SHADOW: GREATER_THAN_OR_EQUAL compare, no depth write, no polygon offset. Vanilla runs one draw pipeline over a fixed 24-bit depth, so the two coplanar draws disagree in Horizon only: reversed Depth32Float plus separate terrain and shadow paths make a small constant bias necessary, and 16 was simply too small for the residual.
  • No parity harness asserts the depth-bias constant (rendering-internal numeric choice); tools/parity.py block_entity_render cloud_render world_border_render (gfx.rs-adjacent render harnesses) pass with the change.

Self-check

pr_ready (tools/pr_ready.py --quick, omarchy, against origin/main at aef652c8a, 8 min 25 s)

Check Result
Scope ✅ 1 files, +9 −7
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 320 passed (28 s)
rustfmt ✅ (6 s)
clippy ✅ (2 min 23 s)
tests: horizon-client ✅ 1337 passed (5 min 3 s)
doc tests ✅ 0 passed (26 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: no label for a fix

Screenshots

The shadow of a dropped cobblestone item, camera looking 45 degrees down: the "before" frame is picked during a subpixel glide, where the shadow's rim shows the flipped-in/out speckle; "after" is the same setup with the changed bias.

before/after rim

🤖 Generated with GLM


🔄 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/2615 **Author:** [@sifi11](https://github.com/sifi11) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shadow-depth-bias` --- ### 📝 Commits (1) - [`c3a12bf`](https://github.com/horizon-rust/horizon/commit/c3a12bf7924e141518b82431452377a5b73856ac) client: retune the entity-shadow depth bias to kill its rim flicker ### 📊 Changes **1 file changed** (+9 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+9 -7) </details> ### 📄 Description > 🤖 Opened by Silas Lunsford's AI agent (GLM), not by Silas himself. ## What and why The entity shadows' rim flickered away from the vanilla look: as the camera drifts even a subpixel, the shadow's rim speckle re-rolls frame by frame - players reported it most on decorated pots (the pieces there straddle several block tops), but it reproduces on any entity over flat ground. The `Entity shadows` pipeline draws the quads exactly on the block tops like vanilla (`EntityRenderer.extractShadow`), but the terrain under them and the shadow quads come from two separate draw paths, so their fp32 depth interpolations disagree by a few dozen ulps of the fragment depth. The pipeline's constant depth bias of 16 ulps covers the coarse case (whole shadows undertest the block top after a slant), but the re-roll of the residual few-ulps disagreement flickers: every subpixel camera change re-rolls which rim pixel wins. Raising the constant to 128 ulps silences the rim across all camera pitches while staying far below what the 0.001 a model's feet sit higher measures in depth, so shadows still never bleed onto the feet. Measured with subpixel yaw glides (~0.0005 deg/step, world frozen) with a static camera and a cobblestone item over stone at camera pitches 70/45/20 down: the shadow-region flips >40 gray levels between consecutive frames were ~88/~60/~26 pixels at 16-ulp bias (all on the shadow's rim) and ~0 (the ambient cloud/water noise floor) at a 128-ulp bias; noEntity baselines matched the after-count. The slope-scale bias is untouched. ## Vanilla reference - `EntityRenderer.extractShadow` + `ShadowFeatureRenderer` (decompiled `client` sources): shadow pieces lie on the block top itself, no offset. - `RenderPipelines.ENTITY_SHADOW`: GREATER_THAN_OR_EQUAL compare, no depth write, no polygon offset. Vanilla runs one draw pipeline over a fixed 24-bit depth, so the two coplanar draws disagree in Horizon only: reversed Depth32Float plus separate terrain and shadow paths make a small constant bias necessary, and 16 was simply too small for the residual. - No parity harness asserts the depth-bias constant (rendering-internal numeric choice); `tools/parity.py block_entity_render cloud_render world_border_render` (`gfx.rs`-adjacent render harnesses) pass with the change. ## Self-check **pr_ready** (`tools/pr_ready.py --quick`, omarchy, against origin/main at aef652c8a, 8 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +9 −7 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 320 passed (28 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (2 min 23 s) | | tests: horizon-client | ✅ 1337 passed (5 min 3 s) | | doc tests | ✅ 0 passed (26 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: no label for a fix | ## Screenshots The shadow of a dropped cobblestone item, camera looking 45 degrees down: the "before" frame is picked during a subpixel glide, where the shadow's rim shows the flipped-in/out speckle; "after" is the same setup with the changed bias. ![before/after rim](https://raw.githubusercontent.com/sifi11/horizon/shadow-media-branch/shadow-rim-before-after.png) 🤖 Generated with [GLM](https://z.ai) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17:26 +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#4477
No description provided.