[PR #1861] [MERGED] Horizon shader packs: the post stage runs in the game, with hot reload #3826

Closed
opened 2026-11-03 04:12:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/native-shaders-post


📝 Commits (1)

  • 1aa6f21 Horizon shader packs: the post stage runs in the game, with hot reload

📊 Changes

13 files changed (+723 additions, -21 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/game.rs (+4 -0)
➕ crates/horizon-client/src/game/native_shaders.rs (+110 -0)
📝 crates/horizon-client/src/game/shader_packs.rs (+10 -6)
📝 crates/horizon-client/src/gfx.rs (+55 -4)
➕ crates/horizon-client/src/gfx/native_post.rs (+509 -0)
📝 crates/horizon-shader-api/packs/golden_hour/post/glow.wgsl (+9 -6)
📝 crates/horizon-shader-api/src/inputs.rs (+1 -1)
📝 crates/horizon-shader-api/src/package.rs (+7 -0)
📝 docs/api/shaders-reference.md (+1 -1)
📝 docs/api/shaders.md (+1 -0)
📝 docs/shaders.md (+13 -3)

📄 Description

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

What

Horizon's own shader packs (horizon-shaders.toml, docs/shaders.md) now draw in the game. A pack folder or .hshader in shaderpacks/, named by HORIZON_SHADER_PACK, goes through horizon_shader_api::check first. Its post passes then run over the world, under the hand and HUD. The Options > Shader Packs page comes in a follow-up PR.

  • Hot reload. The game looks at the pack twice a second. When a file is saved, the pack is checked and rebuilt in place, and the chat says "Shader pack … reloaded". If the new version fails, the chat lists each problem at its file, line and column, and the last good version keeps drawing.
  • One hook for both pack kinds. A native pack reads the same world target a shaders/ pack reads: world_post.prepare with depth stored, then the pack draws onto the screen in place of world_post.finish. There is no second target and no duplicate pass. Setting either kind of pack drops the other. This replaces #1842, which is closed.
  • Without a pack the frame only tests one Option.
  • Golden Hour's glow now leaves the daytime sky mostly alone. The PostInput.pixel doc says which size it counts in.

Screenshots

These are in ~/code/horizon-parity/screenshots/shaders-api-2/ on the Mac mini, 1280×720, Metal, M4 Pro:

  • sunset-none.png / sunset-pack.png: the same view at time 12500, without and with Golden Hour.
  • day-pack.png: Golden Hour at noon.
  • reload-gray.png: a saved edit to grade.wgsl (saturation × 0) shows as "Shader pack Golden Hour reloaded".
  • reload-broken.png: a broken edit is refused, with post/grade.wgsl:1:49: no definition in scope for identifier: oops, and the last good pack keeps drawing.

A/B: no frame cost without a pack

The test uses paired runs, alternating main at d8aaf367e and this branch on top of it. Each run is a fresh creative world (seed 12345, render distance 12, time 6000, a fixed view, offscreen) with horizon-ctl bench 15, repeated 4 times.

CPU ms/frame (4 runs) mean GPU ms/frame (4 runs) mean
main 0.706 0.712 0.690 0.682 0.698 1.641 1.650 1.829 1.705 1.706
this branch, no pack 0.731 0.680 0.736 0.731 0.720 1.511 1.875 1.722 1.651 1.690
this branch, Golden Hour 0.870 0.872 0.871 1.899 2.111 2.005

Without a pack, both columns fall within the spread of main's runs. Golden Hour costs about 0.3 ms GPU for its two passes at 1280×720.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 8cf51888c, 8 min 43 s)

Check Result
Scope ⚠️ 13 files, +723 −21; 725 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (1 min 22 s)
tests: workspace ✅ 2168 passed (6 min 40 s)
doc tests ✅ 1 passed (36 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 338 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 326 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: CI's parity job selects all 338 harnesses because Cargo.lock changed (horizon-client depends on horizon-shader-api now). Locally I ran the 66 harnesses the code changes select (tools/parity.py --changed-files on every changed path except the lock): 66 passed, 0 failed (40 min).

Scope: 725 lines, including the 150-line GPU test of the pass chain.

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/1861 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-shaders-post` --- ### 📝 Commits (1) - [`1aa6f21`](https://github.com/horizon-rust/horizon/commit/1aa6f21620833327a6c9aeaa7ab95764682c1041) Horizon shader packs: the post stage runs in the game, with hot reload ### 📊 Changes **13 files changed** (+723 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/game.rs` (+4 -0) ➕ `crates/horizon-client/src/game/native_shaders.rs` (+110 -0) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+10 -6) 📝 `crates/horizon-client/src/gfx.rs` (+55 -4) ➕ `crates/horizon-client/src/gfx/native_post.rs` (+509 -0) 📝 `crates/horizon-shader-api/packs/golden_hour/post/glow.wgsl` (+9 -6) 📝 `crates/horizon-shader-api/src/inputs.rs` (+1 -1) 📝 `crates/horizon-shader-api/src/package.rs` (+7 -0) 📝 `docs/api/shaders-reference.md` (+1 -1) 📝 `docs/api/shaders.md` (+1 -0) 📝 `docs/shaders.md` (+13 -3) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Horizon's own shader packs (`horizon-shaders.toml`, docs/shaders.md) now draw in the game. A pack folder or `.hshader` in `shaderpacks/`, named by `HORIZON_SHADER_PACK`, goes through `horizon_shader_api::check` first. Its post passes then run over the world, under the hand and HUD. The Options > Shader Packs page comes in a follow-up PR. - **Hot reload.** The game looks at the pack twice a second. When a file is saved, the pack is checked and rebuilt in place, and the chat says "Shader pack … reloaded". If the new version fails, the chat lists each problem at its file, line and column, and the last good version keeps drawing. - **One hook for both pack kinds.** A native pack reads the same world target a `shaders/` pack reads: `world_post.prepare` with depth stored, then the pack draws onto the screen in place of `world_post.finish`. There is no second target and no duplicate pass. Setting either kind of pack drops the other. This replaces #1842, which is closed. - **Without a pack** the frame only tests one `Option`. - Golden Hour's glow now leaves the daytime sky mostly alone. The `PostInput.pixel` doc says which size it counts in. ## Screenshots These are in `~/code/horizon-parity/screenshots/shaders-api-2/` on the Mac mini, 1280×720, Metal, M4 Pro: - `sunset-none.png` / `sunset-pack.png`: the same view at time 12500, without and with Golden Hour. - `day-pack.png`: Golden Hour at noon. - `reload-gray.png`: a saved edit to `grade.wgsl` (saturation × 0) shows as "Shader pack Golden Hour reloaded". - `reload-broken.png`: a broken edit is refused, with `post/grade.wgsl:1:49: no definition in scope for identifier: oops`, and the last good pack keeps drawing. ## A/B: no frame cost without a pack The test uses paired runs, alternating main at d8aaf367e and this branch on top of it. Each run is a fresh creative world (seed 12345, render distance 12, time 6000, a fixed view, offscreen) with `horizon-ctl bench 15`, repeated 4 times. | | CPU ms/frame (4 runs) | mean | GPU ms/frame (4 runs) | mean | |---|---|---|---|---| | main | 0.706 0.712 0.690 0.682 | 0.698 | 1.641 1.650 1.829 1.705 | 1.706 | | this branch, no pack | 0.731 0.680 0.736 0.731 | 0.720 | 1.511 1.875 1.722 1.651 | 1.690 | | this branch, Golden Hour | 0.870 0.872 | 0.871 | 1.899 2.111 | 2.005 | Without a pack, both columns fall within the spread of main's runs. Golden Hour costs about 0.3 ms GPU for its two passes at 1280×720. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 8cf51888c, 8 min 43 s) | Check | Result | | --- | --- | | Scope | ⚠️ 13 files, +723 −21; 725 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 22 s) | | tests: workspace | ✅ 2168 passed (6 min 40 s) | | doc tests | ✅ 1 passed (36 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 338 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 326 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: CI's parity job selects all 338 harnesses because Cargo.lock changed (horizon-client depends on horizon-shader-api now). Locally I ran the 66 harnesses the code changes select (`tools/parity.py --changed-files` on every changed path except the lock): 66 passed, 0 failed (40 min). Scope: 725 lines, including the 150-line GPU test of the pass chain. ## 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-03 04:12:36 +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#3826
No description provided.