[PR #1818] [MERGED] Horizon shader packs: the stages of API 0.1 and their generated reference #3789

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • 608d1a7 Horizon shader packs: the stages of API 0.1 and their generated reference

📊 Changes

12 files changed (+862 additions, -6 deletions)

View changed files

📝 Cargo.lock (+2 -0)
📝 crates/horizon-shader-api/Cargo.toml (+4 -0)
➕ crates/horizon-shader-api/src/inputs.rs (+218 -0)
📝 crates/horizon-shader-api/src/lib.rs (+5 -0)
📝 crates/horizon-shader-api/src/package.rs (+2 -2)
➕ crates/horizon-shader-api/src/reference.rs (+88 -0)
➕ crates/horizon-shader-api/src/stages.rs (+265 -0)
➕ crates/horizon-shader-api/tests/reference.rs (+119 -0)
📝 crates/horizon-shader-api/tests/samples/schema-1/README.md (+1 -1)
📝 crates/horizon-shader-api/tests/samples/schema-1/material.wgsl (+2 -1)
➕ docs/api/shaders-reference.md (+152 -0)
📝 docs/api/shaders.md (+4 -2)

📄 Description

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

Stacked on #1817 (the pack format); the diff below is only this step.

What

The stages of shader API 0.1, each a WGSL function with a fixed signature that Horizon calls inside its own pass, and the typed inputs generated from Rust:

Stage Manifest The pack's function
sky [sky] fn sky(input: SkyInput) -> vec4<f32>
material [material] fn material(input: MaterialInput) -> Surface
post [[post]] fn post(input: PostInput) -> vec4<f32>
  • Frame (inputs.rs) is the #[repr(C)] Pod struct the renderer will upload as frame (matrices, camera, sun/moon, day and game time, sky/fog colours, rain/thunder, fog distances, eye light and fluid, effects, dimension...). One macro defines the Rust struct, its WGSL, its field docs (unit and range) and offsets, so they can't disagree.
  • A stage's WGSL = generated prelude (the frame, the stage's structs, its resources in bind group 3, the post helpers depth_at and view_position) + the pack's shared files + its file + the entry points (horizon_*). The post entry points are the renderer's real ones; sky and material get entry points with the same inputs, used to check a pack. Composed::locate maps an offset back to the pack's file, line and column, for error messages.
  • docs/api/shaders-reference.md, generated (HORIZON_WRITE_DOCS=1 cargo test -p horizon-shader-api --test reference).

Groups 0-2 stay the renderer's; a native pack only ever binds group 3, so with no pack nothing changes in the renderer's pipelines. The renderer hooks are being agreed with cleanroom-impl-1 through the orchestrator.

How tested

cargo test -p horizon-shader-api: 10 passed
  reference.rs: every stage compiles (naga parse + validate) with vanilla's look written as the stage;
                naga's layout of the WGSL Frame == the Rust struct's offsets and size (the drift test);
                the sample pack's stages compile, and errors locate in the pack's own file and line;
                docs/api/shaders-reference.md is up to date
  schema.rs: 5 (from #1817)
cargo clippy -p horizon-shader-api --all-targets -- -D warnings: clean; cargo fmt --check: clean

No harness covers this crate; nothing in the game uses it yet.

Needs Ludovic

Nothing. skip-release.

🤖 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/1818 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-shaders-stages` --- ### 📝 Commits (1) - [`608d1a7`](https://github.com/horizon-rust/horizon/commit/608d1a70a74f80abd392fe458ab36d7ae42b0d67) Horizon shader packs: the stages of API 0.1 and their generated reference ### 📊 Changes **12 files changed** (+862 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -0) 📝 `crates/horizon-shader-api/Cargo.toml` (+4 -0) ➕ `crates/horizon-shader-api/src/inputs.rs` (+218 -0) 📝 `crates/horizon-shader-api/src/lib.rs` (+5 -0) 📝 `crates/horizon-shader-api/src/package.rs` (+2 -2) ➕ `crates/horizon-shader-api/src/reference.rs` (+88 -0) ➕ `crates/horizon-shader-api/src/stages.rs` (+265 -0) ➕ `crates/horizon-shader-api/tests/reference.rs` (+119 -0) 📝 `crates/horizon-shader-api/tests/samples/schema-1/README.md` (+1 -1) 📝 `crates/horizon-shader-api/tests/samples/schema-1/material.wgsl` (+2 -1) ➕ `docs/api/shaders-reference.md` (+152 -0) 📝 `docs/api/shaders.md` (+4 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1817 (the pack format); the diff below is only this step. ## What The stages of shader API 0.1, each a WGSL function with a fixed signature that Horizon calls inside its own pass, and the typed inputs generated from Rust: | Stage | Manifest | The pack's function | | --- | --- | --- | | sky | `[sky]` | `fn sky(input: SkyInput) -> vec4<f32>` | | material | `[material]` | `fn material(input: MaterialInput) -> Surface` | | post | `[[post]]` | `fn post(input: PostInput) -> vec4<f32>` | - `Frame` (`inputs.rs`) is the `#[repr(C)]` Pod struct the renderer will upload as `frame` (matrices, camera, sun/moon, day and game time, sky/fog colours, rain/thunder, fog distances, eye light and fluid, effects, dimension...). One macro defines the Rust struct, its WGSL, its field docs (unit and range) and offsets, so they can't disagree. - A stage's WGSL = generated prelude (the frame, the stage's structs, its resources in bind group 3, the post helpers `depth_at` and `view_position`) + the pack's `shared` files + its file + the entry points (`horizon_*`). The post entry points are the renderer's real ones; sky and material get entry points with the same inputs, used to check a pack. `Composed::locate` maps an offset back to the pack's file, line and column, for error messages. - `docs/api/shaders-reference.md`, generated (`HORIZON_WRITE_DOCS=1 cargo test -p horizon-shader-api --test reference`). Groups 0-2 stay the renderer's; a native pack only ever binds group 3, so with no pack nothing changes in the renderer's pipelines. The renderer hooks are being agreed with cleanroom-impl-1 through the orchestrator. ## How tested ``` cargo test -p horizon-shader-api: 10 passed reference.rs: every stage compiles (naga parse + validate) with vanilla's look written as the stage; naga's layout of the WGSL Frame == the Rust struct's offsets and size (the drift test); the sample pack's stages compile, and errors locate in the pack's own file and line; docs/api/shaders-reference.md is up to date schema.rs: 5 (from #1817) cargo clippy -p horizon-shader-api --all-targets -- -D warnings: clean; cargo fmt --check: clean ``` No harness covers this crate; nothing in the game uses it yet. ## Needs Ludovic Nothing. `skip-release`. 🤖 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:19 +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#3789
No description provided.