[PR #5900] [MERGED] Shader API: set_surface and surface_at, per-pixel data for the post stage #6547

Closed
opened 2026-11-03 06:22:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5900
Author: @Teiwazik
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: shader/surface


📝 Commits (3)

  • e285098 Shader API: set_surface and surface_at, per-pixel data for the post stage
  • 90f08d3 Merge #5900 into the shader API union
  • 63250fd Merge main into the surface branch

📊 Changes

8 files changed (+313 additions, -36 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+123 -17)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+42 -7)
📝 crates/horizon-client-render/src/gfx/native_post.rs (+53 -8)
📝 crates/horizon-shader-api/src/reference.rs (+7 -2)
📝 crates/horizon-shader-api/src/stages.rs (+59 -1)
📝 crates/horizon-shader-api/tests/check.rs (+25 -1)
📝 docs/api/shaders-reference.md (+3 -0)
📝 docs/api/shaders.md (+1 -0)

📄 Description

🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally.

Fixes #5899.

What

  • Material stage: set_surface(normal, smoothness, data) stores these for a point of solid terrain. Unset, the point keeps its face's normal and 0 for both.
  • Post stage: surface_at(texel) returns present, normal, smoothness and data, and the raw scene_surface is bound at 11. The fragment's depth is stored too, so present is false wherever something nearer was drawn later (the sky, an entity, water, glass, a particle).
  • The renderer: an Rgba32Float target beside the world's colour, written by the solid terrain in passes of their own between the sky and everything else, with occlusion culling's test in a colour-only pass between its two phases.

Cost

A pack whose material stage doesn't call set_surface gets the world pass as before, with no extra passes and a 1x1 blank target: calls_set_surface decides this when the pack loads, counting calls beyond the prelude's own. A comment naming the function would turn the target on, which is harmless. A pack that calls it pays 16 bytes a pixel (about 31 MiB at 1908x1028, computed, not measured) and two or three more render passes. I have no frame time comparison for this: my two runs had different window sizes, so their numbers can't be compared.

Proof

  • only_a_material_that_calls_set_surface_needs_its_target covers the decision, for the sample pack and for one that calls it. The reference is regenerated.
  • In game, single player, a debug pack whose post pass draws surface_at on the left half of the screen and leaves the right half alone, over stone, planks, water, stained glass and a pig (shader pack stack_proof 0.1.0: material.wgsl, post/show.wgsl in 200 ms, no validation error):
    • Calling set_surface on upward faces: those show the one stored value everywhere. A plank wall's side shows its face's own normal. The sky, the water and the pig are present == false.
    • The same post pass with a material that doesn't call it: present is false on the whole left half.
  • Not tested: the flat draw path versus the instanced one separately, and a run with culling switched off. No screenshot attached: it would show Mojang's textures.

pr_ready (tools/pr_ready.py --quick on teiwazik-laptop, against origin/main at 9543d2a68, 1 min 40 s)

Check Result
Scope ✅ 8 files, +308 −32
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (41 s)
rustfmt ✅ (9 s)
clippy ✅ (29 s)
tests: horizon-client-render, horizon-shader-api ✅ 879 passed (20 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EBqm1v5zTsDGwuZF6XKFjL


🔄 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/5900 **Author:** [@Teiwazik](https://github.com/Teiwazik) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shader/surface` --- ### 📝 Commits (3) - [`e285098`](https://github.com/horizon-rust/horizon/commit/e2850986c9c54444d99b000a739cd974ffff2602) Shader API: set_surface and surface_at, per-pixel data for the post stage - [`90f08d3`](https://github.com/horizon-rust/horizon/commit/90f08d3fbbc5e9f652d638c63d8769a369f34d8f) Merge #5900 into the shader API union - [`63250fd`](https://github.com/horizon-rust/horizon/commit/63250fd4e8d859ad9dab4da9db41abf691e9bcab) Merge main into the surface branch ### 📊 Changes **8 files changed** (+313 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+123 -17) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+42 -7) 📝 `crates/horizon-client-render/src/gfx/native_post.rs` (+53 -8) 📝 `crates/horizon-shader-api/src/reference.rs` (+7 -2) 📝 `crates/horizon-shader-api/src/stages.rs` (+59 -1) 📝 `crates/horizon-shader-api/tests/check.rs` (+25 -1) 📝 `docs/api/shaders-reference.md` (+3 -0) 📝 `docs/api/shaders.md` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #5899. ## What - Material stage: `set_surface(normal, smoothness, data)` stores these for a point of solid terrain. Unset, the point keeps its face's normal and 0 for both. - Post stage: `surface_at(texel)` returns `present`, `normal`, `smoothness` and `data`, and the raw `scene_surface` is bound at 11. The fragment's depth is stored too, so `present` is false wherever something nearer was drawn later (the sky, an entity, water, glass, a particle). - The renderer: an `Rgba32Float` target beside the world's colour, written by the solid terrain in passes of their own between the sky and everything else, with occlusion culling's test in a colour-only pass between its two phases. ## Cost A pack whose material stage doesn't call `set_surface` gets the world pass as before, with no extra passes and a 1x1 blank target: `calls_set_surface` decides this when the pack loads, counting calls beyond the prelude's own. A comment naming the function would turn the target on, which is harmless. A pack that calls it pays 16 bytes a pixel (about 31 MiB at 1908x1028, computed, not measured) and two or three more render passes. I have no frame time comparison for this: my two runs had different window sizes, so their numbers can't be compared. ## Proof - `only_a_material_that_calls_set_surface_needs_its_target` covers the decision, for the sample pack and for one that calls it. The reference is regenerated. - In game, single player, a debug pack whose post pass draws `surface_at` on the left half of the screen and leaves the right half alone, over stone, planks, water, stained glass and a pig (`shader pack stack_proof 0.1.0: material.wgsl, post/show.wgsl in 200 ms`, no validation error): - Calling `set_surface` on upward faces: those show the one stored value everywhere. A plank wall's side shows its face's own normal. The sky, the water and the pig are `present == false`. - The same post pass with a material that doesn't call it: `present` is false on the whole left half. - Not tested: the flat draw path versus the instanced one separately, and a run with culling switched off. No screenshot attached: it would show Mojang's textures. **pr_ready** (`tools/pr_ready.py --quick` on teiwazik-laptop, against origin/main at 9543d2a68, 1 min 40 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +308 −32 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (41 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (29 s) | | tests: horizon-client-render, horizon-shader-api | ✅ 879 passed (20 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EBqm1v5zTsDGwuZF6XKFjL --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:22: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#6547
No description provided.