[PR #1863] [MERGED] Horizon shader packs: the sky stage runs in the game #3825

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • cad817c Horizon shader packs: the sky stage runs in the game

📊 Changes

9 files changed (+567 additions, -45 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+76 -21)
📝 crates/horizon-client/src/gfx/native_pack.rs (+20 -12)
📝 crates/horizon-client/src/gfx/native_post.rs (+17 -0)
➕ crates/horizon-client/src/gfx/native_sky.rs (+426 -0)
📝 crates/horizon-client/src/gfx/pack_timing.rs (+5 -0)
📝 crates/horizon-client/src/terrain.wgsl (+7 -3)
📝 crates/horizon-shader-api/src/check.rs (+5 -0)
📝 docs/api/shaders.md (+3 -2)
📝 docs/shaders.md (+8 -7)

📄 Description

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

#2051 (the frame shared by a pack's stages), #2028 and #2026 are merged; this builds on them.

What pack authors can do now

A Horizon shader pack's [sky] stage draws in the game. Its fn sky(input: SkyInput) -> vec4<f32> gets vanilla's colour along each view ray (the sky disc, its fog and the sunrise) and returns the colour to draw there. It draws where vanilla draws its sky dome (the Overworld's sky). The sun, moon, stars, clouds and dark disc still draw over it, and the output is opaque (alpha is ignored). The pack is picked on Options > Horizon Settings > Shader Packs and hot-reloads like its post passes. With F3 open, the sky gets a time of its own in the overlay. Golden Hour's "Warm horizon" sky now runs.

How

  • gfx/native_sky.rs:
    • The pipeline's shader is the pack's checked stage, from the new CheckedStage::source: the prelude, the shared files and the file, without the entry points.
    • A copy of terrain.wgsl's Globals, linear_fog and sky section follows it, with every name it declares prefixed horizon_sky_. The check refuses horizon_ names, so no pack name can clash.
    • A new entry, horizon_sky_fs_pack, calls sky.
    • Group 0 is the terrain's globals. Group 3 is the pack's frame, shared with its post passes (#2051).
  • terrain.wgsl: fs_sky's body moved into fn sky_along_ray(d), unchanged. Vanilla's sky draws the same pixels as before.
  • gfx.rs: with a sky stage, the world pass draws the pack's sky instead of vanilla's. In a timed frame (F3 open), the sky draws in a pass of its own, after a mark, so its GPU time is its own. That pass clears colour and depth; the world pass then loads them.
  • NativePack builds the sky and/or the post. On an error, the pack that ran keeps running.

Evidence

  • GPU test a_pack_gets_vanilla_s_colour_and_draws_opaque:
    • Vanilla's fs_sky and a pass-through pack give identical pixels.
    • An inverting pack with an option gives 255 - vanilla on every pixel, alpha 255.
  • Test the_renderer_s_sky_takes_a_prefix_and_validates_with_a_pack: the combined module passes naga validation when the pack declares its own PI and view_ray.
  • In the game (offscreen, Metal, isolated dirs). Screenshots are in ~/code/horizon-parity/screenshots/shaders-api-2/:
    • sky-west-off.png and sky-west-pack.png: sunset facing west, without and with Golden Hour. The pack's sky warms the horizon and turns the zenith pink-violet, and the sun and clouds draw over it.
    • sky-f3.png: F3 lists "Warm horizon" with its own time beside the post passes.
    • Earlier: a pass-through sky pack gave 0 differing bytes in the sky rows against no pack.

Self-check

pr_ready (tools/pr_ready.py --quick --base origin/feat/native-shader-frame on ludovics-mac-mini, against origin/feat/native-shader-frame at a68c2f587, 3 min 23 s)

Check Result
Scope ⚠️ 9 files, +567 −45; 592 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (7 s)
clippy ✅ (49 s)
tests: horizon-client, horizon-shader-api ✅ 1318 passed (1 min 58 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 77 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, chat_screen, command_exec, command_parse and 65 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Harnesses (tools/parity.py --changed origin/main at cad817c82, before #2051 merged, so its files too): 80 passed, 0 failed.

A/B, no pack (paired, alternating, 3 rounds of horizon-ctl bench 15, offscreen; the machine was busy): #2051's head CPU mean 0.758 ms, GPU mean 1.726 ms; this PR CPU mean 0.786 ms (0.877 / 0.736 / 0.746), GPU mean 1.781 ms (1.575 / 1.943 / 1.824). Within the run-to-run spread (the same rounds on #2026's head: CPU 0.743-0.875, GPU 1.458-2.003). Without a pack the frame does the same work as before, plus two Option checks.

Size: +567 −45, of which about 220 are native_sky.rs's tests. The part that changes no pixels is in #2051.

🤖 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/1863 **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-sky` --- ### 📝 Commits (1) - [`cad817c`](https://github.com/horizon-rust/horizon/commit/cad817c82de68ba3e7564a7d55cc5299427aa8a5) Horizon shader packs: the sky stage runs in the game ### 📊 Changes **9 files changed** (+567 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+76 -21) 📝 `crates/horizon-client/src/gfx/native_pack.rs` (+20 -12) 📝 `crates/horizon-client/src/gfx/native_post.rs` (+17 -0) ➕ `crates/horizon-client/src/gfx/native_sky.rs` (+426 -0) 📝 `crates/horizon-client/src/gfx/pack_timing.rs` (+5 -0) 📝 `crates/horizon-client/src/terrain.wgsl` (+7 -3) 📝 `crates/horizon-shader-api/src/check.rs` (+5 -0) 📝 `docs/api/shaders.md` (+3 -2) 📝 `docs/shaders.md` (+8 -7) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. #2051 (the frame shared by a pack's stages), #2028 and #2026 are merged; this builds on them. ## What pack authors can do now A Horizon shader pack's `[sky]` stage draws in the game. Its `fn sky(input: SkyInput) -> vec4<f32>` gets vanilla's colour along each view ray (the sky disc, its fog and the sunrise) and returns the colour to draw there. It draws where vanilla draws its sky dome (the Overworld's sky). The sun, moon, stars, clouds and dark disc still draw over it, and the output is opaque (alpha is ignored). The pack is picked on Options > Horizon Settings > Shader Packs and hot-reloads like its post passes. With F3 open, the sky gets a time of its own in the overlay. Golden Hour's "Warm horizon" sky now runs. ## How - `gfx/native_sky.rs`: - The pipeline's shader is the pack's checked stage, from the new `CheckedStage::source`: the prelude, the shared files and the file, without the entry points. - A copy of terrain.wgsl's `Globals`, `linear_fog` and sky section follows it, with every name it declares prefixed `horizon_sky_`. The check refuses `horizon_` names, so no pack name can clash. - A new entry, `horizon_sky_fs_pack`, calls `sky`. - Group 0 is the terrain's globals. Group 3 is the pack's `frame`, shared with its post passes (#2051). - terrain.wgsl: `fs_sky`'s body moved into `fn sky_along_ray(d)`, unchanged. Vanilla's sky draws the same pixels as before. - `gfx.rs`: with a sky stage, the world pass draws the pack's sky instead of vanilla's. In a timed frame (F3 open), the sky draws in a pass of its own, after a mark, so its GPU time is its own. That pass clears colour and depth; the world pass then loads them. - `NativePack` builds the sky and/or the post. On an error, the pack that ran keeps running. ## Evidence - GPU test `a_pack_gets_vanilla_s_colour_and_draws_opaque`: - Vanilla's `fs_sky` and a pass-through pack give identical pixels. - An inverting pack with an option gives `255 - vanilla` on every pixel, alpha 255. - Test `the_renderer_s_sky_takes_a_prefix_and_validates_with_a_pack`: the combined module passes naga validation when the pack declares its own `PI` and `view_ray`. - In the game (offscreen, Metal, isolated dirs). Screenshots are in `~/code/horizon-parity/screenshots/shaders-api-2/`: - `sky-west-off.png` and `sky-west-pack.png`: sunset facing west, without and with Golden Hour. The pack's sky warms the horizon and turns the zenith pink-violet, and the sun and clouds draw over it. - `sky-f3.png`: F3 lists "Warm horizon" with its own time beside the post passes. - Earlier: a pass-through sky pack gave 0 differing bytes in the sky rows against no pack. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base origin/feat/native-shader-frame` on ludovics-mac-mini, against origin/feat/native-shader-frame at a68c2f587, 3 min 23 s) | Check | Result | | --- | --- | | Scope | ⚠️ 9 files, +567 −45; 592 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (7 s) | | clippy | ✅ (49 s) | | tests: horizon-client, horizon-shader-api | ✅ 1318 passed (1 min 58 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 77 affected, to run in CI (--quick): arrow, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, breaking_model, cauldron, chat_screen, command_exec, command_parse and 65 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Harnesses (`tools/parity.py --changed origin/main` at cad817c82, before #2051 merged, so its files too): **80 passed, 0 failed**. A/B, no pack (paired, alternating, 3 rounds of `horizon-ctl bench 15`, offscreen; the machine was busy): #2051's head CPU mean 0.758 ms, GPU mean 1.726 ms; this PR CPU mean 0.786 ms (0.877 / 0.736 / 0.746), GPU mean 1.781 ms (1.575 / 1.943 / 1.824). Within the run-to-run spread (the same rounds on #2026's head: CPU 0.743-0.875, GPU 1.458-2.003). Without a pack the frame does the same work as before, plus two `Option` checks. Size: +567 −45, of which about 220 are `native_sky.rs`'s tests. The part that changes no pixels is in #2051. 🤖 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:35 +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#3825
No description provided.