[PR #7190] [MERGED] Cull the bat model's back faces (entityCutoutCull) to fix ear z-fighting #7400

Closed
opened 2026-11-03 06:38:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7190
Author: @Joansitoh
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7139-bat-ear-cull


📝 Commits (2)

📊 Changes

8 files changed (+123 additions, -9 deletions)

View changed files

📝 crates/horizon-client-render/src/entity.wgsl (+2 -1)
📝 crates/horizon-client-render/src/gfx/entity_skin.rs (+13 -3)
📝 crates/horizon-client-render/src/gfx/entity_skin.wgsl (+7 -2)
📝 crates/horizon-client-render/src/mesher.rs (+3 -0)
📝 crates/horizon-client/src/mobs.rs (+26 -2)
📝 crates/horizon-client/src/mobs/cem.rs (+2 -0)
📝 crates/horizon-client/src/mobs/render.rs (+3 -0)
📝 crates/horizon-client/src/mobs/skin.rs (+67 -1)

📄 Description

🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally.

What

Bat ears, wings, wing tips and feet are zero-depth boxes: ModelPart.Cube emits a north and a south quad at the same position with opposite winding and different UV regions. Vanilla's BatModel uses RenderTypes::entityCutoutCull (BatModel.java:27), so the facing-away quad is culled. Horizon's mob pipeline has no culling, so both quads drew at equal depth and flickered (z-fighting).

Fix

  • New vertex normal w = -126 (mesher::SHADED_CULL_W): shaded like -127 and also discards back faces (entity.wgsl).
  • Polygon::cull_back, set for the bat model, makes the CPU path emit -126.
  • GPU skinning: SkinJob::cull (job word 14, from the stored model) makes entity_skin.wgsl write the same byte. CPU and GPU stay bit-identical.
  • The back quad is not dropped on the CPU (north/south use different UV regions).
  • BabyTurtleModel also uses entityCutoutCull, but I did not verify zero-depth boxes there, so it is not included.
  • OptiFine/CEM bat models still build cull_back: false.

Vanilla reference

net.minecraft.client.model.ambient.BatModel (entityCutoutCull, boxes at lines 49-66).

Tests

  • mobs::skin::tests::only_the_bat_asks_for_culled_back_faces: bat polygons and GPU job are flagged, cow/cat stay at -127.
  • The existing whole-mob CPU-vs-GPU bit-equality test passes (225 draws).
  • entity_skin::the_shader_writes_what_the_cpu_reference_computes now has a cull: 1 job, so the real shader is checked against expand.
  • pr_ready --quick: Scope 8 files, +123 −9; public tree, Python tests (612), rustfmt, clippy and doc tests pass; horizon-client-lib tests 1381 passed.
  • horizon-client-render --lib run ends with SIGSEGV (signal 11) after the gfx::occlusion tests on this machine's GPU: an environment failure; the entity_skin GPU test passes when run alone.
  • No parity harness covers bat rendering directly. Remaining affected harnesses: run by CI's parity job (136 listed).

Fixes #7139

Suggested label: none

🤖 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/7190 **Author:** [@Joansitoh](https://github.com/Joansitoh) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7139-bat-ear-cull` --- ### 📝 Commits (2) - [`51d1ec6`](https://github.com/horizon-rust/horizon/commit/51d1ec6fc89dd667a5ce23554d34713e11e7c448) Cull the bat model's back faces like entityCutoutCull (#7139) - [`8e68961`](https://github.com/horizon-rust/horizon/commit/8e6896180ad5c751fea76472fa35194caa1410de) Format ### 📊 Changes **8 files changed** (+123 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/entity.wgsl` (+2 -1) 📝 `crates/horizon-client-render/src/gfx/entity_skin.rs` (+13 -3) 📝 `crates/horizon-client-render/src/gfx/entity_skin.wgsl` (+7 -2) 📝 `crates/horizon-client-render/src/mesher.rs` (+3 -0) 📝 `crates/horizon-client/src/mobs.rs` (+26 -2) 📝 `crates/horizon-client/src/mobs/cem.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs/render.rs` (+3 -0) 📝 `crates/horizon-client/src/mobs/skin.rs` (+67 -1) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What Bat ears, wings, wing tips and feet are zero-depth boxes: `ModelPart.Cube` emits a north and a south quad at the same position with opposite winding and different UV regions. Vanilla's `BatModel` uses `RenderTypes::entityCutoutCull` (BatModel.java:27), so the facing-away quad is culled. Horizon's mob pipeline has no culling, so both quads drew at equal depth and flickered (z-fighting). ## Fix - New vertex normal `w = -126` (`mesher::SHADED_CULL_W`): shaded like -127 and also discards back faces (`entity.wgsl`). - `Polygon::cull_back`, set for the bat model, makes the CPU path emit -126. - GPU skinning: `SkinJob::cull` (job word 14, from the stored model) makes `entity_skin.wgsl` write the same byte. CPU and GPU stay bit-identical. - The back quad is not dropped on the CPU (north/south use different UV regions). - BabyTurtleModel also uses `entityCutoutCull`, but I did not verify zero-depth boxes there, so it is not included. - OptiFine/CEM bat models still build `cull_back: false`. ## Vanilla reference `net.minecraft.client.model.ambient.BatModel` (`entityCutoutCull`, boxes at lines 49-66). ## Tests - `mobs::skin::tests::only_the_bat_asks_for_culled_back_faces`: bat polygons and GPU job are flagged, cow/cat stay at -127. - The existing whole-mob CPU-vs-GPU bit-equality test passes (225 draws). - `entity_skin::the_shader_writes_what_the_cpu_reference_computes` now has a `cull: 1` job, so the real shader is checked against `expand`. - `pr_ready --quick`: Scope 8 files, +123 −9; public tree, Python tests (612), rustfmt, clippy and doc tests pass; `horizon-client-lib` tests 1381 passed. - `horizon-client-render --lib` run ends with SIGSEGV (signal 11) after the gfx::occlusion tests on this machine's GPU: an environment failure; the entity_skin GPU test passes when run alone. - No parity harness covers bat rendering directly. Remaining affected harnesses: run by CI's parity job (136 listed). Fixes #7139 Suggested label: none 🤖 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 06:38:58 +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#7400
No description provided.