[PR #1656] [MERGED] Shader packs, clean room 10: post-processing over Horizon's world #3665

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

📋 Pull Request Information

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

Base: main ← Head: feat/shader-packs-post


📝 Commits (1)

  • 1776d7c Shader packs, clean room 10: post-processing over Horizon's world

📊 Changes

7 files changed (+1057 additions, -15 deletions)

View changed files

📝 Cargo.lock (+4 -0)
📝 crates/horizon-client/Cargo.toml (+3 -1)
📝 crates/horizon-client/src/game/shader_packs.rs (+54 -4)
📝 crates/horizon-client/src/gfx.rs (+75 -9)
➕ crates/horizon-client/src/gfx/pack_post.rs (+866 -0)
➕ crates/horizon-client/src/gfx/pack_post.wgsl (+47 -0)
📝 crates/horizon-client/src/gfx/world_post.rs (+8 -1)

📄 Description

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

Shader packs, clean room 10 (slice 5d): post-processing over Horizon's world, the first slice that draws. Stacked on #1655.

What

With HORIZON_SHADER_PACK=<name>, the pack in shaderpacks/<name> (folder or zip, beside options.txt) runs its prepare, deferred, composite and final programs over the world, under the hand and the HUD. Gbuffers programs come in slices 6–7, so for now the composites read Horizon's own picture. Without the variable nothing changes.

  • The world renders into its own target (as with a resolution scale); its colour becomes colortex0 and its reverse-Z depth becomes depthtex0 holding GL's window depth (1 − d for the same planes), rows flipped to GL's order (§5.5). depthtex1/depthtex2 read the same depth until gbuffers split them.
  • colortex buffers in the formats the pack asked for (the nearest format wgpu renders to: RGB → RGBA, snorm and 16-bit norm without the feature → half float), created only when a program uses them, two textures each: programs read main and write alt, the buffers a program wrote flip after it, flip.* and deferred_pre/composite_pre apply, and the mapping carries over to the next frame so Clear=false buffers keep their history (OQ-8). Clears at the start of the frame with the pack's colours or §6.1.5's defaults.
  • noisetex (256×256 white noise, repeat), a lit stand-in behind sampler2DShadow until shadow maps exist (slice 8), a 1×1 stand-in for other names, each reported once.
  • final draws onto the window; without one, colortex0 is shown (OQ-5).
  • Pipelines are built inside wgpu validation scopes: a program wgpu refuses is reported with the full error chain and skipped. The dimension's folder is reloaded when the player changes dimension.

Size: about 1060 lines, over the ~500 target: the runtime (targets, passes, bind groups, the two helper shaders) only draws as a whole, and its first PR has to show a frame. It is in its own file, gfx/pack_post.rs (+ pack_post.wgsl); the renderer changes are ~90 lines.

Left for later slices: scale.*, size.buffer.* and colortex mipmaps (no test pack needs them yet), compute passes, begin.

Clean room

Clean-room: implemented from cleanroom/shader-packs-spec.md revision 1, §2.1 rows 4, 6, 8, 9; §2.2; §2.5; §5.5; §6.1; §6.2; §6.4; OQ-5 and OQ-8; no other loader's code read. Horizon's test pack was written from the spec.

How tested

  • Screenshots (Mac mini, Metal, 1280×720, --offscreen, fresh mktemp -d homes, launcher and XDG folders; kept in ~/builds/horizon/shader-packs-slice5/ on the Mac mini): without a pack, and with Horizon's post-test pack, on the server-thread path and --in-frame. With the pack: the warm tint and vignette over the whole frame, and on the right half the depth bands, blue on the nearby leaves going to orange towards the sky, so depth, its orientation, gl_FragCoord, viewWidth, noisetex, a GLSL 330 program, the flip from composite to composite1 and final all work. Not mirrored, not upside down.
  • A public pack as a black box (BSL, never committed, screenshot kept local): 5 programs load in 1.3 s and draw without errors; it looks wrong, as expected, because its composites read material buffers only its gbuffers programs fill.
  • Unit tests: pack formats to wgpu formats with and without the optional features; sampler names to their sources.
  • Benchmark baseline (horizon-client --benchmark forest --render-distance 8, 1280×720, offscreen, fast profile, fresh homes, 3 runs each interleaved, on a busy machine: load average 50–59 from other sessions, so treat it as a first reading):
avg FPS frame time 1% low (frame time) steady RSS
no pack 1829 0.551 ms 2.34 ms 1120 MB
post-test (blit + 3 programs) 1612 0.622 ms 3.12 ms 1114 MB

Cost of the pack: +0.07 ms per frame on average. At ~1800 FPS any fixed cost is a large share (88% of the FPS; the plan's ≥95% target is meant at game-like frame rates); the 1% low difference is within the noise of this machine. Loading the test pack takes 0.2–0.9 s (the target is ≤2 s). An idle-machine rerun is planned with the next rendering slice.

Self-check (whole stack, on its top branch feat/shader-packs-post)

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 16d49fe66, 33 min 27 s)

Check Result
Scope ⚠️ 35 files, +5328 −13; 5068 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (18 s)
clippy ✅ (2 min 38 s)
tests: workspace ✅ 1965 passed (26 min 23 s)
doc tests ✅ 1 passed (4 min 7 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 326 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 314 more
Label skip-release: players see nothing without HORIZON_SHADER_PACK

Parity: 326 harnesses selected (the root Cargo.toml, then gfx.rs and game.rs in the last PR); CI runs them. The renderer changes only act when a pack is loaded: without HORIZON_SHADER_PACK the world target, depth stores and passes are as before.

Needs Ludovic

Nothing for this PR. Label skip-release: it runs only behind HORIZON_SHADER_PACK; the first visible slice is the Shader Packs page (slice 9).

🤖 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/1656 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-packs-post` --- ### 📝 Commits (1) - [`1776d7c`](https://github.com/horizon-rust/horizon/commit/1776d7ca5ce3f0de51c41006c045460ba2c40ae0) Shader packs, clean room 10: post-processing over Horizon's world ### 📊 Changes **7 files changed** (+1057 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+4 -0) 📝 `crates/horizon-client/Cargo.toml` (+3 -1) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+54 -4) 📝 `crates/horizon-client/src/gfx.rs` (+75 -9) ➕ `crates/horizon-client/src/gfx/pack_post.rs` (+866 -0) ➕ `crates/horizon-client/src/gfx/pack_post.wgsl` (+47 -0) 📝 `crates/horizon-client/src/gfx/world_post.rs` (+8 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Shader packs, clean room 10 (slice 5d):** post-processing over Horizon's world, the first slice that draws. Stacked on #1655. ## What With `HORIZON_SHADER_PACK=<name>`, the pack in `shaderpacks/<name>` (folder or zip, beside `options.txt`) runs its `prepare`, `deferred`, `composite` and `final` programs over the world, under the hand and the HUD. Gbuffers programs come in slices 6–7, so for now the composites read Horizon's own picture. Without the variable nothing changes. - The world renders into its own target (as with a resolution scale); its colour becomes colortex0 and its reverse-Z depth becomes `depthtex0` holding GL's window depth (1 − d for the same planes), rows flipped to GL's order (§5.5). `depthtex1`/`depthtex2` read the same depth until gbuffers split them. - colortex buffers in the formats the pack asked for (the nearest format wgpu renders to: RGB → RGBA, snorm and 16-bit norm without the feature → half float), created only when a program uses them, two textures each: programs read main and write alt, the buffers a program wrote flip after it, `flip.*` and `deferred_pre`/`composite_pre` apply, and the mapping carries over to the next frame so `Clear=false` buffers keep their history (OQ-8). Clears at the start of the frame with the pack's colours or §6.1.5's defaults. - `noisetex` (256×256 white noise, repeat), a lit stand-in behind `sampler2DShadow` until shadow maps exist (slice 8), a 1×1 stand-in for other names, each reported once. - `final` draws onto the window; without one, colortex0 is shown (OQ-5). - Pipelines are built inside wgpu validation scopes: a program wgpu refuses is reported with the full error chain and skipped. The dimension's folder is reloaded when the player changes dimension. **Size:** about 1060 lines, over the ~500 target: the runtime (targets, passes, bind groups, the two helper shaders) only draws as a whole, and its first PR has to show a frame. It is in its own file, `gfx/pack_post.rs` (+ `pack_post.wgsl`); the renderer changes are ~90 lines. Left for later slices: `scale.*`, `size.buffer.*` and colortex mipmaps (no test pack needs them yet), compute passes, `begin`. ## Clean room Clean-room: implemented from `cleanroom/shader-packs-spec.md` revision 1, §2.1 rows 4, 6, 8, 9; §2.2; §2.5; §5.5; §6.1; §6.2; §6.4; OQ-5 and OQ-8; no other loader's code read. Horizon's test pack was written from the spec. ## How tested - **Screenshots** (Mac mini, Metal, 1280×720, `--offscreen`, fresh `mktemp -d` homes, launcher and XDG folders; kept in `~/builds/horizon/shader-packs-slice5/` on the Mac mini): without a pack, and with Horizon's `post-test` pack, on the server-thread path and `--in-frame`. With the pack: the warm tint and vignette over the whole frame, and on the right half the depth bands, blue on the nearby leaves going to orange towards the sky, so depth, its orientation, `gl_FragCoord`, `viewWidth`, `noisetex`, a GLSL 330 program, the flip from `composite` to `composite1` and `final` all work. Not mirrored, not upside down. - **A public pack as a black box** (BSL, never committed, screenshot kept local): 5 programs load in 1.3 s and draw without errors; it looks wrong, as expected, because its composites read material buffers only its gbuffers programs fill. - Unit tests: pack formats to wgpu formats with and without the optional features; sampler names to their sources. - **Benchmark baseline** (`horizon-client --benchmark forest --render-distance 8`, 1280×720, offscreen, `fast` profile, fresh homes, 3 runs each interleaved, **on a busy machine**: load average 50–59 from other sessions, so treat it as a first reading): | | avg FPS | frame time | 1% low (frame time) | steady RSS | |---|---|---|---|---| | no pack | 1829 | 0.551 ms | 2.34 ms | 1120 MB | | `post-test` (blit + 3 programs) | 1612 | 0.622 ms | 3.12 ms | 1114 MB | Cost of the pack: **+0.07 ms per frame** on average. At ~1800 FPS any fixed cost is a large share (88% of the FPS; the plan's ≥95% target is meant at game-like frame rates); the 1% low difference is within the noise of this machine. Loading the test pack takes 0.2–0.9 s (the target is ≤2 s). An idle-machine rerun is planned with the next rendering slice. ## Self-check (whole stack, on its top branch `feat/shader-packs-post`) **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 16d49fe66, 33 min 27 s) | Check | Result | | --- | --- | | Scope | ⚠️ 35 files, +5328 −13; 5068 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (18 s) | | clippy | ✅ (2 min 38 s) | | tests: workspace | ✅ 1965 passed (26 min 23 s) | | doc tests | ✅ 1 passed (4 min 7 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 326 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 314 more | | Label | `skip-release`: players see nothing without `HORIZON_SHADER_PACK` | Parity: 326 harnesses selected (the root `Cargo.toml`, then `gfx.rs` and `game.rs` in the last PR); CI runs them. The renderer changes only act when a pack is loaded: without `HORIZON_SHADER_PACK` the world target, depth stores and passes are as before. ## Needs Ludovic Nothing for this PR. Label `skip-release`: it runs only behind `HORIZON_SHADER_PACK`; the first visible slice is the Shader Packs page (slice 9). 🤖 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:11:17 +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#3665
No description provided.