[PR #344] [MERGED] Shader packs (1/3): load and validate Horizon WGSL packs #2505

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

📋 Pull Request Information

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

Base: main ← Head: feat/shader-pack-loader


📝 Commits (1)

  • 9739740 Shader packs: load and validate Horizon WGSL packs (pack.toml, prelude, options)

📊 Changes

8 files changed (+682 additions, -4 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/Cargo.toml (+3 -4)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/shader_pack.rs (+506 -0)
➕ crates/horizon-client/src/shader_pack_prelude.wgsl (+71 -0)
➕ examples/shaderpacks/horizon-sample/LICENSE (+21 -0)
➕ examples/shaderpacks/horizon-sample/pack.toml (+35 -0)
➕ examples/shaderpacks/horizon-sample/shaders/golden_hour.wgsl (+44 -0)

📄 Description

What

First code slice of the Horizon shader pack format designed in #333 (docs/shader-packs.md). Nothing draws with it yet (2/3 does), so no player-visible change.

  • shader_pack.rs: list(shaderpacks/) (folders with a pack.toml, by name, with their manifest or the error), ShaderPack::load(dir, values):
    • pack.toml ([pack] name/description/authors/version/license/api, [[stage]] kind/shader/entry/scale, [options.<key>]), unknown fields rejected, api newer than this build rejected, 1–16 stages, ≤64 options, shader paths kept inside the pack;
    • api 1 has the composite stage only; other kinds are refused with a clear message;
    • options (bool, i32 with values, f32 with min/max/step) become WGSL override constants; saved values (shaderpacks/<pack>.txt, key=value) are clamped / checked, defaults otherwise;
    • each stage = the prelude + the pack's file, parsed and validated by naga before wgpu ever sees it, with errors as shaders/x.wgsl:LINE:COL: message in the pack's own line numbers;
    • changed(): a file stamp (path, size, mtime) for hot reload.
  • shader_pack_prelude.wgsl (api 1): bindings (scene_color, scene_depth, previous, two samplers, frame), the Frame uniform, the full-screen vertex shader, depth_at, is_sky, linear_depth, view_position, world_offset, luminance, srgb_to_linear/linear_to_srgb (they hide the reversed depth).
  • examples/shaderpacks/horizon-sample (MIT): one composite stage, a warm grade, distance haze that glows towards a low sun, greyer in rain, a vignette; four options.
  • naga moves from dev-dependency to dependency (same version wgpu already builds); toml 1.1 (already in the lockfile).

Folder packs only in this slice; zips with the renderer or the screen.

How tested

cargo fmt -p horizon-client --check                       ok
cargo clippy -p horizon-client --all-targets -D warnings  ok
cargo test -p horizon-client --lib shader_pack            6 passed (sample pack loads; options/values; errors point into the pack file; manifest checks; stamp + list; saved values)

No harness reads this module (nothing calls it yet).

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/344 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-pack-loader` --- ### 📝 Commits (1) - [`9739740`](https://github.com/horizon-rust/horizon/commit/97397403796fd72ed6f0f1ab1e5820bf87cd8791) Shader packs: load and validate Horizon WGSL packs (pack.toml, prelude, options) ### 📊 Changes **8 files changed** (+682 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/Cargo.toml` (+3 -4) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/shader_pack.rs` (+506 -0) ➕ `crates/horizon-client/src/shader_pack_prelude.wgsl` (+71 -0) ➕ `examples/shaderpacks/horizon-sample/LICENSE` (+21 -0) ➕ `examples/shaderpacks/horizon-sample/pack.toml` (+35 -0) ➕ `examples/shaderpacks/horizon-sample/shaders/golden_hour.wgsl` (+44 -0) </details> ### 📄 Description ## What First code slice of the Horizon shader pack format designed in #333 (`docs/shader-packs.md`). Nothing draws with it yet (2/3 does), so no player-visible change. - `shader_pack.rs`: `list(shaderpacks/)` (folders with a `pack.toml`, by name, with their manifest or the error), `ShaderPack::load(dir, values)`: - `pack.toml` (`[pack]` name/description/authors/version/license/`api`, `[[stage]]` kind/shader/entry/scale, `[options.<key>]`), unknown fields rejected, api newer than this build rejected, 1–16 stages, ≤64 options, shader paths kept inside the pack; - api 1 has the `composite` stage only; other kinds are refused with a clear message; - options (`bool`, `i32` with `values`, `f32` with `min`/`max`/`step`) become WGSL `override` constants; saved values (`shaderpacks/<pack>.txt`, `key=value`) are clamped / checked, defaults otherwise; - each stage = the prelude + the pack's file, parsed and validated by naga before wgpu ever sees it, with errors as `shaders/x.wgsl:LINE:COL: message` in the pack's own line numbers; - `changed()`: a file stamp (path, size, mtime) for hot reload. - `shader_pack_prelude.wgsl` (api 1): bindings (`scene_color`, `scene_depth`, `previous`, two samplers, `frame`), the `Frame` uniform, the full-screen vertex shader, `depth_at`, `is_sky`, `linear_depth`, `view_position`, `world_offset`, `luminance`, `srgb_to_linear`/`linear_to_srgb` (they hide the reversed depth). - `examples/shaderpacks/horizon-sample` (MIT): one composite stage, a warm grade, distance haze that glows towards a low sun, greyer in rain, a vignette; four options. - `naga` moves from dev-dependency to dependency (same version wgpu already builds); `toml` 1.1 (already in the lockfile). Folder packs only in this slice; zips with the renderer or the screen. ## How tested ``` cargo fmt -p horizon-client --check ok cargo clippy -p horizon-client --all-targets -D warnings ok cargo test -p horizon-client --lib shader_pack 6 passed (sample pack loads; options/values; errors point into the pack file; manifest checks; stamp + list; saved values) ``` No harness reads this module (nothing calls it yet). ## 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:56: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#2505
No description provided.