[PR #5819] [MERGED] Shader API: the material stage reads resource packs' LabPBR maps #6504

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

📋 Pull Request Information

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

Base: main ← Head: shader/labpbr


📝 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
  • 622786d Shader packs: pages, the layout of a Horizon pack's options page
  • fbf8c46 Shader API: [sky] clouds, sun and stars, for a sky that draws its own
  • e26bd0f feat(mods): native mods use items over time (duration, animation, can eat, start and finish)
  • 000eb64 Shader API: the [weather] stage colours rain and snow streaks

📊 Changes

62 files changed (+3587 additions, -412 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/src/assets.rs (+8 -0)
📝 crates/horizon-client-render/src/gfx.rs (+185 -16)
➕ crates/horizon-client-render/src/gfx/block_light.rs (+224 -0)
📝 crates/horizon-client-render/src/gfx/entity_batch.rs (+5 -0)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+79 -19)
📝 crates/horizon-client-render/src/gfx/native_pack.rs (+48 -4)
📝 crates/horizon-client-render/src/gfx/native_post.rs (+338 -121)
📝 crates/horizon-client-render/src/gfx/native_shadow.rs (+180 -8)
📝 crates/horizon-client-render/src/gfx/native_sky.rs (+1 -1)
📝 crates/horizon-client-render/src/gfx/weather.rs (+169 -2)
📝 crates/horizon-client-render/src/graphics.rs (+10 -1)
📝 crates/horizon-client-render/src/hud.rs (+6 -0)
📝 crates/horizon-client-render/src/mesher.rs (+8 -0)
📝 crates/horizon-client-render/src/options_ui.rs (+117 -44)
📝 crates/horizon-client-render/src/shader_pack_list.rs (+9 -3)
📝 crates/horizon-client-render/src/sprites.rs (+243 -41)
📝 crates/horizon-client/src/entity_nbt.rs (+42 -2)
📝 crates/horizon-client/src/game.rs (+107 -41)
📝 crates/horizon-client/src/game/chat.rs (+3 -0)

...and 42 more files

📄 Description

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

Fixes #5818.

What

  • Sprites loads the _n and _s maps beside each block texture (the first frame of an animated one) and lays them out as two arrays, one size for all layers, at most 64 MiB each at the top mip level. A layer without a map gets LabPBR's neutral value. Their mips are plain means, since the channels are data.
  • The material prelude gains block_pbr_maps(), block_normal_map(uv), block_specular_map(uv), their _level(uv, lod) forms and block_pbr_size(). The arrays sit at bindings 12 and 13 of group 3, which a pack doesn't declare itself.
  • The GUI atlas skips _n and _s images that sit beside a texture of the same name.
  • build_renderer now always makes PreparedTextures through prepare_renderer_textures, because the renderer's own fallback has no maps. Without this the arrays stayed blank.

Cost for people not using a native pack

A resource pack with maps now costs video memory and load time even when no native pack reads them: up to about 170 MiB for both arrays with mips, plus decoding the maps. A pack without maps costs a 1x1 blank only when a native pack is active. I kept it simple rather than loading maps on demand, because a pack switch would then need a resource reload. Say if you'd rather have that.

Proof

Tests: a_labpbr_map_shrinks_by_plain_means_and_a_layer_without_one_gets_the_default, textures_without_labpbr_maps_keep_none; the_terrain_takes_a_prefix_and_validates_with_a_pack validates the material shader with the bindings.

In game on Linux (RTX 3050 Ti), single player, with a throwaway resource pack giving block/stone a striped stone_n.png and a half-green stone_s.png, and a debug material showing block_normal_map(uv).x as red, block_specular_map(uv).y as green and block_pbr_maps() as blue, looking straight down at a floor half stone, half oak planks:

  • The log says Horizon: LabPBR maps at 16 px, 1291 layers.
  • Stone shows the normal map's stripes and the specular map's half, in each block's own rotation.
  • Oak planks, which have no maps, show the neutral values evenly: red 0.5, green 0.

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

Not checked: a real LabPBR pack on this branch (it has run on a local build with one), animated textures with maps, the OpenGL backend, and lan_e2e (client-only rendering).

pr_ready (tools/pr_ready.py --quick on teiwazik-laptop, against origin/main at b4e123280, 8 min 19 s)

Check Result
Scope ⚠️ 14 files, +485 −48; 527 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 511 passed (37 s)
rustfmt ✅ (8 s)
clippy ✅ (30 s)
tests: horizon-client, horizon-client-render, horizon-shader-api ✅ 2518 passed (5 min 18 s)
doc tests ✅ 0 passed (3 s)
content root tests ✅ 20 passed (1 min 43 s)
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/5819 **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/labpbr` --- ### 📝 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 - [`622786d`](https://github.com/horizon-rust/horizon/commit/622786d90317822ff09249426417b3af4a8ef9f2) Shader packs: [[pages]], the layout of a Horizon pack's options page - [`fbf8c46`](https://github.com/horizon-rust/horizon/commit/fbf8c46b8e6834bf3faf0885ddc9718a421f5b41) Shader API: [sky] clouds, sun and stars, for a sky that draws its own - [`e26bd0f`](https://github.com/horizon-rust/horizon/commit/e26bd0fe58f0cb465b60f7bc5712fb5a08ca5507) feat(mods): native mods use items over time (duration, animation, can eat, start and finish) - [`000eb64`](https://github.com/horizon-rust/horizon/commit/000eb647aaec5f178d89741ed56637797b8951a6) Shader API: the [weather] stage colours rain and snow streaks ### 📊 Changes **62 files changed** (+3587 additions, -412 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/src/assets.rs` (+8 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+185 -16) ➕ `crates/horizon-client-render/src/gfx/block_light.rs` (+224 -0) 📝 `crates/horizon-client-render/src/gfx/entity_batch.rs` (+5 -0) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+79 -19) 📝 `crates/horizon-client-render/src/gfx/native_pack.rs` (+48 -4) 📝 `crates/horizon-client-render/src/gfx/native_post.rs` (+338 -121) 📝 `crates/horizon-client-render/src/gfx/native_shadow.rs` (+180 -8) 📝 `crates/horizon-client-render/src/gfx/native_sky.rs` (+1 -1) 📝 `crates/horizon-client-render/src/gfx/weather.rs` (+169 -2) 📝 `crates/horizon-client-render/src/graphics.rs` (+10 -1) 📝 `crates/horizon-client-render/src/hud.rs` (+6 -0) 📝 `crates/horizon-client-render/src/mesher.rs` (+8 -0) 📝 `crates/horizon-client-render/src/options_ui.rs` (+117 -44) 📝 `crates/horizon-client-render/src/shader_pack_list.rs` (+9 -3) 📝 `crates/horizon-client-render/src/sprites.rs` (+243 -41) 📝 `crates/horizon-client/src/entity_nbt.rs` (+42 -2) 📝 `crates/horizon-client/src/game.rs` (+107 -41) 📝 `crates/horizon-client/src/game/chat.rs` (+3 -0) _...and 42 more files_ </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #5818. ## What - `Sprites` loads the `_n` and `_s` maps beside each block texture (the first frame of an animated one) and lays them out as two arrays, one size for all layers, at most 64 MiB each at the top mip level. A layer without a map gets LabPBR's neutral value. Their mips are plain means, since the channels are data. - The material prelude gains `block_pbr_maps()`, `block_normal_map(uv)`, `block_specular_map(uv)`, their `_level(uv, lod)` forms and `block_pbr_size()`. The arrays sit at bindings 12 and 13 of group 3, which a pack doesn't declare itself. - The GUI atlas skips `_n` and `_s` images that sit beside a texture of the same name. - `build_renderer` now always makes `PreparedTextures` through `prepare_renderer_textures`, because the renderer's own fallback has no maps. Without this the arrays stayed blank. ## Cost for people not using a native pack **A resource pack with maps now costs video memory and load time even when no native pack reads them**: up to about 170 MiB for both arrays with mips, plus decoding the maps. A pack without maps costs a 1x1 blank only when a native pack is active. I kept it simple rather than loading maps on demand, because a pack switch would then need a resource reload. Say if you'd rather have that. ## Proof Tests: `a_labpbr_map_shrinks_by_plain_means_and_a_layer_without_one_gets_the_default`, `textures_without_labpbr_maps_keep_none`; `the_terrain_takes_a_prefix_and_validates_with_a_pack` validates the material shader with the bindings. In game on Linux (RTX 3050 Ti), single player, with a throwaway resource pack giving `block/stone` a striped `stone_n.png` and a half-green `stone_s.png`, and a debug material showing `block_normal_map(uv).x` as red, `block_specular_map(uv).y` as green and `block_pbr_maps()` as blue, looking straight down at a floor half stone, half oak planks: - The log says `Horizon: LabPBR maps at 16 px, 1291 layers`. - Stone shows the normal map's stripes and the specular map's half, in each block's own rotation. - Oak planks, which have no maps, show the neutral values evenly: red 0.5, green 0. No screenshots attached: they'd have to be committed to upload, and the scene shows Mojang textures. Not checked: a real LabPBR pack on this branch (it has run on a local build with one), animated textures with maps, the OpenGL backend, and `lan_e2e` (client-only rendering). **pr_ready** (`tools/pr_ready.py --quick` on teiwazik-laptop, against origin/main at b4e123280, 8 min 19 s) | Check | Result | | --- | --- | | Scope | ⚠️ 14 files, +485 −48; 527 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (37 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (30 s) | | tests: horizon-client, horizon-client-render, horizon-shader-api | ✅ 2518 passed (5 min 18 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ✅ 20 passed (1 min 43 s) | | 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:21:45 +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#6504
No description provided.