[PR #4359] [CLOSED] Shader API: the material stage's face, fluid, emission, normal and tangent #5582

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4359
Author: @Teiwazik
Created: 10/30/2026
Status: ❌ Closed

Base: main ← Head: shader/s4-material-surface


📝 Commits (10+)

  • 951c7d5 Shader API: the frame's motion since the last one, and the eye's light eased
  • 07d3026 Shader API: the post stage's history, last frame's input to the last pass
  • f9ef4e0 Shader API: the material stage's face, fluid, emission, normal and tangent
  • 252ac76 Merge branch 'pr4335' into pr4345
  • ff2bf4e Merge branch 'shader/s2-frame-motion' into shader/s3-post-history
  • f8184ab Merge branch 'shader/s3-post-history' into shader/s4-material-surface
  • c20250b Merge branch 'shader/s3-post-history' into shader/s4-material-surface
  • 9e867ea Merge branch 'shader/s2-frame-motion' into shader/s3-post-history
  • 07cd25f Shader API: a gap between frames forgets the frame before
  • 360f52d Shader API: flowing water keeps its slope in MaterialInput.normal

📊 Changes

11 files changed (+462 additions, -33 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+2 -0)
📝 crates/horizon-client-render/src/gfx/native_material.rs (+25 -3)
📝 crates/horizon-client-render/src/gfx/native_post.rs (+266 -10)
📝 crates/horizon-client-render/src/lod/mesh.rs (+9 -2)
📝 crates/horizon-client-render/src/mesher.rs (+43 -1)
📝 crates/horizon-client-render/src/mesher/fluid.rs (+18 -9)
📝 crates/horizon-client/examples/probe/section_mesh_fixture.rs (+2 -2)
📝 crates/horizon-shader-api/src/inputs.rs (+24 -2)
📝 crates/horizon-shader-api/src/stages.rs (+53 -4)
📝 docs/api/shaders-reference.md (+12 -0)
📝 docs/api/shaders.md (+8 -0)

📄 Description

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

Fixes #4358

Builds on #4349 (and #4345, #4335 under it); this PR's own change is the last commit (8 files, +131 −17).

What and why

  • MaterialInput gains face, fluid, emission, normal and tangent, appended after screen:
    • face and fluid (0 none, 1 water, 2 lava) let a pack shade water and lava apart from glass and stone, and their tops apart from their sides;
    • emission is the face's HDR tier (mesher::hdr_tier) as 0..1: a redstone torch 7/15, a torch or lava 14/15, glowstone 1;
    • normal and tangent come from the derivatives of the position and uv. The normal snaps to an axis within a few degrees, so distant full block faces do not shimmer. Together they turn a normal map into world axes.
  • The meshers (mesher/fluid.rs, and lod/mesh.rs for the distant tiles) mark fluid quads with mesher::fluid_face: 8 plus the face in the high nibble of the colour's alpha byte. terrain.wgsl reads only the low nibble (the emission), so vanilla drawing is unchanged. The material entries decode the byte per vertex, and the pass tells water (translucent) from lava (solid).
  • The normal and tangent helpers live in the material prelude, so the checker's entries and the renderer's compute them the same way.

Tests: fluid_faces_keep_the_colour_and_the_emission, and the renderer's material test shader now reads every new field.

Related: #4186 also appends fields to MaterialInput (sprite tags, weather); whichever lands second only reorders the constructor call.

pr_ready

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

Check Result
Scope ⚠️ 11 files, +554 −38; 566 lines of code: over 500, split it if it can ship in parts (the stack under it; this PR's own commit is +131 −17)
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (1 min 3 s)
rustfmt ✅ (10 s)
clippy ✅ (1 min 8 s)
tests: horizon-client-render, horizon-shader-api ✅ 590 passed (58 s)
doc tests ✅ 0 passed (20 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/4359 **Author:** [@Teiwazik](https://github.com/Teiwazik) **Created:** 10/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `shader/s4-material-surface` --- ### 📝 Commits (10+) - [`951c7d5`](https://github.com/horizon-rust/horizon/commit/951c7d5165d02d68f47d89fb1f2033efd5b9b6c0) Shader API: the frame's motion since the last one, and the eye's light eased - [`07d3026`](https://github.com/horizon-rust/horizon/commit/07d302639ecb87e90e0127669cdc54adaff8d98f) Shader API: the post stage's history, last frame's input to the last pass - [`f9ef4e0`](https://github.com/horizon-rust/horizon/commit/f9ef4e0ea0dd0ab14ff52392cf792c3706bc774f) Shader API: the material stage's face, fluid, emission, normal and tangent - [`252ac76`](https://github.com/horizon-rust/horizon/commit/252ac76369990b6ef98615f6a125d769ec407707) Merge branch 'pr4335' into pr4345 - [`ff2bf4e`](https://github.com/horizon-rust/horizon/commit/ff2bf4e6706e9f107da0fb8c2c2587216c985356) Merge branch 'shader/s2-frame-motion' into shader/s3-post-history - [`f8184ab`](https://github.com/horizon-rust/horizon/commit/f8184ab1fb0aa8f3df1e5c779f5a9d980e852340) Merge branch 'shader/s3-post-history' into shader/s4-material-surface - [`c20250b`](https://github.com/horizon-rust/horizon/commit/c20250bf7573ea04af8c73ae86bf88971821788c) Merge branch 'shader/s3-post-history' into shader/s4-material-surface - [`9e867ea`](https://github.com/horizon-rust/horizon/commit/9e867eacf6260535e2bd3057c83b333c89f4a643) Merge branch 'shader/s2-frame-motion' into shader/s3-post-history - [`07cd25f`](https://github.com/horizon-rust/horizon/commit/07cd25f8192cba96c10092165f1db1943d7580a6) Shader API: a gap between frames forgets the frame before - [`360f52d`](https://github.com/horizon-rust/horizon/commit/360f52d328c8e337d3ffeb7d3428a18c8fdaa3c3) Shader API: flowing water keeps its slope in MaterialInput.normal ### 📊 Changes **11 files changed** (+462 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+2 -0) 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+25 -3) 📝 `crates/horizon-client-render/src/gfx/native_post.rs` (+266 -10) 📝 `crates/horizon-client-render/src/lod/mesh.rs` (+9 -2) 📝 `crates/horizon-client-render/src/mesher.rs` (+43 -1) 📝 `crates/horizon-client-render/src/mesher/fluid.rs` (+18 -9) 📝 `crates/horizon-client/examples/probe/section_mesh_fixture.rs` (+2 -2) 📝 `crates/horizon-shader-api/src/inputs.rs` (+24 -2) 📝 `crates/horizon-shader-api/src/stages.rs` (+53 -4) 📝 `docs/api/shaders-reference.md` (+12 -0) 📝 `docs/api/shaders.md` (+8 -0) </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #4358 Builds on #4349 (and #4345, #4335 under it); this PR's own change is the last commit (8 files, +131 −17). ## What and why - `MaterialInput` gains `face`, `fluid`, `emission`, `normal` and `tangent`, appended after `screen`: - `face` and `fluid` (0 none, 1 water, 2 lava) let a pack shade water and lava apart from glass and stone, and their tops apart from their sides; - `emission` is the face's HDR tier (`mesher::hdr_tier`) as 0..1: a redstone torch 7/15, a torch or lava 14/15, glowstone 1; - `normal` and `tangent` come from the derivatives of the position and uv. The normal snaps to an axis within a few degrees, so distant full block faces do not shimmer. Together they turn a normal map into world axes. - The meshers (`mesher/fluid.rs`, and `lod/mesh.rs` for the distant tiles) mark fluid quads with `mesher::fluid_face`: 8 plus the face in the high nibble of the colour's alpha byte. `terrain.wgsl` reads only the low nibble (the emission), so vanilla drawing is unchanged. The material entries decode the byte per vertex, and the pass tells water (translucent) from lava (solid). - The normal and tangent helpers live in the material prelude, so the checker's entries and the renderer's compute them the same way. Tests: `fluid_faces_keep_the_colour_and_the_emission`, and the renderer's material test shader now reads every new field. Related: #4186 also appends fields to `MaterialInput` (sprite tags, weather); whichever lands second only reorders the constructor call. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick` on Teiwazik, against origin/main at 68f036059, 3 min 43 s) | Check | Result | | --- | --- | | Scope | ⚠️ 11 files, +554 −38; 566 lines of code: over 500, split it if it can ship in parts (the stack under it; this PR's own commit is +131 −17) | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (1 min 3 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (1 min 8 s) | | tests: horizon-client-render, horizon-shader-api | ✅ 590 passed (58 s) | | doc tests | ✅ 0 passed (20 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:33 +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#5582
No description provided.