[PR #117] [MERGED] Apply the entity hurt and white-flash overlay in vanilla's order #2334

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

📋 Pull Request Information

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

Base: main ← Head: fix/hurt-tint-order


📝 Commits (1)

  • a3d3297 Apply the entity hurt/white overlay in vanilla's order

📊 Changes

4 files changed (+35 additions, -34 deletions)

View changed files

📝 crates/horizon-client/src/entity.wgsl (+24 -12)
📝 crates/horizon-client/src/game/minecarts.rs (+2 -2)
📝 crates/horizon-client/src/game/mob_blocks.rs (+3 -12)
📝 crates/horizon-client/src/mobs/render.rs (+6 -8)

📄 Description

What was wrong

entity.wgsl multiplied the vertex colour by the lightmap first, then by the cardinal light, then mixed a fixed 30 % red into the vertex colour (hurt), and the fragment multiplied the texture by it. So the hurt red was modulated by the texture and never darkened by the lightmap: hurt mobs glowed red at night and in caves. The primed-TNT white flash was a fixed 0.75 mix after texturing, also unlit.

What vanilla does

Shipped shaders core/entity.vsh / core/entity.fsh and include/light.glsl:

  • vertex: vertexColor = minecraft_mix_light(Light0, Light1, Normal, Color) (cardinal light only); lightMapColor = sample_lightmap(Sampler2, UV2); overlayColor = texelFetch(Sampler1, UV1), all passed separately;
  • fragment: color = texture × vertexColor × ColorModulator, then calculateFinalColor: color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a) then color *= lightMapColor, then glint and fog.
  • OverlayTexture: rows 0–7 are the hurt red 0xB2FF0000 (alpha 178/255, so 30.2 % red), row 10 is white with alpha (1 − u/15 × 0.75), i.e. 63/255 for the TNT flash (OverlayTexture.u(1.0)).

The change

  • entity.wgsl: the vertex stage passes the lightmap colour and the overlay texel (overlay_texel: exact 178/255 hurt red, 63/255 white) to the fragment stage, which mixes the overlay over the textured, cardinal-lit colour, then multiplies by the lightmap, then glint and fog, as entity.fsh. Unlit kinds (celestial, clouds, beacon beams, End portal, breaking cracks) get a light colour of 1. Per-face front/back colours are kept.
  • Layers vanilla submits with OverlayTexture.NO_OVERLAY no longer take the hurt tint: armour (EquipmentLayerRenderer, glint kept), held items (ItemInHandLayer) and the enderman's carried block (CarriedBlockLayer).
  • The TNT minecart flash uses the white overlay on the cart's own light (TntMinecartRenderer.submitWhiteSolidBlock) instead of plain full-bright white.

How tested

Same scene before/after on a vscreen (a sheep and a husk, NoAI, hurt with /damage), in daylight, at night and in a closed dark box. Mean colour of the mob's pixels (R, G, B):

scene before, hurt after, hurt unhurt (before = after)
day, sheep 166.6, 94.9, 92.0 176.4, 94.8, 91.7 142.5, 135.4, 131.1
night, sheep 93.8, 25.9, 45.9 48.3, 25.7, 45.8 39.0, 37.0, 65.5
dark box, sheep 71.2, 8.1, 8.0 14.6, 8.1, 8.0 11.9, 11.5, 11.3
dark box, husk 48.3, 5.7, 4.3 12.5, 5.7, 4.3 9.0, 8.1, 5.9

In shade the red is now darkened with the mob as in vanilla (it was a bright red glow); in daylight the red is the exact 178/255 mix over the texture; unhurt mobs are unchanged. Screenshots: ~/code/horizon-parity/screens/hurt-tint/{before,after}-{day,night,box}-{hurt,unhurt}.png (numbers in numbers.json) on ludodesktop.

cargo fmt --check, cargo clippy --workspace --all-targets -D warnings clean, cargo test -p horizon-client --lib 409 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/117 **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/hurt-tint-order` --- ### 📝 Commits (1) - [`a3d3297`](https://github.com/horizon-rust/horizon/commit/a3d32978407cead17b8749cbc739fdc7e6be885a) Apply the entity hurt/white overlay in vanilla's order ### 📊 Changes **4 files changed** (+35 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity.wgsl` (+24 -12) 📝 `crates/horizon-client/src/game/minecarts.rs` (+2 -2) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+3 -12) 📝 `crates/horizon-client/src/mobs/render.rs` (+6 -8) </details> ### 📄 Description ## What was wrong `entity.wgsl` multiplied the vertex colour by the lightmap first, then by the cardinal light, then mixed a fixed 30 % red into the **vertex** colour (hurt), and the fragment multiplied the texture by it. So the hurt red was modulated by the texture and **never darkened by the lightmap**: hurt mobs glowed red at night and in caves. The primed-TNT white flash was a fixed 0.75 mix after texturing, also unlit. ## What vanilla does Shipped shaders `core/entity.vsh` / `core/entity.fsh` and `include/light.glsl`: - vertex: `vertexColor = minecraft_mix_light(Light0, Light1, Normal, Color)` (cardinal light only); `lightMapColor = sample_lightmap(Sampler2, UV2)`; `overlayColor = texelFetch(Sampler1, UV1)`, all passed separately; - fragment: `color = texture × vertexColor × ColorModulator`, then `calculateFinalColor`: `color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a)` **then** `color *= lightMapColor`, then glint and fog. - `OverlayTexture`: rows 0–7 are the hurt red `0xB2FF0000` (alpha 178/255, so 30.2 % red), row 10 is white with alpha `(1 − u/15 × 0.75)`, i.e. 63/255 for the TNT flash (`OverlayTexture.u(1.0)`). ## The change - `entity.wgsl`: the vertex stage passes the lightmap colour and the overlay texel (`overlay_texel`: exact 178/255 hurt red, 63/255 white) to the fragment stage, which mixes the overlay over the textured, cardinal-lit colour, then multiplies by the lightmap, then glint and fog, as `entity.fsh`. Unlit kinds (celestial, clouds, beacon beams, End portal, breaking cracks) get a light colour of 1. Per-face front/back colours are kept. - Layers vanilla submits with `OverlayTexture.NO_OVERLAY` no longer take the hurt tint: armour (`EquipmentLayerRenderer`, glint kept), held items (`ItemInHandLayer`) and the enderman's carried block (`CarriedBlockLayer`). - The TNT minecart flash uses the white overlay on the cart's own light (`TntMinecartRenderer.submitWhiteSolidBlock`) instead of plain full-bright white. ## How tested Same scene before/after on a vscreen (a sheep and a husk, `NoAI`, hurt with `/damage`), in daylight, at night and in a closed dark box. Mean colour of the mob's pixels (R, G, B): | scene | before, hurt | after, hurt | unhurt (before = after) | |---|---|---|---| | day, sheep | 166.6, 94.9, 92.0 | 176.4, 94.8, 91.7 | 142.5, 135.4, 131.1 | | night, sheep | 93.8, 25.9, 45.9 | 48.3, 25.7, 45.8 | 39.0, 37.0, 65.5 | | dark box, sheep | 71.2, 8.1, 8.0 | 14.6, 8.1, 8.0 | 11.9, 11.5, 11.3 | | dark box, husk | 48.3, 5.7, 4.3 | 12.5, 5.7, 4.3 | 9.0, 8.1, 5.9 | In shade the red is now darkened with the mob as in vanilla (it was a bright red glow); in daylight the red is the exact 178/255 mix over the texture; unhurt mobs are unchanged. Screenshots: `~/code/horizon-parity/screens/hurt-tint/{before,after}-{day,night,box}-{hurt,unhurt}.png` (numbers in `numbers.json`) on ludodesktop. `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings` clean, `cargo test -p horizon-client --lib` 409 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:02 +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#2334
No description provided.