[PR #5894] [MERGED] Shader API: the material stage reads its own block texture #6546

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

📋 Pull Request Information

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

Base: main ← Head: shader/block-texture


📝 Commits (10+)

  • 48b3388 fix(portals): transfer mobs and falling blocks through End portals
  • 8860e92 No durability bar on an unbreakable item
  • e3fcbf1 Keep unbreakable when syncing an inventory stack
  • e7f99e7 Block states: compact properties with shared strings
  • 49e08de Block states: a palette entry's properties collect in one pass
  • b6709fe Block states: facts.json reads properties straight into shared strings
  • 2daf81f Fix filled shulker box drops in Creative
  • 8f2e53a Launcher: give each memory store its own account lock
  • e241409 Clear a recycled mesh's light sources
  • d44fb43 Block states: shared property strings are the process's, not counted

📊 Changes

55 files changed (+1846 additions, -174 deletions)

View changed files

📝 crates/horizon-anticheat/src/prediction.rs (+5 -0)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+26 -4)
📝 crates/horizon-client-render/src/mesher.rs (+2 -0)
📝 crates/horizon-client-render/src/streaming.rs (+2 -0)
📝 crates/horizon-client/examples/mod_port_probe.rs (+1 -1)
📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+1 -1)
📝 crates/horizon-client/examples/probe/spawn_rules_fixture.rs (+1 -1)
📝 crates/horizon-client/src/block_entity_item.rs (+20 -13)
📝 crates/horizon-client/src/game.rs (+55 -22)
📝 crates/horizon-client/src/game/block_items.rs (+25 -0)
📝 crates/horizon-client/src/game/blockctl.rs (+4 -1)
📝 crates/horizon-client/src/game/command_harness.rs (+32 -1)
📝 crates/horizon-client/src/game/falling_damage.rs (+13 -6)
📝 crates/horizon-client/src/game/lan_actions.rs (+163 -6)
📝 crates/horizon-client/src/game/levels.rs (+4 -0)
📝 crates/horizon-client/src/game/machines/native_fluids.rs (+1 -1)
📝 crates/horizon-client/src/game/native_falling.rs (+1 -0)
📝 crates/horizon-client/src/game/nether_portal.rs (+58 -5)
📝 crates/horizon-client/src/game/persist.rs (+14 -4)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+1 -0)

...and 35 more files

📄 Description

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

Fixes #5893.

What

The material prelude gains four functions over the surface's own sprite:

  • block_texture(uv): the texture at any uv of the sprite, without the tint, at this point's mip level.
  • block_texture_level(uv, lod): the same at a chosen mip level.
  • block_texture_size(): its size in texels.
  • block_texture_lod(): the mip level block_texture reads here.

A change to existing functions

block_normal_map_level and block_specular_map_level took a mip level of the map. They now take one of the block texture, so one lod means the same footprint on the surface where a map is smaller than the texture. block_normal_map and block_specular_map keep the same footprint as before. With maps the same size as the texture nothing changes. This is an API 0.1 addition from today's series, noted in the changelog; a pack passing a map's own level to a smaller map would read a sharper mip.

Cost

Only a pack that calls these functions samples anything more. The prelude's two extra functions are compiled into native material stages only.

Proof

  • a_material_reads_its_block_texture checks a material using all four. The reference is regenerated.
  • In game, single player, a debug pack on a cobblestone floor in three bands (shader pack stack_proof 0.1.0: material.wgsl in 173 ms, no validation error):
    • abs(block_texture(uv) - input.albedo) * 8: near black, so the two agree.
    • block_texture_level(uv, 4.0): visibly smoother than the base texture.
    • block_texture_size().x / 64 in red, block_texture_lod() / 4 in green: a solid yellow from high up, as this install's resource pack is over 64 texels a side and the view is far from the blocks.
  • Not tested: the LabPBR _level change with maps smaller than the texture. No screenshot attached: it would show Mojang's textures.

pr_ready (tools/pr_ready.py --quick on teiwazik-laptop, against origin/main at 9543d2a68, 1 min 49 s)

Check Result
Scope ✅ 6 files, +85 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (42 s)
rustfmt ✅ (10 s)
clippy ✅ (34 s)
tests: horizon-client-render, horizon-shader-api ✅ 879 passed (22 s)
doc tests ✅ 0 passed (1 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/5894 **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/block-texture` --- ### 📝 Commits (10+) - [`48b3388`](https://github.com/horizon-rust/horizon/commit/48b338836f006c306ecc59d802decfd6aaa6f89c) fix(portals): transfer mobs and falling blocks through End portals - [`8860e92`](https://github.com/horizon-rust/horizon/commit/8860e928fc73117f21ae41b54cd2fc6201d8685a) No durability bar on an unbreakable item - [`e3fcbf1`](https://github.com/horizon-rust/horizon/commit/e3fcbf1b3cca04b1ce3abd5d55ce50f848b9834c) Keep unbreakable when syncing an inventory stack - [`e7f99e7`](https://github.com/horizon-rust/horizon/commit/e7f99e7ce17dbae500b7a802508fa37b1a432035) Block states: compact properties with shared strings - [`49e08de`](https://github.com/horizon-rust/horizon/commit/49e08de26d4710700f2468fadcae862ceeec6571) Block states: a palette entry's properties collect in one pass - [`b6709fe`](https://github.com/horizon-rust/horizon/commit/b6709fee4fb8854c068cf8da4e2e1ee6fb548cff) Block states: facts.json reads properties straight into shared strings - [`2daf81f`](https://github.com/horizon-rust/horizon/commit/2daf81f4873f81ffe65e842610af2799b4fd5a61) Fix filled shulker box drops in Creative - [`8f2e53a`](https://github.com/horizon-rust/horizon/commit/8f2e53a9667d1fd4fd3889f049f13ed2f32007c1) Launcher: give each memory store its own account lock - [`e241409`](https://github.com/horizon-rust/horizon/commit/e241409e65d30dbe2d1104633abef3410a3eee58) Clear a recycled mesh's light sources - [`d44fb43`](https://github.com/horizon-rust/horizon/commit/d44fb4367a6423a17b9feca068d78c0e2534934c) Block states: shared property strings are the process's, not counted ### 📊 Changes **55 files changed** (+1846 additions, -174 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-anticheat/src/prediction.rs` (+5 -0) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+26 -4) 📝 `crates/horizon-client-render/src/mesher.rs` (+2 -0) 📝 `crates/horizon-client-render/src/streaming.rs` (+2 -0) 📝 `crates/horizon-client/examples/mod_port_probe.rs` (+1 -1) 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+1 -1) 📝 `crates/horizon-client/examples/probe/spawn_rules_fixture.rs` (+1 -1) 📝 `crates/horizon-client/src/block_entity_item.rs` (+20 -13) 📝 `crates/horizon-client/src/game.rs` (+55 -22) 📝 `crates/horizon-client/src/game/block_items.rs` (+25 -0) 📝 `crates/horizon-client/src/game/blockctl.rs` (+4 -1) 📝 `crates/horizon-client/src/game/command_harness.rs` (+32 -1) 📝 `crates/horizon-client/src/game/falling_damage.rs` (+13 -6) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+163 -6) 📝 `crates/horizon-client/src/game/levels.rs` (+4 -0) 📝 `crates/horizon-client/src/game/machines/native_fluids.rs` (+1 -1) 📝 `crates/horizon-client/src/game/native_falling.rs` (+1 -0) 📝 `crates/horizon-client/src/game/nether_portal.rs` (+58 -5) 📝 `crates/horizon-client/src/game/persist.rs` (+14 -4) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+1 -0) _...and 35 more files_ </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #5893. ## What The material prelude gains four functions over the surface's own sprite: - `block_texture(uv)`: the texture at any `uv` of the sprite, without the tint, at this point's mip level. - `block_texture_level(uv, lod)`: the same at a chosen mip level. - `block_texture_size()`: its size in texels. - `block_texture_lod()`: the mip level `block_texture` reads here. ## A change to existing functions `block_normal_map_level` and `block_specular_map_level` took a mip level of the map. They now take one of the block texture, so one `lod` means the same footprint on the surface where a map is smaller than the texture. `block_normal_map` and `block_specular_map` keep the same footprint as before. With maps the same size as the texture nothing changes. This is an API 0.1 addition from today's series, noted in the changelog; a pack passing a map's own level to a smaller map would read a sharper mip. ## Cost Only a pack that calls these functions samples anything more. The prelude's two extra functions are compiled into native material stages only. ## Proof - `a_material_reads_its_block_texture` checks a material using all four. The reference is regenerated. - In game, single player, a debug pack on a cobblestone floor in three bands (`shader pack stack_proof 0.1.0: material.wgsl in 173 ms`, no validation error): - `abs(block_texture(uv) - input.albedo) * 8`: near black, so the two agree. - `block_texture_level(uv, 4.0)`: visibly smoother than the base texture. - `block_texture_size().x / 64` in red, `block_texture_lod() / 4` in green: a solid yellow from high up, as this install's resource pack is over 64 texels a side and the view is far from the blocks. - Not tested: the LabPBR `_level` change with maps smaller than the texture. No screenshot attached: it would show Mojang's textures. **pr_ready** (`tools/pr_ready.py --quick` on teiwazik-laptop, against origin/main at 9543d2a68, 1 min 49 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +85 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (42 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (34 s) | | tests: horizon-client-render, horizon-shader-api | ✅ 879 passed (22 s) | | doc tests | ✅ 0 passed (1 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:22: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#6546
No description provided.