[PR #5619] [MERGED] Shader API: [[materials]], an id by sprite, and shadows cut whole #6391

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5619
Author: @Teiwazik
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: shader/s9-materials


📝 Commits (10+)

  • 3ab39ea Merge remote-tracking branch 'origin/main' into shader/s8-shadow-entities
  • b1d6819 Native mods: the screen hears of the wheel before it scrolls
  • 43207a5 Shader API: entities cast into the shadow map
  • c901615 Merge branch 'screen-mouse-button' into screen-mouse-scrolled
  • 11cd3f2 Shader API: the first-person player casts into the shadow map
  • bbbb185 Shader API: materials, an id by sprite, and shadows cut whole
  • e26bd0f feat(mods): native mods use items over time (duration, animation, can eat, start and finish)
  • 753c565 Shader API: the blob stays where a pack has no sun to cast with
  • ddadcb2 Merge branch 'shader/s8b-player-shadow' into shader/s9-materials
  • f11233f Shader API: solid_materials work without a material stage

📊 Changes

75 files changed (+2487 additions, -359 deletions)

View changed files

📝 crates/horizon-client-render/src/containers.rs (+62 -0)
📝 crates/horizon-client-render/src/fast_hash.rs (+3 -85)
📝 crates/horizon-client-render/src/gfx.rs (+43 -10)
📝 crates/horizon-client-render/src/gfx/entity_batch.rs (+5 -0)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+37 -17)
📝 crates/horizon-client-render/src/gfx/native_pack.rs (+1 -1)
📝 crates/horizon-client-render/src/gfx/native_shadow.rs (+180 -8)
📝 crates/horizon-client-render/src/streaming.rs (+13 -4)
📝 crates/horizon-client/src/content_identity.rs (+31 -3)
📝 crates/horizon-client/src/entity_nbt.rs (+42 -2)
📝 crates/horizon-client/src/game.rs (+120 -43)
📝 crates/horizon-client/src/game/chat.rs (+3 -0)
📝 crates/horizon-client/src/game/commands.rs (+25 -11)
📝 crates/horizon-client/src/game/creatures.rs (+9 -2)
📝 crates/horizon-client/src/game/crossbow.rs (+2 -4)
📝 crates/horizon-client/src/game/end.rs (+1 -3)
📝 crates/horizon-client/src/game/entity_culling.rs (+3 -0)
📝 crates/horizon-client/src/game/fov.rs (+1 -2)
📝 crates/horizon-client/src/game/item_draw.rs (+5 -2)
➕ crates/horizon-client/src/game/item_use.rs (+218 -0)

...and 55 more files

📄 Description

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

Closes #5618.

Stacked on #5590 (and so #5476 and #5461), which should merge first; until then this diff shows them too. Only the last commit is new here.

What

  • [[materials]]: id (1 to 65535, entries may share one) and sprites, with any number of *. A sprite takes the id of the first entry that names it, MaterialInput.material reads it, 0 without one. Identical stills sharing a layer take the earliest entry any of their names matches, so the result doesn't hang on the order of the names.
  • [shadow] solid_materials: those ids go into the shadow map without their cutouts. An id no entry declares is refused at load.
  • SpriteTag::matches and materials share one matcher; a pattern with one * matches as before, and tags keep their limit of one.

Why ids next to tags

Tags are for "is it one of these", and stop at 32. The ids reuse the tags' mechanism, a generated switch over the sprite layer, so there is no new binding or buffer and no new public resource. The trade-off: a pack with many entries has a long switch in its fragment shader. I haven't measured that with hundreds of entries. It can become a table later without touching the pack API, since packs only see input.material.

Proof

Checked in game on Linux (RTX 3050 Ti) in single player, with a throwaway pack that tints input.material == 10 red and darkens by the shadow map. The scene is a layer of oak trapdoors, block/oak_trapdoor as id 10, above a stone floor at time set 4000:

  • with solid_materials = [10]: trapdoors red, and their shadow is a solid dark rectangle.
  • with solid_materials = []: trapdoors red, and the shadow shows the trapdoors' holes as a grid of lit dots.

No screenshots attached: they'd have to be committed to upload, and they show Mojang textures.

Not run: lan_e2e and the parity harnesses. No API version bump, it is additive. Not measured: frame time against a pack with hundreds of entries.

pr_ready (tools/pr_ready.py --quick on teiwazik-laptop, against origin/main at c9d8e3efa, 6 min 27 s)

Check Result
Scope ⚠️ 23 files, +1402 −70; 1339 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (35 s)
rustfmt ✅ (9 s)
clippy ✅ (25 s)
tests: horizon-client, horizon-client-render, horizon-shader-api, horizon-shaders ✅ 2518 passed (5 min 15 s)
doc tests ✅ 0 passed (3 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EBqm1v5zTsDGwuZF6XKFjL


🔄 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/5619 **Author:** [@Teiwazik](https://github.com/Teiwazik) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shader/s9-materials` --- ### 📝 Commits (10+) - [`3ab39ea`](https://github.com/horizon-rust/horizon/commit/3ab39ea98415cf91cbf58af324e3afcc87f8260c) Merge remote-tracking branch 'origin/main' into shader/s8-shadow-entities - [`b1d6819`](https://github.com/horizon-rust/horizon/commit/b1d6819737cabae0cda4c11268d1dfc9954cb652) Native mods: the screen hears of the wheel before it scrolls - [`43207a5`](https://github.com/horizon-rust/horizon/commit/43207a5a3d6afeee0061ed6aef9c68dcd0ce8d24) Shader API: entities cast into the shadow map - [`c901615`](https://github.com/horizon-rust/horizon/commit/c90161511b9404e22911a177208490b058d15e0f) Merge branch 'screen-mouse-button' into screen-mouse-scrolled - [`11cd3f2`](https://github.com/horizon-rust/horizon/commit/11cd3f220d91b1b99febea60ce035150bd8996b8) Shader API: the first-person player casts into the shadow map - [`bbbb185`](https://github.com/horizon-rust/horizon/commit/bbbb18595fdb024b76a7dda8e78a2ce92c7ad0dc) Shader API: [[materials]], an id by sprite, and shadows cut whole - [`e26bd0f`](https://github.com/horizon-rust/horizon/commit/e26bd0fe58f0cb465b60f7bc5712fb5a08ca5507) feat(mods): native mods use items over time (duration, animation, can eat, start and finish) - [`753c565`](https://github.com/horizon-rust/horizon/commit/753c565883ce75bbfd9624ad53ed0de157a0c59b) Shader API: the blob stays where a pack has no sun to cast with - [`ddadcb2`](https://github.com/horizon-rust/horizon/commit/ddadcb2203db1760074dd9be0abac4ac1ce80a69) Merge branch 'shader/s8b-player-shadow' into shader/s9-materials - [`f11233f`](https://github.com/horizon-rust/horizon/commit/f11233f125b8904fbcc79358137ecc0a7d3e58c3) Shader API: solid_materials work without a material stage ### 📊 Changes **75 files changed** (+2487 additions, -359 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/containers.rs` (+62 -0) 📝 `crates/horizon-client-render/src/fast_hash.rs` (+3 -85) 📝 `crates/horizon-client-render/src/gfx.rs` (+43 -10) 📝 `crates/horizon-client-render/src/gfx/entity_batch.rs` (+5 -0) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+37 -17) 📝 `crates/horizon-client-render/src/gfx/native_pack.rs` (+1 -1) 📝 `crates/horizon-client-render/src/gfx/native_shadow.rs` (+180 -8) 📝 `crates/horizon-client-render/src/streaming.rs` (+13 -4) 📝 `crates/horizon-client/src/content_identity.rs` (+31 -3) 📝 `crates/horizon-client/src/entity_nbt.rs` (+42 -2) 📝 `crates/horizon-client/src/game.rs` (+120 -43) 📝 `crates/horizon-client/src/game/chat.rs` (+3 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+25 -11) 📝 `crates/horizon-client/src/game/creatures.rs` (+9 -2) 📝 `crates/horizon-client/src/game/crossbow.rs` (+2 -4) 📝 `crates/horizon-client/src/game/end.rs` (+1 -3) 📝 `crates/horizon-client/src/game/entity_culling.rs` (+3 -0) 📝 `crates/horizon-client/src/game/fov.rs` (+1 -2) 📝 `crates/horizon-client/src/game/item_draw.rs` (+5 -2) ➕ `crates/horizon-client/src/game/item_use.rs` (+218 -0) _...and 55 more files_ </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Closes #5618. Stacked on #5590 (and so #5476 and #5461), which should merge first; until then this diff shows them too. Only the last commit is new here. ## What - `[[materials]]`: `id` (1 to 65535, entries may share one) and `sprites`, with any number of `*`. A sprite takes the id of the first entry that names it, `MaterialInput.material` reads it, 0 without one. Identical stills sharing a layer take the earliest entry any of their names matches, so the result doesn't hang on the order of the names. - `[shadow] solid_materials`: those ids go into the shadow map without their cutouts. An id no entry declares is refused at load. - `SpriteTag::matches` and materials share one matcher; a pattern with one `*` matches as before, and tags keep their limit of one. ## Why ids next to tags Tags are for "is it one of these", and stop at 32. The ids reuse the tags' mechanism, a generated `switch` over the sprite layer, so there is no new binding or buffer and no new public resource. The trade-off: a pack with many entries has a long `switch` in its fragment shader. I haven't measured that with hundreds of entries. It can become a table later without touching the pack API, since packs only see `input.material`. ## Proof Checked in game on Linux (RTX 3050 Ti) in single player, with a throwaway pack that tints `input.material == 10` red and darkens by the shadow map. The scene is a layer of oak trapdoors, `block/oak_trapdoor` as id 10, above a stone floor at `time set 4000`: - with `solid_materials = [10]`: trapdoors red, and their shadow is a solid dark rectangle. - with `solid_materials = []`: trapdoors red, and the shadow shows the trapdoors' holes as a grid of lit dots. No screenshots attached: they'd have to be committed to upload, and they show Mojang textures. Not run: `lan_e2e` and the parity harnesses. No API version bump, it is additive. Not measured: frame time against a pack with hundreds of entries. **pr_ready** (`tools/pr_ready.py --quick` on teiwazik-laptop, against origin/main at c9d8e3efa, 6 min 27 s) | Check | Result | | --- | --- | | Scope | ⚠️ 23 files, +1402 −70; 1339 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (35 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (25 s) | | tests: horizon-client, horizon-client-render, horizon-shader-api, horizon-shaders | ✅ 2518 passed (5 min 15 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EBqm1v5zTsDGwuZF6XKFjL --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:19:50 +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#6391
No description provided.