[PR #121] [MERGED] OverlayTexture texels from one tested table; creepers flash white while swelling #2337

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

📋 Pull Request Information

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

Base: main ← Head: fix/creeper-white-flash


📝 Commits (1)

  • 74821bf Overlay texels from OverlayTexture, and the creeper's white flash

📊 Changes

7 files changed (+156 additions, -15 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/Cargo.toml (+4 -0)
📝 crates/horizon-client/src/entity.wgsl (+7 -5)
📝 crates/horizon-client/src/gfx.rs (+16 -1)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/mobs/render.rs (+25 -9)
➕ crates/horizon-client/src/overlay.rs (+102 -0)

📄 Description

Follow-up to #117 (hurt tint in vanilla's order, merged).

What was wrong

  • The overlay texels in entity.wgsl were hand-written literals (hurt 178/255, TNT white 63/255), untested against vanilla.
  • Swelling creepers never flashed white: Horizon had no CreeperRenderer.getWhiteOverlayProgress at all.
  • CreeperRenderer.scale's wobble used the clamped swelling; vanilla computes the wobble from the unclamped Creeper.getSwelling (it passes 1 in the last two fuse ticks) and clamps afterwards.

What vanilla does

  • OverlayTexture: rows 0–7 are 0xB2FF0000; row 10 is white with alpha (int) ((1 - x / 15F * 0.75F) * 255F). LivingEntityRenderer.getOverlayCoords = pack(u(whiteOverlayProgress), v(hasRedOverlay)), u = (int) (progress * 15), v = hurt ? 3 : 10, so the red row wins while hurt. hasRedOverlay = hurtTime > 0 || deathTime > 0 (CreakingRenderer clears it while tearing down; EnderDragonRenderer uses hurtTime > 0). Horizon already matches those conditions, and sets hurtTime to 10 on hurt.
  • CreeperRenderer.getWhiteOverlayProgress: (int) (swelling * 10) % 2 == 0 ? 0 : clamp(swelling, 0.5, 1). Layers (e.g. the charged swirl, wool) use getOverlayCoords(state, 0): red only.
  • entity.fsh mixes the overlay texel over the lit texture, then multiplies by the lightmap (#117).

The change

  • overlay.rs: the OverlayTexture texels and the overlay codes (living(white, red), creeper_progress), prepended to entity.wgsl as WGSL constants (HURT_OVERLAY, WHITE_OVERLAY_ALPHA[16]). Codes 16..=31 are the white row's columns 0..=15; TNT keeps code 5 (column 15).
  • mobs/render.rs: the body of a swelling creeper carries its white column; layers and extras keep the red only. creeper_swelling is Creeper.getSwelling; the scale wobble uses it unclamped.

How tested

  • Unit tests: the 16 white alphas and the hurt texel equal the values printed by the 26.3 JVM (255, 242, 229, 216, 203, 191, 178, 165, 152, 140, 127, 114, 101, 89, 76, 63, b2ff0000); creeper swelling → column for 12 swellings, compared with the JVM (e.g. 0.55 → 8, 0.95 → 14, 1.0 → 0); red wins over white. entity_shader_validates_with_its_overlay_constants parses and validates the composed shader with naga (dev-dependency, already built for wgpu).
  • vscreen, same scene as #117 with this build (a sheep and a husk, NoAI, /damage; daylight, midnight, a closed stone box). Per-pixel check against entity.fsh (tools-free script ~/code/horizon-parity/screens/hurt-tint/check_formula.py): for every changed pixel, G and B are 0.698 × unhurt (mean error 0.36–0.50 levels), and the red added is 77 × the lightmap: median 76.9 in daylight, 21.0 at night, 6.2 in the box (p1–p99 75.7–77.6, 19.6–21.8, 3.9–7.6). Before #117 it was 52.8 / 52.6 / 44.0 with a 6–77 spread: the red did not follow the light. Frames: ~/code/horizon-parity/screens/hurt-tint/final-{day,night,box}-{hurt,unhurt}.png on ludodesktop.
  • The creeper flash itself is covered by the unit tests, not by a screenshot.
  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings clean, cargo test -p horizon-client --lib 412 passed (Mac mini); 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/121 **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:** `fix/creeper-white-flash` --- ### 📝 Commits (1) - [`74821bf`](https://github.com/horizon-rust/horizon/commit/74821bf1883b97f9717179ec23953c876d965130) Overlay texels from OverlayTexture, and the creeper's white flash ### 📊 Changes **7 files changed** (+156 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/Cargo.toml` (+4 -0) 📝 `crates/horizon-client/src/entity.wgsl` (+7 -5) 📝 `crates/horizon-client/src/gfx.rs` (+16 -1) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/render.rs` (+25 -9) ➕ `crates/horizon-client/src/overlay.rs` (+102 -0) </details> ### 📄 Description Follow-up to #117 (hurt tint in vanilla's order, merged). ## What was wrong - The overlay texels in `entity.wgsl` were hand-written literals (hurt `178/255`, TNT white `63/255`), untested against vanilla. - **Swelling creepers never flashed white**: Horizon had no `CreeperRenderer.getWhiteOverlayProgress` at all. - `CreeperRenderer.scale`'s wobble used the clamped swelling; vanilla computes the wobble from the unclamped `Creeper.getSwelling` (it passes 1 in the last two fuse ticks) and clamps afterwards. ## What vanilla does - `OverlayTexture`: rows 0–7 are `0xB2FF0000`; row 10 is white with alpha `(int) ((1 - x / 15F * 0.75F) * 255F)`. `LivingEntityRenderer.getOverlayCoords` = `pack(u(whiteOverlayProgress), v(hasRedOverlay))`, `u = (int) (progress * 15)`, `v = hurt ? 3 : 10`, so the red row wins while hurt. `hasRedOverlay = hurtTime > 0 || deathTime > 0` (`CreakingRenderer` clears it while tearing down; `EnderDragonRenderer` uses `hurtTime > 0`). Horizon already matches those conditions, and sets `hurtTime` to 10 on hurt. - `CreeperRenderer.getWhiteOverlayProgress`: `(int) (swelling * 10) % 2 == 0 ? 0 : clamp(swelling, 0.5, 1)`. Layers (e.g. the charged swirl, wool) use `getOverlayCoords(state, 0)`: red only. - `entity.fsh` mixes the overlay texel over the lit texture, then multiplies by the lightmap (#117). ## The change - `overlay.rs`: the OverlayTexture texels and the overlay codes (`living(white, red)`, `creeper_progress`), prepended to `entity.wgsl` as WGSL constants (`HURT_OVERLAY`, `WHITE_OVERLAY_ALPHA[16]`). Codes 16..=31 are the white row's columns 0..=15; TNT keeps code 5 (column 15). - `mobs/render.rs`: the body of a swelling creeper carries its white column; layers and extras keep the red only. `creeper_swelling` is `Creeper.getSwelling`; the scale wobble uses it unclamped. ## How tested - Unit tests: the 16 white alphas and the hurt texel equal the values printed by the 26.3 JVM (`255, 242, 229, 216, 203, 191, 178, 165, 152, 140, 127, 114, 101, 89, 76, 63`, `b2ff0000`); creeper swelling → column for 12 swellings, compared with the JVM (e.g. 0.55 → 8, 0.95 → 14, 1.0 → 0); red wins over white. `entity_shader_validates_with_its_overlay_constants` parses and validates the composed shader with naga (dev-dependency, already built for wgpu). - vscreen, same scene as #117 with this build (a sheep and a husk, NoAI, `/damage`; daylight, midnight, a closed stone box). Per-pixel check against `entity.fsh` (`tools`-free script `~/code/horizon-parity/screens/hurt-tint/check_formula.py`): for every changed pixel, G and B are 0.698 × unhurt (mean error 0.36–0.50 levels), and the red added is 77 × the lightmap: median **76.9** in daylight, **21.0** at night, **6.2** in the box (p1–p99 75.7–77.6, 19.6–21.8, 3.9–7.6). Before #117 it was 52.8 / 52.6 / 44.0 with a 6–77 spread: the red did not follow the light. Frames: `~/code/horizon-parity/screens/hurt-tint/final-{day,night,box}-{hurt,unhurt}.png` on ludodesktop. - The creeper flash itself is covered by the unit tests, not by a screenshot. - `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings` clean, `cargo test -p horizon-client --lib` 412 passed (Mac mini); `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:05 +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#2337
No description provided.