[PR #52] [MERGED] Fix missing directional lighting on mob and player models #2300

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

📋 Pull Request Information

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

Base: main ← Head: fix/vanilla-mob-lighting


📝 Commits (1)

  • 7b21d4b fix(client): restore directional lighting for mob models

📊 Changes

27 files changed (+361 additions, -12 deletions)

View changed files

📝 crates/horizon-client/src/block_entity_render.rs (+4 -0)
📝 crates/horizon-client/src/entity.wgsl (+21 -4)
📝 crates/horizon-client/src/game.rs (+10 -0)
📝 crates/horizon-client/src/game/creatures.rs (+2 -0)
📝 crates/horizon-client/src/game/dragon.rs (+3 -0)
📝 crates/horizon-client/src/game/end.rs (+4 -0)
📝 crates/horizon-client/src/game/fireworks.rs (+1 -0)
📝 crates/horizon-client/src/game/fishing.rs (+1 -0)
📝 crates/horizon-client/src/game/frames.rs (+1 -0)
📝 crates/horizon-client/src/game/leads.rs (+1 -0)
📝 crates/horizon-client/src/game/lightning.rs (+1 -0)
📝 crates/horizon-client/src/game/maps.rs (+3 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+1 -0)
📝 crates/horizon-client/src/game/mob_blocks.rs (+1 -0)
📝 crates/horizon-client/src/game/names.rs (+1 -0)
📝 crates/horizon-client/src/game/paintings.rs (+1 -0)
📝 crates/horizon-client/src/game/tnt.rs (+1 -0)
📝 crates/horizon-client/src/gfx.rs (+11 -3)
📝 crates/horizon-client/src/item_render.rs (+1 -0)
📝 crates/horizon-client/src/mesher.rs (+3 -0)

...and 7 more files

📄 Description

Summary

Fix the flat, apparently unshaded appearance of model-based mobs and player models.

The cause was missing directional lighting, not the ordinary mob body being on an unlit render layer: the model emitters discarded vanilla face normals, and the entity shader applied only the lightmap. A baseline pig emitted 168 vertices with identical face colours; the baseline shader failed the directional-light comparison against the owned, shipped 26.3 shader.

Changes

  • Export and load exact ModelPart face normals, including mirrored and collapsed faces.
  • Carry the hierarchical normal transform separately from geometry, preserving vanilla uniform/nonuniform scale handling and quaternion rounding before RGBA8_SNORM packing.
  • Apply the vanilla diffuse-light equation in the entity shader, including front/back face lighting and Nether light directions.
  • Keep eye layers intentionally unshaded; preserve existing baked shading and intentionally unlit geometry.
  • Add five regression tests for normal metadata, mirrored/collapsed faces, parent scaling and child rotations, native packing/rounding, and vertex layout.

Most touched rendering files only initialize the new four-byte normal attribute to zero. The root lighting change is shared by the animated model and first-person model paths.

Validation

  • Standalone offline gate: python3 tools/gate.py --no-parity.
  • Standalone optimized client build and offscreen Vulkan smoke: daylight, night, covered scene, and torch lighting.
  • Actual shipped GLSL via OpenGL transform feedback versus the actual WGSL directional-light branch via Vulkan compute: 49,152 front/back colour outputs, maximum channel error 5.96e-8, repeated.
  • Actual vanilla ModelPart rendering versus Horizon model emission: 95,904 packed face normals, 2,152 cases across 269 affected mob/player model layers, including animated poses, negative scales, and nonuniform scales: exact matches.
  • Existing entity model/pose parity: 1,844 cases across 49 layers; block-entity rendering: 407/407 cases; light propagation: 1,179,648 values and 100 incremental edits.
  • Contributor in-game check reports matching mob and boat appearance.

Scope and limits

This fixes the missing model directional lighting, not a claim of complete entity/framebuffer parity. A complete framebuffer comparison and exhaustive audit of non-model entity renderers are not included. The existing root geometry transform still supplies the initial normal pose; bit-exact root-transform rounding remains separate work. A wider exploratory, hypothetical non-mob model call found one-byte differences for a chest-boat layer, outside the real boat renderer; all affected mob/player fixtures above matched exactly.

The shared vertex stride grows from 32 to 36 bytes; no broad performance benchmark is included. Re-run python3 tools/prepare_native_client.py to regenerate exact normal metadata (the exporter source hash automatically invalidates the old export). Old exports remain readable, but cannot recover normals of collapsed faces.


🔄 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/52 **Author:** [@Online5277](https://github.com/Online5277) **Created:** 10/13/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/vanilla-mob-lighting` --- ### 📝 Commits (1) - [`7b21d4b`](https://github.com/horizon-rust/horizon/commit/7b21d4bc6c362adf6550ccd03bcc42f70a18de1a) fix(client): restore directional lighting for mob models ### 📊 Changes **27 files changed** (+361 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_render.rs` (+4 -0) 📝 `crates/horizon-client/src/entity.wgsl` (+21 -4) 📝 `crates/horizon-client/src/game.rs` (+10 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -0) 📝 `crates/horizon-client/src/game/dragon.rs` (+3 -0) 📝 `crates/horizon-client/src/game/end.rs` (+4 -0) 📝 `crates/horizon-client/src/game/fireworks.rs` (+1 -0) 📝 `crates/horizon-client/src/game/fishing.rs` (+1 -0) 📝 `crates/horizon-client/src/game/frames.rs` (+1 -0) 📝 `crates/horizon-client/src/game/leads.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lightning.rs` (+1 -0) 📝 `crates/horizon-client/src/game/maps.rs` (+3 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+1 -0) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+1 -0) 📝 `crates/horizon-client/src/game/names.rs` (+1 -0) 📝 `crates/horizon-client/src/game/paintings.rs` (+1 -0) 📝 `crates/horizon-client/src/game/tnt.rs` (+1 -0) 📝 `crates/horizon-client/src/gfx.rs` (+11 -3) 📝 `crates/horizon-client/src/item_render.rs` (+1 -0) 📝 `crates/horizon-client/src/mesher.rs` (+3 -0) _...and 7 more files_ </details> ### 📄 Description ## Summary Fix the flat, apparently unshaded appearance of model-based mobs and player models. The cause was missing directional lighting, not the ordinary mob body being on an unlit render layer: the model emitters discarded vanilla face normals, and the entity shader applied only the lightmap. A baseline pig emitted 168 vertices with identical face colours; the baseline shader failed the directional-light comparison against the owned, shipped 26.3 shader. ## Changes - Export and load exact ModelPart face normals, including mirrored and collapsed faces. - Carry the hierarchical normal transform separately from geometry, preserving vanilla uniform/nonuniform scale handling and quaternion rounding before RGBA8_SNORM packing. - Apply the vanilla diffuse-light equation in the entity shader, including front/back face lighting and Nether light directions. - Keep eye layers intentionally unshaded; preserve existing baked shading and intentionally unlit geometry. - Add five regression tests for normal metadata, mirrored/collapsed faces, parent scaling and child rotations, native packing/rounding, and vertex layout. Most touched rendering files only initialize the new four-byte normal attribute to zero. The root lighting change is shared by the animated model and first-person model paths. ## Validation - Standalone offline gate: `python3 tools/gate.py --no-parity`. - Standalone optimized client build and offscreen Vulkan smoke: daylight, night, covered scene, and torch lighting. - Actual shipped GLSL via OpenGL transform feedback versus the actual WGSL directional-light branch via Vulkan compute: **49,152 front/back colour outputs**, maximum channel error **5.96e-8**, repeated. - Actual vanilla ModelPart rendering versus Horizon model emission: **95,904 packed face normals**, **2,152 cases across 269 affected mob/player model layers**, including animated poses, negative scales, and nonuniform scales: **exact matches**. - Existing entity model/pose parity: **1,844 cases across 49 layers**; block-entity rendering: **407/407 cases**; light propagation: **1,179,648 values and 100 incremental edits**. - Contributor in-game check reports matching mob and boat appearance. ## Scope and limits This fixes the missing model directional lighting, not a claim of complete entity/framebuffer parity. A complete framebuffer comparison and exhaustive audit of non-model entity renderers are not included. The existing root geometry transform still supplies the initial normal pose; bit-exact root-transform rounding remains separate work. A wider exploratory, hypothetical non-mob model call found one-byte differences for a chest-boat layer, outside the real boat renderer; all affected mob/player fixtures above matched exactly. The shared vertex stride grows from 32 to 36 bytes; no broad performance benchmark is included. Re-run `python3 tools/prepare_native_client.py` to regenerate exact normal metadata (the exporter source hash automatically invalidates the old export). Old exports remain readable, but cannot recover normals of collapsed faces. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:54:44 +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#2300
No description provided.