[PR #5928] [MERGED] Shader API: the [vertex] stage, where corners of terrain are drawn #6567

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

📋 Pull Request Information

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

Base: main ← Head: shader/vertex


📝 Commits (10+)

📊 Changes

24 files changed (+382 additions, -44 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/native_material.rs (+43 -10)
📝 crates/horizon-client-render/src/gfx/native_pack.rs (+15 -2)
📝 crates/horizon-client-render/src/gfx/native_shadow.rs (+36 -13)
📝 crates/horizon-client-render/src/mesher.rs (+10 -2)
📝 crates/horizon-client-render/src/mesher/leaf_culling_tests.rs (+1 -0)
📝 crates/horizon-client-render/src/mesher/reuse_tests.rs (+2 -0)
📝 crates/horizon-client-render/src/streaming.rs (+8 -1)
📝 crates/horizon-client/examples/chunk_load_bench.rs (+1 -0)
📝 crates/horizon-client/examples/probe/section_mesh_fixture.rs (+1 -0)
📝 crates/horizon-client/src/game.rs (+8 -0)
📝 crates/horizon-client/src/game/native_shaders.rs (+22 -4)
📝 crates/horizon-client/src/game/shader_packs.rs (+5 -4)
📝 crates/horizon-client/tests/streaming_meshes.rs (+1 -0)
📝 crates/horizon-client/tests/tall_column.rs (+1 -0)
📝 crates/horizon-shader-api/src/check.rs (+1 -0)
📝 crates/horizon-shader-api/src/inputs.rs (+15 -0)
📝 crates/horizon-shader-api/src/manifest.rs (+62 -3)
📝 crates/horizon-shader-api/src/reference.rs (+1 -0)
📝 crates/horizon-shader-api/src/stages.rs (+39 -4)
📝 crates/horizon-shader-api/tests/check.rs (+25 -0)

...and 4 more files

📄 Description

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

Fixes #5927.

What

A [vertex] stage: fn vertex(input: VertexInput) -> vec3<f32> returns where a corner of terrain is drawn, camera-relative. Its input has the position, the sprite's uv, the [[materials]] id, light, the vertex colour, and the fluid's face and flag.

  • It needs a [material], and its file joins the material's module, so an override can be read by both and the terrain pass calls it directly. Its names must not clash with the material's.
  • The shadow pass builds it from the stage's own source with the same id table, so shadows follow what moves.
  • It reads frame only: no textures, because the pass's vertex stage has no other binding.

Cost

A pack without it, and everyone without a pack, gets an identity function in the terrain and shadow vertex shaders of native packs. Vanilla's own shaders aren't touched. I didn't measure the cost of a stage that does work.

Limits

  • The normal given to the material comes from the moved position's derivatives, so it tilts with the movement. A small sway gives a small tilt.
  • Culling doesn't know about the movement: a large offset can show faces the mesher culled, and a section can be culled with its moved corners still on screen. The stage suits small movement, as waving is.

Proof

  • a_vertex_stage_checks_alone_and_joins_the_material, a_vertex_stage_needs_a_material, and the reference test compiling the stage with an identity function.
  • In game, single player, with [shadow] and a debug vertex moving oak_planks 3 blocks along x by their material id, seen from above, with bricks beside them. Against the same pack without [vertex]:
    • The planks moved 3 blocks and their shadow moved with them. The bricks and their shadow didn't move.
    • The 3-block offset showed sky where the floor's top face under the planks was culled, as the limit above says.
    • No validation error in either run (shader pack stack_proof 0.1.0: material.wgsl in 206 ms).
  • Not tested: movement over time on screen (the debug offset was constant), the flat draw path separately, water, and an option read from this stage. No screenshot attached: it would show Mojang's textures.

pr_ready (tools/pr_ready.py --quick on teiwazik-laptop, against origin/main at 5bbecdc49, 1 min 17 s)

Check Result
Scope ✅ 13 files, +248 −30
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (40 s)
rustfmt ✅ (9 s)
clippy ❌ failed (13 s)
tests: horizon-client-render, horizon-shader-api ✅ 880 passed (13 s)
doc tests ✅ 0 passed (2 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)

The ❌ on clippy isn't from this branch: needless_borrow at crates/horizon-world/src/block_state_properties.rs:161, from d44fb4367 on main, on rustc 1.99.1 here. This branch doesn't touch that file. cargo clippy -p horizon-shader-api -p horizon-client-render -p horizon-client --all-targets --no-deps -- -D warnings is clean.

🤖 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/5928 **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/vertex` --- ### 📝 Commits (10+) - [`dc4a9f2`](https://github.com/horizon-rust/horizon/commit/dc4a9f24946b6283b4fef9aa817416fe604c9745) Shader API: [[materials]] blocks and translucent - [`724d94d`](https://github.com/horizon-rust/horizon/commit/724d94d0dd31c1392ceb689e6db563d891e3ea92) Shader API: the [vertex] stage, where corners of terrain are drawn - [`c41d1ee`](https://github.com/horizon-rust/horizon/commit/c41d1ee7b4214f01c85a4c31df548b4bedbf288e) Merge main: the lint fix - [`9f3a88a`](https://github.com/horizon-rust/horizon/commit/9f3a88a41de8fcbe3d67ae15764bfb26791e4393) Merge main: the lint fix - [`2947ff9`](https://github.com/horizon-rust/horizon/commit/2947ff96b2e6d7885106f3813e1cee9592fed233) Merge #5920 into the shader API union - [`47b5a77`](https://github.com/horizon-rust/horizon/commit/47b5a77bce9ca727dc53bd37c5688e749c540d77) Merge #5928 into the shader API union - [`c80ab3b`](https://github.com/horizon-rust/horizon/commit/c80ab3bbcdbb8ff4bb6c5ff542ee6503eb2b9708) Merge the branch below, with main - [`51643e9`](https://github.com/horizon-rust/horizon/commit/51643e956ac82f7166095426ad2dc5bf9b12091b) Merge the branch below, with main - [`b0fee0d`](https://github.com/horizon-rust/horizon/commit/b0fee0d30d5998348881719b3e0de4adaa6ab087) Merge main into shader/material-blocks (after #5926) - [`31d53c8`](https://github.com/horizon-rust/horizon/commit/31d53c8b47cc5f538115328a9bb7a5ea2e8a803d) Merge #5920's branch (main after #5926) into shader/vertex ### 📊 Changes **24 files changed** (+382 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/native_material.rs` (+43 -10) 📝 `crates/horizon-client-render/src/gfx/native_pack.rs` (+15 -2) 📝 `crates/horizon-client-render/src/gfx/native_shadow.rs` (+36 -13) 📝 `crates/horizon-client-render/src/mesher.rs` (+10 -2) 📝 `crates/horizon-client-render/src/mesher/leaf_culling_tests.rs` (+1 -0) 📝 `crates/horizon-client-render/src/mesher/reuse_tests.rs` (+2 -0) 📝 `crates/horizon-client-render/src/streaming.rs` (+8 -1) 📝 `crates/horizon-client/examples/chunk_load_bench.rs` (+1 -0) 📝 `crates/horizon-client/examples/probe/section_mesh_fixture.rs` (+1 -0) 📝 `crates/horizon-client/src/game.rs` (+8 -0) 📝 `crates/horizon-client/src/game/native_shaders.rs` (+22 -4) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+5 -4) 📝 `crates/horizon-client/tests/streaming_meshes.rs` (+1 -0) 📝 `crates/horizon-client/tests/tall_column.rs` (+1 -0) 📝 `crates/horizon-shader-api/src/check.rs` (+1 -0) 📝 `crates/horizon-shader-api/src/inputs.rs` (+15 -0) 📝 `crates/horizon-shader-api/src/manifest.rs` (+62 -3) 📝 `crates/horizon-shader-api/src/reference.rs` (+1 -0) 📝 `crates/horizon-shader-api/src/stages.rs` (+39 -4) 📝 `crates/horizon-shader-api/tests/check.rs` (+25 -0) _...and 4 more files_ </details> ### 📄 Description > 🤖 Opened by Teiwazik's AI agent (Claude Code, Claude Opus 5.5), not by Teiwazik personally. Fixes #5927. ## What A `[vertex]` stage: `fn vertex(input: VertexInput) -> vec3<f32>` returns where a corner of terrain is drawn, camera-relative. Its input has the position, the sprite's uv, the `[[materials]]` id, light, the vertex colour, and the fluid's face and flag. - It needs a `[material]`, and its file joins the material's module, so an override can be read by both and the terrain pass calls it directly. Its names must not clash with the material's. - The shadow pass builds it from the stage's own source with the same id table, so shadows follow what moves. - It reads `frame` only: no textures, because the pass's vertex stage has no other binding. ## Cost A pack without it, and everyone without a pack, gets an identity function in the terrain and shadow vertex shaders of native packs. Vanilla's own shaders aren't touched. I didn't measure the cost of a stage that does work. ## Limits - The normal given to the material comes from the moved position's derivatives, so it tilts with the movement. A small sway gives a small tilt. - Culling doesn't know about the movement: a large offset can show faces the mesher culled, and a section can be culled with its moved corners still on screen. The stage suits small movement, as waving is. ## Proof - `a_vertex_stage_checks_alone_and_joins_the_material`, `a_vertex_stage_needs_a_material`, and the reference test compiling the stage with an identity function. - In game, single player, with `[shadow]` and a debug `vertex` moving `oak_planks` 3 blocks along x by their material id, seen from above, with bricks beside them. Against the same pack without `[vertex]`: - The planks moved 3 blocks and their shadow moved with them. The bricks and their shadow didn't move. - The 3-block offset showed sky where the floor's top face under the planks was culled, as the limit above says. - No validation error in either run (`shader pack stack_proof 0.1.0: material.wgsl in 206 ms`). - Not tested: movement over time on screen (the debug offset was constant), the flat draw path separately, water, and an option read from this stage. No screenshot attached: it would show Mojang's textures. **pr_ready** (`tools/pr_ready.py --quick` on teiwazik-laptop, against origin/main at 5bbecdc49, 1 min 17 s) | Check | Result | | --- | --- | | Scope | ✅ 13 files, +248 −30 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (40 s) | | rustfmt | ✅ (9 s) | | clippy | ❌ failed (13 s) | | tests: horizon-client-render, horizon-shader-api | ✅ 880 passed (13 s) | | doc tests | ✅ 0 passed (2 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) | The ❌ on clippy isn't from this branch: `needless_borrow` at `crates/horizon-world/src/block_state_properties.rs:161`, from d44fb4367 on `main`, on rustc 1.99.1 here. This branch doesn't touch that file. `cargo clippy -p horizon-shader-api -p horizon-client-render -p horizon-client --all-targets --no-deps -- -D warnings` is clean. 🤖 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:23:10 +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#6567
No description provided.