[PR #4335] [MERGED] Shader API: the material stage sees what lies behind translucent terrain #5568

Closed
opened 2026-11-03 05:13:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4335
Author: @Teiwazik
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: shader/s1-material-behind


📝 Commits (5)

  • fa845cd Shader API: the material stage sees what lies behind translucent terrain
  • 3dbcf3c Merge remote-tracking branch 'origin/main' into pr4335
  • 3f0b8f2 Merge remote-tracking branch 'origin/main' into shader/s1-material-behind
  • 59f37f9 Merge origin/main into shader/s1-material-behind
  • a8763ea Merge remote-tracking branch 'origin/main' into a3-pr-4335

📊 Changes

8 files changed (+202 additions, -18 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+41 -1)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+5 -2)
📝 crates/horizon-client-render/src/gfx/native_post.rs (+122 -11)
📝 crates/horizon-client-render/src/gfx/world_post.rs (+5 -2)
📝 crates/horizon-shader-api/src/inputs.rs (+1 -0)
📝 crates/horizon-shader-api/src/stages.rs (+22 -2)
📝 docs/api/shaders-reference.md (+3 -0)
📝 docs/api/shaders.md (+3 -0)

📄 Description

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

Fixes #4334

What and why

The material stage could not see what lies behind water or glass. Within API 0.1, additively:

  • MaterialInput.screen (new last field): the point's place on the screen, 0..1 from the top left.
  • opaque_depth (group 3, binding 6, texture_depth_2d, reversed like scene_depth) and opaque_color (binding 11, texture_2d<f32>, read with textureLoad) in the material prelude.
  • NativeFrame keeps both copies at the world targets' size (fit_opaque); the frame group (shared with the sky, which declares neither) is made again when they change.
  • Before translucent terrain the world pass ends, depth and colour are copied, and world_pass_after_culling carries on; while a material stage runs the depth is stored across that break. The colour can only be copied from the scaled world target: when the world draws straight to the window it stays a black 1×1 (documented).
  • Bindings 6 and 11 leave room for the material stage's later resources (reflection, shadow map) without renumbering.

Tested in the game with a small pack whose water goes from green to dark with the depth behind it (opaque_depth against the point's distance): the shallows and the deep middle of a lake come out as expected, solid terrain unchanged.

#4186 also appends a field to MaterialInput (tags); whichever merges second needs a one-line rebase.

pr_ready

pr_ready (tools/pr_ready.py --quick on Teiwazik, against origin/main at 68f036059, 4 min 17 s)

Check Result
Scope ✅ 8 files, +204 −19
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 18 s)
rustfmt ✅ (14 s)
clippy ✅ (1 min 19 s)
tests: horizon-client-render, horizon-shader-api ✅ 588 passed (57 s)
doc tests ✅ 0 passed (25 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


🔄 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/4335 **Author:** [@Teiwazik](https://github.com/Teiwazik) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shader/s1-material-behind` --- ### 📝 Commits (5) - [`fa845cd`](https://github.com/horizon-rust/horizon/commit/fa845cd5802713d4824f42f296eaf99b52792dd8) Shader API: the material stage sees what lies behind translucent terrain - [`3dbcf3c`](https://github.com/horizon-rust/horizon/commit/3dbcf3c6c66104f76353df7352d14d12889409ec) Merge remote-tracking branch 'origin/main' into pr4335 - [`3f0b8f2`](https://github.com/horizon-rust/horizon/commit/3f0b8f293a23a926c17f1f87c2948182e4b32889) Merge remote-tracking branch 'origin/main' into shader/s1-material-behind - [`59f37f9`](https://github.com/horizon-rust/horizon/commit/59f37f92fb9b5f2392967f06c14f90727de84d02) Merge origin/main into shader/s1-material-behind - [`a8763ea`](https://github.com/horizon-rust/horizon/commit/a8763ea259a1347850afacca53e4ba330abfbbe1) Merge remote-tracking branch 'origin/main' into a3-pr-4335 ### 📊 Changes **8 files changed** (+202 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+41 -1) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+5 -2) 📝 `crates/horizon-client-render/src/gfx/native_post.rs` (+122 -11) 📝 `crates/horizon-client-render/src/gfx/world_post.rs` (+5 -2) 📝 `crates/horizon-shader-api/src/inputs.rs` (+1 -0) 📝 `crates/horizon-shader-api/src/stages.rs` (+22 -2) 📝 `docs/api/shaders-reference.md` (+3 -0) 📝 `docs/api/shaders.md` (+3 -0) </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #4334 ## What and why The material stage could not see what lies behind water or glass. Within API 0.1, additively: - `MaterialInput.screen` (new last field): the point's place on the screen, 0..1 from the top left. - `opaque_depth` (group 3, binding 6, `texture_depth_2d`, reversed like `scene_depth`) and `opaque_color` (binding 11, `texture_2d<f32>`, read with `textureLoad`) in the material prelude. - `NativeFrame` keeps both copies at the world targets' size (`fit_opaque`); the frame group (shared with the sky, which declares neither) is made again when they change. - Before translucent terrain the world pass ends, depth and colour are copied, and `world_pass_after_culling` carries on; while a material stage runs the depth is stored across that break. The colour can only be copied from the scaled world target: when the world draws straight to the window it stays a black 1×1 (documented). - Bindings 6 and 11 leave room for the material stage's later resources (reflection, shadow map) without renumbering. Tested in the game with a small pack whose water goes from green to dark with the depth behind it (`opaque_depth` against the point's distance): the shallows and the deep middle of a lake come out as expected, solid terrain unchanged. #4186 also appends a field to `MaterialInput` (`tags`); whichever merges second needs a one-line rebase. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick` on Teiwazik, against origin/main at 68f036059, 4 min 17 s) | Check | Result | | --- | --- | | Scope | ✅ 8 files, +204 −19 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 18 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (1 min 19 s) | | tests: horizon-client-render, horizon-shader-api | ✅ 588 passed (57 s) | | doc tests | ✅ 0 passed (25 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:27 +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#5568
No description provided.