[PR #405] [MERGED] Java shader packs (1): horizon-shaderpack crate, Iris's preprocessor and options #2539

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

📋 Pull Request Information

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

Base: main ← Head: feat/shaderpack-preprocess


📝 Commits (1)

  • b22583d horizon-shaderpack: open Java shader packs and preprocess them like Iris

📊 Changes

16 files changed (+1744 additions, -1 deletions)

View changed files

📝 Cargo.lock (+17 -0)
📝 Cargo.toml (+1 -1)
➕ crates/horizon-shaderpack/Cargo.toml (+18 -0)
➕ crates/horizon-shaderpack/src/include.rs (+198 -0)
➕ crates/horizon-shaderpack/src/lib.rs (+122 -0)
➕ crates/horizon-shaderpack/src/options.rs (+659 -0)
➕ crates/horizon-shaderpack/src/preprocess.rs (+332 -0)
➕ crates/horizon-shaderpack/src/source.rs (+141 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/composite.fsh (+10 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/composite.vsh (+3 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/lib/common.glsl (+7 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/lib/settings.glsl (+7 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/notes.txt (+1 -0)
➕ crates/horizon-shaderpack/tests/fixtures/mini/shaders/world-1/composite.fsh (+4 -0)
➕ crates/horizon-shaderpack/tests/pack.rs (+223 -0)
📝 docs/shader-packs.md (+1 -0)

📄 Description

What

First step of the OptiFine/Iris translation in docs/shader-packs.md ("Order to implement", step 1, first half): a new crate, crates/horizon-shaderpack, that turns a Java shader pack's program into plain GLSL the way Iris does before compiling it. It needs no GPU and nothing in the game uses it yet.

  • source: open a pack folder or .zip; shaders/ is found the way Iris finds it (shaders/ at the root, else the first folder ending in shaders, such as Pack-main/shaders/); programs are listed per dimension folder (dimension.properties, else world0/world-1/world1).
  • include: Iris's IncludeGraph/IncludeProcessor. #include is resolved before any other directive (so include guards don't apply); /lib/x is from shaders/, x from the including file; missing files, self-includes and cycles are errors that name file:line.
  • options: a port of Iris's OptionAnnotatedSource/ParsedString/OptionSet. A boolean #define is an option only when a bare #ifdef/#ifndef in its include component refers to it; value defines and the configurable consts (Iris's list) need a [...] list; two definitions with different defaults drop the option. The player's values are written back line by line, as Iris does (//#define, #define X v // OptionAnnotatedSource: Changed option, the const value after =).
  • preprocess: Iris's standard macros (MC_VERSION 260300 for 26.3, IS_IRIS, MC_OS_*, vendor/renderer from the adapter, render stages, CAT_*, PPT_*, DH_BLOCK_*, ...) and pp-rs (naga's preprocessor) expansion. Output lines are the inlined lines, so later errors still map to file:line.

Why

The spike in #333 used a throwaway token tool. This is the real front half: the next PR adds the syntax-tree legaliser and naga → WGSL on top, and the shaders.properties screens use options.

How it was verified

  • Unit tests: Iris's own OptionDiscoverTest cases plus booleans/references, value write-back and conflicting defaults.
  • Fixture pack in tests/fixtures/mini (our own, hand-written): programs per dimension, options found, defaults vs changed values, file:line mapping, missing include, include cycle, zip with shaders/ in a subfolder giving the same output as the folder.
  • Real packs, dev only (outside the repo, never committed): with HORIZON_TEST_SHADERPACKS set to a folder holding the three test packs' zips, every program preprocesses:
    ComplementaryReimagined_r5.9.3.zip: 219/219 programs, 170 boolean and 231 value options
    Sildurs-Vibrant-2.02-Extreme.zip: 126/126 programs, 60 boolean and 55 value options
    BSL_v10.1.8.zip: 185/185 programs, 102 boolean and 282 value options
    
    Without the variable the test does nothing, so CI never needs the packs.

Self-check (Mac mini):

cargo fmt -p horizon-shaderpack                                   clean
cargo clippy -p horizon-shaderpack --all-targets -- -D warnings   clean
cargo test -p horizon-shaderpack --locked                         9 passed

No other crate depends on the new one, so nothing else is rebuilt or changed; no parity harness covers it (nothing player-facing yet).

What is left

Next PRs: the GLSL syntax-tree legaliser and naga → WGSL (with the three fixes the spike listed), shaders.properties, then the full-screen programs (deferred*, composite*, final) in the renderer. MC_GL_* extension macros are not defined yet, so packs take their portable paths; BIOME_* and the texture-format macros are for the game to add (Environment::define).

Needs Ludovic

Nothing.

🤖 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/405 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shaderpack-preprocess` --- ### 📝 Commits (1) - [`b22583d`](https://github.com/horizon-rust/horizon/commit/b22583d0577f83652e275b4560de483ab42594d8) horizon-shaderpack: open Java shader packs and preprocess them like Iris ### 📊 Changes **16 files changed** (+1744 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+17 -0) 📝 `Cargo.toml` (+1 -1) ➕ `crates/horizon-shaderpack/Cargo.toml` (+18 -0) ➕ `crates/horizon-shaderpack/src/include.rs` (+198 -0) ➕ `crates/horizon-shaderpack/src/lib.rs` (+122 -0) ➕ `crates/horizon-shaderpack/src/options.rs` (+659 -0) ➕ `crates/horizon-shaderpack/src/preprocess.rs` (+332 -0) ➕ `crates/horizon-shaderpack/src/source.rs` (+141 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/composite.fsh` (+10 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/composite.vsh` (+3 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/lib/common.glsl` (+7 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/lib/settings.glsl` (+7 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/notes.txt` (+1 -0) ➕ `crates/horizon-shaderpack/tests/fixtures/mini/shaders/world-1/composite.fsh` (+4 -0) ➕ `crates/horizon-shaderpack/tests/pack.rs` (+223 -0) 📝 `docs/shader-packs.md` (+1 -0) </details> ### 📄 Description ## What First step of the OptiFine/Iris translation in docs/shader-packs.md ("Order to implement", step 1, first half): a new crate, `crates/horizon-shaderpack`, that turns a Java shader pack's program into plain GLSL the way Iris does before compiling it. It needs no GPU and nothing in the game uses it yet. - `source`: open a pack folder or `.zip`; `shaders/` is found the way Iris finds it (`shaders/` at the root, else the first folder ending in `shaders`, such as `Pack-main/shaders/`); programs are listed per dimension folder (`dimension.properties`, else `world0`/`world-1`/`world1`). - `include`: Iris's `IncludeGraph`/`IncludeProcessor`. `#include` is resolved before any other directive (so include guards don't apply); `/lib/x` is from `shaders/`, `x` from the including file; missing files, self-includes and cycles are errors that name `file:line`. - `options`: a port of Iris's `OptionAnnotatedSource`/`ParsedString`/`OptionSet`. A boolean `#define` is an option only when a bare `#ifdef`/`#ifndef` in its include component refers to it; value defines and the configurable `const`s (Iris's list) need a `[...]` list; two definitions with different defaults drop the option. The player's values are written back line by line, as Iris does (`//#define`, `#define X v // OptionAnnotatedSource: Changed option`, the const value after `=`). - `preprocess`: Iris's standard macros (`MC_VERSION 260300` for 26.3, `IS_IRIS`, `MC_OS_*`, vendor/renderer from the adapter, render stages, `CAT_*`, `PPT_*`, `DH_BLOCK_*`, ...) and pp-rs (naga's preprocessor) expansion. Output lines are the inlined lines, so later errors still map to `file:line`. ## Why The spike in #333 used a throwaway token tool. This is the real front half: the next PR adds the syntax-tree legaliser and naga → WGSL on top, and the `shaders.properties` screens use `options`. ## How it was verified - Unit tests: Iris's own `OptionDiscoverTest` cases plus booleans/references, value write-back and conflicting defaults. - Fixture pack in `tests/fixtures/mini` (our own, hand-written): programs per dimension, options found, defaults vs changed values, `file:line` mapping, missing include, include cycle, zip with `shaders/` in a subfolder giving the same output as the folder. - Real packs, dev only (outside the repo, never committed): with `HORIZON_TEST_SHADERPACKS` set to a folder holding the three test packs' zips, every program preprocesses: ``` ComplementaryReimagined_r5.9.3.zip: 219/219 programs, 170 boolean and 231 value options Sildurs-Vibrant-2.02-Extreme.zip: 126/126 programs, 60 boolean and 55 value options BSL_v10.1.8.zip: 185/185 programs, 102 boolean and 282 value options ``` Without the variable the test does nothing, so CI never needs the packs. Self-check (Mac mini): ``` cargo fmt -p horizon-shaderpack clean cargo clippy -p horizon-shaderpack --all-targets -- -D warnings clean cargo test -p horizon-shaderpack --locked 9 passed ``` No other crate depends on the new one, so nothing else is rebuilt or changed; no parity harness covers it (nothing player-facing yet). ## What is left Next PRs: the GLSL syntax-tree legaliser and naga → WGSL (with the three fixes the spike listed), `shaders.properties`, then the full-screen programs (`deferred*`, `composite*`, `final`) in the renderer. `MC_GL_*` extension macros are not defined yet, so packs take their portable paths; `BIOME_*` and the texture-format macros are for the game to add (`Environment::define`). ## Needs Ludovic Nothing. 🤖 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:57:01 +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#2539
No description provided.