[PR #118] [MERGED] entity_model harness: compare per-vertex normals with vanilla #2335

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

📋 Pull Request Information

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

Base: main ← Head: test/entity-model-normals


📝 Commits (1)

  • 3f61995 test(entity_model): compare per-vertex normals with vanilla

📊 Changes

3 files changed (+308 additions, -9 deletions)

View changed files

📝 crates/horizon-client/examples/entity_anim_fixture.rs (+86 -3)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityAnimOracle.java (+115 -2)
📝 tools/test_entity_model_parity.py (+107 -4)

📄 Description

What was missing

Since #52 Horizon's entity meshes carry per-vertex normals (for entity.wgsl's directional light), but tools/test_entity_model_parity.py only compared part geometry and setupAnim poses: nothing checked the normals vanilla actually writes.

What vanilla does

ModelPart.render → ModelPart.Cube.compile: each Polygon's normal is transformed with PoseStack.Pose.transformNormal (the pose's normal matrix; PoseStack.scale flips it for negative scales with trustedNormals, and normalises it for non-uniform ones) and written with VertexConsumer.setNormal, packed by BufferBuilder to signed bytes (normalIntValue) in the NEW_ENTITY format.

The change

  • VanillaEntityAnimOracle draws every posed case through the real ModelPart.render under LivingEntityRenderer's root transform (body yaw, scale(-1, -1, 1), the renderer's scale, the -1.501 translation) into a capturing VertexConsumer, and records each drawn part's normals packed with BufferBuilder's own normalIntValue, plus a position checksum.
  • entity_anim_fixture draws the same case with mobs::render::draw and records the RGBA8_SNORM normal bytes of each drawn part (and the position checksum).
  • The harness compares them byte for byte. A one-step difference is accepted only where vanilla's float lies on a truncation edge (--normal-edge, 1e-4). A part-scale override per case covers negative and non-uniform part scales. Comparison happens on the packed bytes because both games feed the GPU those, not floats.

How tested

Full run (Mac mini, with the current shared-local data):

  • 5815 cases over 160 layers;
  • 1 251 216 vertex normals in 44 922 drawn parts: 1 250 832 byte-identical, 384 components one step apart at a truncation edge, max byte difference 1 (max normal error 0.00787); 48 collapsed vertices of zero-scaled parts left out;
  • entity model parity ok.

Note: with the Mac mini's stale entity-models.json (from 10 October) the run fails with 41 layers emitting zero normals; the re-prepared one passes. cargo fmt --check, cargo clippy --workspace --all-targets -D warnings clean; tools/check_public_tree.py passed.

🤖 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/118 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `test/entity-model-normals` --- ### 📝 Commits (1) - [`3f61995`](https://github.com/horizon-rust/horizon/commit/3f61995c8b7b75beb875b292aadbc5c72c2a8406) test(entity_model): compare per-vertex normals with vanilla ### 📊 Changes **3 files changed** (+308 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/entity_anim_fixture.rs` (+86 -3) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaEntityAnimOracle.java` (+115 -2) 📝 `tools/test_entity_model_parity.py` (+107 -4) </details> ### 📄 Description ## What was missing Since #52 Horizon's entity meshes carry per-vertex normals (for `entity.wgsl`'s directional light), but `tools/test_entity_model_parity.py` only compared part geometry and `setupAnim` poses: nothing checked the normals vanilla actually writes. ## What vanilla does `ModelPart.render` → `ModelPart.Cube.compile`: each `Polygon`'s normal is transformed with `PoseStack.Pose.transformNormal` (the pose's normal matrix; `PoseStack.scale` flips it for negative scales with `trustedNormals`, and normalises it for non-uniform ones) and written with `VertexConsumer.setNormal`, packed by `BufferBuilder` to signed bytes (`normalIntValue`) in the NEW_ENTITY format. ## The change - `VanillaEntityAnimOracle` draws every posed case through the real `ModelPart.render` under `LivingEntityRenderer`'s root transform (body yaw, `scale(-1, -1, 1)`, the renderer's scale, the -1.501 translation) into a capturing `VertexConsumer`, and records each drawn part's normals packed with `BufferBuilder`'s own `normalIntValue`, plus a position checksum. - `entity_anim_fixture` draws the same case with `mobs::render::draw` and records the RGBA8_SNORM normal bytes of each drawn part (and the position checksum). - The harness compares them byte for byte. A one-step difference is accepted only where vanilla's float lies on a truncation edge (`--normal-edge`, 1e-4). A part-scale override per case covers negative and non-uniform part scales. Comparison happens on the packed bytes because both games feed the GPU those, not floats. ## How tested Full run (Mac mini, with the current shared-local data): - 5815 cases over 160 layers; - **1 251 216 vertex normals** in 44 922 drawn parts: 1 250 832 byte-identical, 384 components one step apart at a truncation edge, max byte difference 1 (max normal error 0.00787); 48 collapsed vertices of zero-scaled parts left out; - `entity model parity ok`. Note: with the Mac mini's stale `entity-models.json` (from 10 October) the run fails with 41 layers emitting zero normals; the re-prepared one passes. `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings` clean; `tools/check_public_tree.py` passed. 🤖 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:55:03 +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#2335
No description provided.