[PR #346] [MERGED] Shader packs (2/3): run a pack's composite stages over the world, with hot reload #2507

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • 35f78ae Shader packs: run a pack's composite stages over the world, with hot reload

📊 Changes

9 files changed (+640 additions, -26 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+6 -0)
📝 crates/horizon-client/src/game/debug_keys.rs (+1 -0)
📝 crates/horizon-client/src/game/options.rs (+8 -0)
📝 crates/horizon-client/src/game/render_tick.rs (+33 -0)
➕ crates/horizon-client/src/game/shader_packs.rs (+92 -0)
📝 crates/horizon-client/src/gfx.rs (+128 -5)
➕ crates/horizon-client/src/gfx/pack_stages.rs (+325 -0)
📝 crates/horizon-client/src/gfx/world_post.rs (+39 -20)
📝 crates/horizon-client/src/graphics.rs (+8 -1)

📄 Description

What

Second slice of Horizon WGSL shader packs (design: docs/shader-packs.md, #333). Stacked on #344.

  • gfx/pack_stages.rs: builds the pack's composite stages as full-screen passes.
    • Bindings, as documented: scene colour, scene depth, previous stage, linear and nearest samplers, Frame uniform.
    • Each stage writes its own target at its scale. The last target goes to the screen through world_post (copy or FXAA), under the hand and the HUD.
    • Pipelines are built inside an error scope, so a pack wgpu rejects is refused with its message, never a panic.
    • Each stage only gets the override constants it declares.
  • gfx.rs:
    • Renderer::set_shader_pack and ShaderInputs on Frame.
    • The Frame uniform: matrices, camera, sun/moon, sky and fog colours, fog distances, rain/thunder, submerged, dimension, day fraction.
    • With a pack on, the world depth is stored (Store) and world_post gets a texture to sample.
    • With no pack, the code path is unchanged: same prepare, depth Discard, same passes.
  • game/shader_packs.rs:
    • Loads the pack named by shaderPack: in horizon-graphics.txt from shaderpacks/.
    • Hot reload: file stamps are checked twice a second, F3 + T forces a reload, and a new selection loads at once.
    • A pack that fails keeps the last good one (or vanilla) and says why in chat, with file:line:column.
  • graphics.rs: the shaderPack key (empty = off, the default).

Why

This is the format's first working stage: a pack can grade, fog and tint the world without touching the GUI.

How tested

  • cargo fmt; cargo clippy --workspace --all-targets -- -D warnings is clean.
  • Tests in horizon-client: shader_pack, pack_stages, gfx and graphics pass. New: the Frame uniform matches the prelude's struct (448 bytes, 4 mat4 + 12 vec4); only declared overrides are passed.
  • Rendering harnesses: environment_render, weather_render, cloud_render and world_border_render (results in a comment below).
  • On the Mac mini (Metal, offscreen 1280x720, seed 1234, the same position and time 12300), with the sample pack from #344:
    • pack off vs on: the vignette, the warmer grade and the haze toward the sun show; the held item and the HUD are unchanged;
    • hot reload: setting saturation to 0 in pack.toml turned the world grey within a second, with no restart;
    • an error: appending fn broken( { to the WGSL put Shader pack horizon-sample: shaders/golden_hour.wgsl:45:12: expected identifier, found "{" in chat, and the last good pack kept running;
    • restoring the files reloaded it.
    • The shots are on the Mac mini in ~/code/horizon-parity/shots/shader-packs/ (off.png, on.png, reload-grey.png, reload-restored.png).

Needs Ludovic

Nothing blocking. Not checked: Linux/Vulkan with vscreen on the desktop.

🤖 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/346 **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-render` --- ### 📝 Commits (1) - [`35f78ae`](https://github.com/horizon-rust/horizon/commit/35f78ae27c803e47c90d6d95ba1f0a80b54e49ee) Shader packs: run a pack's composite stages over the world, with hot reload ### 📊 Changes **9 files changed** (+640 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+6 -0) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+1 -0) 📝 `crates/horizon-client/src/game/options.rs` (+8 -0) 📝 `crates/horizon-client/src/game/render_tick.rs` (+33 -0) ➕ `crates/horizon-client/src/game/shader_packs.rs` (+92 -0) 📝 `crates/horizon-client/src/gfx.rs` (+128 -5) ➕ `crates/horizon-client/src/gfx/pack_stages.rs` (+325 -0) 📝 `crates/horizon-client/src/gfx/world_post.rs` (+39 -20) 📝 `crates/horizon-client/src/graphics.rs` (+8 -1) </details> ### 📄 Description ## What Second slice of Horizon WGSL shader packs (design: docs/shader-packs.md, #333). Stacked on #344. - **gfx/pack_stages.rs**: builds the pack's `composite` stages as full-screen passes. - Bindings, as documented: scene colour, scene depth, previous stage, linear and nearest samplers, `Frame` uniform. - Each stage writes its own target at its `scale`. The last target goes to the screen through `world_post` (copy or FXAA), under the hand and the HUD. - Pipelines are built inside an error scope, so a pack wgpu rejects is refused with its message, never a panic. - Each stage only gets the `override` constants it declares. - **gfx.rs**: - `Renderer::set_shader_pack` and `ShaderInputs` on `Frame`. - The `Frame` uniform: matrices, camera, sun/moon, sky and fog colours, fog distances, rain/thunder, submerged, dimension, day fraction. - With a pack on, the world depth is stored (`Store`) and `world_post` gets a texture to sample. - **With no pack, the code path is unchanged**: same `prepare`, depth `Discard`, same passes. - **game/shader_packs.rs**: - Loads the pack named by `shaderPack:` in `horizon-graphics.txt` from `shaderpacks/`. - Hot reload: file stamps are checked twice a second, F3 + T forces a reload, and a new selection loads at once. - A pack that fails keeps the last good one (or vanilla) and says why in chat, with file:line:column. - **graphics.rs**: the `shaderPack` key (empty = off, the default). ## Why This is the format's first working stage: a pack can grade, fog and tint the world without touching the GUI. ## How tested - `cargo fmt`; `cargo clippy --workspace --all-targets -- -D warnings` is clean. - Tests in `horizon-client`: shader_pack, pack_stages, gfx and graphics pass. New: the `Frame` uniform matches the prelude's struct (448 bytes, 4 mat4 + 12 vec4); only declared overrides are passed. - Rendering harnesses: environment_render, weather_render, cloud_render and world_border_render (results in a comment below). - On the Mac mini (Metal, offscreen 1280x720, seed 1234, the same position and time 12300), with the sample pack from #344: - pack off vs on: the vignette, the warmer grade and the haze toward the sun show; the held item and the HUD are unchanged; - hot reload: setting `saturation` to 0 in pack.toml turned the world grey within a second, with no restart; - an error: appending `fn broken( {` to the WGSL put `Shader pack horizon-sample: shaders/golden_hour.wgsl:45:12: expected identifier, found "{"` in chat, and the last good pack kept running; - restoring the files reloaded it. - The shots are on the Mac mini in `~/code/horizon-parity/shots/shader-packs/` (`off.png`, `on.png`, `reload-grey.png`, `reload-restored.png`). ## Needs Ludovic Nothing blocking. Not checked: Linux/Vulkan with `vscreen` on the desktop. 🤖 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:46 +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#2507
No description provided.