[PR #1470] [MERGED] Entity shadows: no more z-fighting with chicken feet and other model feet #3547

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

📋 Pull Request Information

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

Base: main ← Head: fix/entity-shadow-height


📝 Commits (2)

  • eb79cfd Entity shadows: no more z-fighting with chicken feet and other model feet
  • f47f6ee Merge remote-tracking branch 'origin/main' into fix/entity-shadow-height

📊 Changes

3 files changed (+104 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+43 -6)
📝 crates/horizon-client/src/gfx/entity_batch.rs (+10 -5)
📝 crates/horizon-client/src/shadows.rs (+51 -2)

📄 Description

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

Part of #1440: fixes the z-fighting between entity shadows and model feet (a chicken's feet), the part of the report that reproduces.

Vanilla 26.3

  • LivingEntityRenderer translates models by (0, -1.501, 0), so feet sit 0.001 above the ground.
  • ShadowFeatureRenderer puts the shadow quads exactly on the block top (relativeY + shapeBelow.minY, no lift).
  • RenderPipelines.ENTITY_SHADOW has no depth write and uses the normal depth test.

Horizon lifted the shadow 0.001 (coplanar with the feet) and drew it in the entity batch with depth writes, so the toes and the shadow fought.

Change

  • Shadow quads go on the block top.
  • Shadows are their own entity material (SHADOW_OVERLAY = 14). A pipeline with no depth write draws them after the other entity quads.
  • That pipeline has a small depth bias: constant 16 plus 0.015 of the slope. Terrain vertices snap to the subpixel grid differently from the shadow's, and without the bias whole shadows vanished at some camera positions. With it, shadows stay over the terrain and under feet 0.001 higher.
  • Shader-pack shadow maps don't draw entity shadows as casters.

Tests

  • shadows::tests::shadows_lie_on_the_block_top_under_model_feet (resource-backed) fails with the old +0.001 lift and passes now.
  • The gfx material-batch test is updated for the fifth material.
  • In game (Mac mini, Metal, offscreen 1280x720), a line of chickens on grass, 10 frames each as the camera moves; each row of the strips is one frame. On main the toes darken in some frames, where the shadow is drawn over them. After the change they stay bright in all 10, and the shadows show in every frame.
before (main) after

Not reproduced: flower pots and "many blocks"

Flower pots and other blocks show no z-fighting on Metal. The pot model has no overlapping coplanar faces, and flower_pot and the potted variants render clean at every distance I tried . The reporter gave no platform or screenshot. I've asked on the issue.

Not checked on Vulkan: the ThinkPad has no Vulkan ICD installed (/usr/share/vulkan/icd.d is empty), and I didn't use the desktop.

Self-check

These checks ran on one integration commit with #1467, #1468, #1469, #1470 and #1471 merged on main (Mac mini):

  • cargo fmt --all -- --check: clean
  • cargo clippy --workspace --all-targets -- -D warnings: clean. The first run was on main at 8a4ebcc55, with the two functions #1472 restores added in a local commit. The final run, on main with #1472 merged, is clean too.
  • cargo test -p horizon-client --lib: 1063 passed. --bins: 98 + 18 passed.
  • tools/parity.py --changed origin/main: 309/310 passed in 69.8 min, the same run as the clippy check above. The one failure, menu_click, was the loom case fixed in #1467's second commit. On the refreshed integration commit (main with #1472, plus all five branches), menu_click passes: 8000/8000 with seed 7 and with seed 11.

Needs Ludovic

A Vulkan look (desktop or a Vulkan driver on the ThinkPad), and the reporter's platform for the flower-pot part.

🤖 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/1470 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/entity-shadow-height` --- ### 📝 Commits (2) - [`eb79cfd`](https://github.com/horizon-rust/horizon/commit/eb79cfdb010fc01ce88a31a3c6e30b5361fafde0) Entity shadows: no more z-fighting with chicken feet and other model feet - [`f47f6ee`](https://github.com/horizon-rust/horizon/commit/f47f6ee4720153784b6aabb23216f3ad8ffa7ab0) Merge remote-tracking branch 'origin/main' into fix/entity-shadow-height ### 📊 Changes **3 files changed** (+104 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+43 -6) 📝 `crates/horizon-client/src/gfx/entity_batch.rs` (+10 -5) 📝 `crates/horizon-client/src/shadows.rs` (+51 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of #1440: fixes the z-fighting between entity shadows and model feet (a chicken's feet), the part of the report that reproduces. ## Vanilla 26.3 - `LivingEntityRenderer` translates models by `(0, -1.501, 0)`, so feet sit 0.001 above the ground. - `ShadowFeatureRenderer` puts the shadow quads exactly on the block top (`relativeY + shapeBelow.minY`, no lift). - `RenderPipelines.ENTITY_SHADOW` has no depth write and uses the normal depth test. Horizon lifted the shadow 0.001 (coplanar with the feet) and drew it in the entity batch with depth writes, so the toes and the shadow fought. ## Change - Shadow quads go on the block top. - Shadows are their own entity material (`SHADOW_OVERLAY` = 14). A pipeline with no depth write draws them after the other entity quads. - That pipeline has a small depth bias: constant 16 plus 0.015 of the slope. Terrain vertices snap to the subpixel grid differently from the shadow's, and without the bias whole shadows vanished at some camera positions. With it, shadows stay over the terrain and under feet 0.001 higher. - Shader-pack shadow maps don't draw entity shadows as casters. ## Tests - `shadows::tests::shadows_lie_on_the_block_top_under_model_feet` (resource-backed) fails with the old +0.001 lift and passes now. - The `gfx` material-batch test is updated for the fifth material. - In game (Mac mini, Metal, offscreen 1280x720), a line of chickens on grass, 10 frames each as the camera moves; each row of the strips is one frame. On main the toes darken in some frames, where the shadow is drawn over them. After the change they stay bright in all 10, and the shadows show in every frame. | before (main) | after | |---|---| | ![](https://raw.githubusercontent.com/ludovic111/horizon/c5d43f6e724a6e9c6ad44ed4b6fc33fcfa081392/1440/zfeet-zoom.png) | ![](https://raw.githubusercontent.com/ludovic111/horizon/c5d43f6e724a6e9c6ad44ed4b6fc33fcfa081392/1440/zE-feet.png) | ## Not reproduced: flower pots and "many blocks" Flower pots and other blocks show no z-fighting on Metal. The pot model has no overlapping coplanar faces, and `flower_pot` and the potted variants render clean at every distance I tried ![](https://raw.githubusercontent.com/ludovic111/horizon/c5d43f6e724a6e9c6ad44ed4b6fc33fcfa081392/1440/pots-zoom.png). The reporter gave no platform or screenshot. I've asked on the issue. Not checked on Vulkan: the ThinkPad has no Vulkan ICD installed (`/usr/share/vulkan/icd.d` is empty), and I didn't use the desktop. ## Self-check These checks ran on one integration commit with #1467, #1468, #1469, #1470 and #1471 merged on main (Mac mini): - `cargo fmt --all -- --check`: clean - `cargo clippy --workspace --all-targets -- -D warnings`: clean. The first run was on main at 8a4ebcc55, with the two functions #1472 restores added in a local commit. The final run, on main with #1472 merged, is clean too. - `cargo test -p horizon-client --lib`: 1063 passed. `--bins`: 98 + 18 passed. - `tools/parity.py --changed origin/main`: 309/310 passed in 69.8 min, the same run as the clippy check above. The one failure, `menu_click`, was the loom case fixed in #1467's second commit. On the refreshed integration commit (main with #1472, plus all five branches), `menu_click` passes: 8000/8000 with seed 7 and with seed 11. ## Needs Ludovic A Vulkan look (desktop or a Vulkan driver on the ThinkPad), and the reporter's platform for the flower-pot part. 🤖 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:10:19 +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#3547
No description provided.