[PR #1157] [MERGED] Shader packs: Steadfast, Bloop and Noble get past the preprocessor; a compatibility table #3103

Closed
opened 2026-11-02 16:01:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/shaderpack-compat


📝 Commits (3)

  • 21998a7 Shader packs: read pack sources as Iris's JCPP does; legalise what naga refuses
  • e570561 Shader packs: write narrow fragment outputs through a vec4
  • acbfb8c docs/shader-packs.md: the ten packs tested and what stops the rest

📊 Changes

7 files changed (+761 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/java_pack.rs (+39 -0)
📝 crates/horizon-shaderpack/src/preprocess.rs (+175 -5)
📝 crates/horizon-shaderpack/src/properties.rs (+62 -6)
📝 crates/horizon-shaderpack/src/translate.rs (+287 -5)
📝 crates/horizon-shaderpack/tests/pack.rs (+63 -0)
📝 crates/horizon-shaderpack/tests/translate.rs (+97 -0)
📝 docs/shader-packs.md (+38 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #616

The three packs in the report fail before a single pass is drawn. This PR fixes all three errors in horizon-shaderpack, makes Steadfast draw, and adds a compatibility table for the ten packs tested.

Thanks to Online5277 for the report and the exact error lines, and to satelitesatelitesatelite and furyfire0751_82832 for the reports on Discord. Ten packs were tested; the table in docs/shader-packs.md gives each result.

What was wrong

Iris preprocesses packs with JCPP, and Horizon used naga's pp-rs. The two disagree on things packs rely on:

Pack Error What Iris does Now
Steadfast 0.8.0 shaders.properties:1: UnexpectedToken(Float(0.5)) JCPP reads a float in #if as its integer part (ATMOSPHERE_FOG_STRENGTH_NOON == 0.5) same, in shaders.properties and in the GLSL sources
Bloop 1.8.0-Alpha-3 lib/specular.glsl:50: DefineRedefined a later #define replaces an earlier one same (#undef inserted before each redefinition)
Noble v1.9.9 unexpected identifier u16vec2 Noble uses 16-bit types when the GPU reports NVIDIA (NV_gpu_shader5) 16- and 8-bit types and pack/unpackFloat2x16 widened to their 32-bit forms (WGSL has none)

Once those three passed, more errors showed up behind them. These are fixed as well:

  • Steadfast's final writes out vec3. OpenGL fills the missing channel, but wgpu refuses the pipeline (Output format Float32x4 is incompatible with the shader Float32x3). Fragment outputs narrower than four channels are now written through a vec4 with alpha 1.
  • Empty operands and unterminated blocks now behave as in JCPP: an empty operand in #if counts as 0, an unterminated #if runs to the end of the file, and "/' in skipped #error lines no longer stop pp-rs.
  • shaders.properties keeps its empty lines and backslashes through the preprocessor, as Iris's does. Before, a \ continuation swallowed the next line: Complementary's isCold uniform was cut short, and it is now complete.
  • Constructs naga refuses:
    • % with a scalar and a vector operand now goes through overloads;
    • a const naga can't fold (mix, ?:, smoothstep) becomes a global set at the start of main;
    • sqrt of a negative constant is evaluated at run time.

Compatibility (tested 2026-10-22, Mac mini M4 Pro, default options)

Pack Before After
BSL v10.1.8 26 passes, drawn 26 passes, drawn (same picture)
Complementary Reimagined r5.9.3 27 passes, drawn 27 passes, drawn (same picture)
Complementary Unbound r5.8 27 passes 27 passes
Sildur's Vibrant 2.02 Extreme 18 passes 18 passes
Steadfast 0.8.0 UnexpectedToken(Float(0.5)) 3 passes, drawn
Bloop 1.8.0-Alpha-3 DefineRedefined gets further: mat2(vec4), which naga refuses
Noble v1.9.9 u16vec2 (on NVIDIA) gets further: a vec3[9][9] varying
Bliss 2.1.2 fails fails: an operation naga forbids in a vertex shader
Photon v1.4 fails fails: a struct varying
Rethinking Voxels r0.1-beta9 fails fails: 1 << 31 constant overflow; it also needs images

The packs that still fail need translator work that doesn't fit this PR. It is noted as one line in the agents' LATER list. Packs are dev-only test inputs: they were downloaded to a scratch folder outside the repository, and none is committed.

On furyfire0751_82832's report, Complementary's fog over Horizon's world is the pack's own fog. Without its gbuffers_* and shadow stages (not supported yet, see the doc), it draws over terrain that it didn't light. This PR does not change that.

Screenshots

Same fixed seed, camera and time, --offscreen + horizon-ctl screenshot. Left: main. Right: this PR merged with #1158.

Tree placement differs between runs of the same build, so compare the shading, not the trees.

main this PR
No pack
Complementary Reimagined
Complementary at dusk
BSL
Steadfast fails to load, vanilla picture drawn

I also checked for regressions without the screenshots:

  • The WGSL of every pass of BSL, Complementary Reimagined and Sildur's is byte-identical to main, apart from five Complementary programs that now use the iris_mod overloads.
  • The narrow-output change leaves all three packs' WGSL unchanged.

Self-check

Run on the Mac mini (macOS, M4 Pro):

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings (with set -o pipefail): exit 0.
  • cargo test -p horizon-shaderpack: 31 passed. New tests:
    • a_define_replaces_an_earlier_one;
    • conditions_read_as_jcpp_does;
    • floats_in_conditions_count_as_their_integer_part;
    • legalises_what_naga_refuses;
    • narrow_fragment_outputs_fill_four_channels.
  • cargo test -p horizon-client: 1,088 passed, 0 failed.
  • tools/parity.py --changed origin/main: run once over origin/main (5aff2980) with both F1 branches merged (#1157 and #1158).
    • 102 harnesses; 85 pass.
    • The other 17 fail the same way on plain main in the same checkout: ambient_sound, music, sound_engine, sound_event, resource_pack, online_mode, locator_bar, dedicated_server, secure_chat, user_cache, world_spawn and the server_* harnesses.
    • For example, ambient_sound stops at the same line 18011 on both. These are environment failures on this machine (the prepared resources have no registries.json, and a CI runner was running the server harnesses at the same time), not caused by these changes.
  • real_packs_load / real_packs_translate with HORIZON_TEST_SHADERPACKS over the ten packs: the five listed as loading load; the rest stop where the table says.

🤖 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/1157 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/shaderpack-compat` --- ### 📝 Commits (3) - [`21998a7`](https://github.com/horizon-rust/horizon/commit/21998a7e6ac1ca57b937a849d51ef67b0a87141f) Shader packs: read pack sources as Iris's JCPP does; legalise what naga refuses - [`e570561`](https://github.com/horizon-rust/horizon/commit/e570561db9115d055d70317b0386801280737aa1) Shader packs: write narrow fragment outputs through a vec4 - [`acbfb8c`](https://github.com/horizon-rust/horizon/commit/acbfb8ceca74de42569849f036c3db11d5b8f5b1) docs/shader-packs.md: the ten packs tested and what stops the rest ### 📊 Changes **7 files changed** (+761 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/java_pack.rs` (+39 -0) 📝 `crates/horizon-shaderpack/src/preprocess.rs` (+175 -5) 📝 `crates/horizon-shaderpack/src/properties.rs` (+62 -6) 📝 `crates/horizon-shaderpack/src/translate.rs` (+287 -5) 📝 `crates/horizon-shaderpack/tests/pack.rs` (+63 -0) 📝 `crates/horizon-shaderpack/tests/translate.rs` (+97 -0) 📝 `docs/shader-packs.md` (+38 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #616 The three packs in the report fail before a single pass is drawn. This PR fixes all three errors in `horizon-shaderpack`, makes Steadfast draw, and adds a compatibility table for the ten packs tested. Thanks to **Online5277** for the report and the exact error lines, and to **satelitesatelitesatelite** and **furyfire0751_82832** for the reports on Discord. Ten packs were tested; the table in `docs/shader-packs.md` gives each result. ## What was wrong Iris preprocesses packs with JCPP, and Horizon used naga's `pp-rs`. The two disagree on things packs rely on: | Pack | Error | What Iris does | Now | | --- | --- | --- | --- | | Steadfast 0.8.0 | `shaders.properties:1: UnexpectedToken(Float(0.5))` | JCPP reads a float in `#if` as its integer part (`ATMOSPHERE_FOG_STRENGTH_NOON == 0.5`) | same, in `shaders.properties` and in the GLSL sources | | Bloop 1.8.0-Alpha-3 | `lib/specular.glsl:50: DefineRedefined` | a later `#define` replaces an earlier one | same (`#undef` inserted before each redefinition) | | Noble v1.9.9 | `unexpected identifier u16vec2` | Noble uses 16-bit types when the GPU reports NVIDIA (`NV_gpu_shader5`) | 16- and 8-bit types and `pack/unpackFloat2x16` widened to their 32-bit forms (WGSL has none) | Once those three passed, more errors showed up behind them. These are fixed as well: - **Steadfast's `final`** writes `out vec3`. OpenGL fills the missing channel, but wgpu refuses the pipeline (`Output format Float32x4 is incompatible with the shader Float32x3`). Fragment outputs narrower than four channels are now written through a `vec4` with alpha 1. - **Empty operands and unterminated blocks** now behave as in JCPP: an empty operand in `#if` counts as 0, an unterminated `#if` runs to the end of the file, and `"`/`'` in skipped `#error` lines no longer stop `pp-rs`. - **`shaders.properties`** keeps its empty lines and backslashes through the preprocessor, as Iris's does. Before, a `\` continuation swallowed the next line: Complementary's `isCold` uniform was cut short, and it is now complete. - **Constructs naga refuses**: - `%` with a scalar and a vector operand now goes through overloads; - a `const` naga can't fold (`mix`, `?:`, `smoothstep`) becomes a global set at the start of `main`; - `sqrt` of a negative constant is evaluated at run time. ## Compatibility (tested 2026-10-22, Mac mini M4 Pro, default options) | Pack | Before | After | | --- | --- | --- | | BSL v10.1.8 | 26 passes, drawn | 26 passes, drawn (same picture) | | Complementary Reimagined r5.9.3 | 27 passes, drawn | 27 passes, drawn (same picture) | | Complementary Unbound r5.8 | 27 passes | 27 passes | | Sildur's Vibrant 2.02 Extreme | 18 passes | 18 passes | | Steadfast 0.8.0 | `UnexpectedToken(Float(0.5))` | 3 passes, **drawn** | | Bloop 1.8.0-Alpha-3 | `DefineRedefined` | gets further: `mat2(vec4)`, which naga refuses | | Noble v1.9.9 | `u16vec2` (on NVIDIA) | gets further: a `vec3[9][9]` varying | | Bliss 2.1.2 | fails | fails: an operation naga forbids in a vertex shader | | Photon v1.4 | fails | fails: a struct varying | | Rethinking Voxels r0.1-beta9 | fails | fails: `1 << 31` constant overflow; it also needs images | The packs that still fail need translator work that doesn't fit this PR. It is noted as one line in the agents' LATER list. Packs are dev-only test inputs: they were downloaded to a scratch folder outside the repository, and none is committed. On furyfire0751_82832's report, Complementary's fog over Horizon's world is the pack's own fog. Without its `gbuffers_*` and `shadow` stages (not supported yet, see the doc), it draws over terrain that it didn't light. This PR does not change that. ## Screenshots Same fixed seed, camera and time, `--offscreen` + `horizon-ctl screenshot`. Left: `main`. Right: this PR merged with #1158. Tree placement differs between runs of the same build, so compare the shading, not the trees. | | main | this PR | | --- | --- | --- | | No pack | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/main-off-noon.png) | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/integ-off-noon.png) | | Complementary Reimagined | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/main-compl-noon.png) | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/integ-compl-noon.png) | | Complementary at dusk | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/main-compl-dusk.png) | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/integ-compl-dusk.png) | | BSL | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/main-bsl-noon.png) | ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/integ-bsl-noon.png) | | Steadfast | fails to load, vanilla picture ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/main-stead-noon.png) | drawn ![](https://raw.githubusercontent.com/ludovic111/horizon/b26d357f04a1d0847f6ac912fded407a49e2fdaf/f1/integ-stead-noon.png) | I also checked for regressions without the screenshots: - The WGSL of every pass of BSL, Complementary Reimagined and Sildur's is byte-identical to `main`, apart from five Complementary programs that now use the `iris_mod` overloads. - The narrow-output change leaves all three packs' WGSL unchanged. ## Self-check Run on the Mac mini (macOS, M4 Pro): - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings` (with `set -o pipefail`): exit 0. - `cargo test -p horizon-shaderpack`: 31 passed. New tests: - `a_define_replaces_an_earlier_one`; - `conditions_read_as_jcpp_does`; - `floats_in_conditions_count_as_their_integer_part`; - `legalises_what_naga_refuses`; - `narrow_fragment_outputs_fill_four_channels`. - `cargo test -p horizon-client`: 1,088 passed, 0 failed. - `tools/parity.py --changed origin/main`: run once over origin/main (5aff2980) with both F1 branches merged (#1157 and #1158). - 102 harnesses; 85 pass. - The other 17 fail the same way on plain `main` in the same checkout: `ambient_sound`, `music`, `sound_engine`, `sound_event`, `resource_pack`, `online_mode`, `locator_bar`, `dedicated_server`, `secure_chat`, `user_cache`, `world_spawn` and the `server_*` harnesses. - For example, `ambient_sound` stops at the same line 18011 on both. These are environment failures on this machine (the prepared resources have no `registries.json`, and a CI runner was running the server harnesses at the same time), not caused by these changes. - `real_packs_load` / `real_packs_translate` with `HORIZON_TEST_SHADERPACKS` over the ten packs: the five listed as loading load; the rest stop where the table says. 🤖 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 16:01:31 +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#3103
No description provided.