[PR #1698] [MERGED] Shader packs, clean room 14: terrain drawn by the pack's program #3698

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

📋 Pull Request Information

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

Base: main ← Head: feat/shader-packs-terrain-draw


📝 Commits (3)

  • 0f9de6d Shader packs, clean room 14: terrain drawn by the pack's program
  • 2f527aa Merge remote-tracking branch 'origin/main' into feat/shader-packs-terrain-draw
  • 7bbd715 Merge origin/main into feat/shader-packs-terrain-draw

📊 Changes

12 files changed (+700 additions, -280 deletions)

View changed files

📝 crates/horizon-client/src/game/shader_packs.rs (+2 -1)
📝 crates/horizon-client/src/gfx.rs (+91 -13)
📝 crates/horizon-client/src/gfx/flat.rs (+2 -1)
📝 crates/horizon-client/src/gfx/pack_atlas.rs (+64 -5)
📝 crates/horizon-client/src/gfx/pack_post.rs (+459 -257)
📝 crates/horizon-client/src/gfx/pack_post.wgsl (+4 -3)
📝 crates/horizon-client/src/gfx/pack_uniforms.rs (+5 -0)
➕ crates/horizon-shaders/tests/packs/terrain-test/README.md (+8 -0)
➕ crates/horizon-shaders/tests/packs/terrain-test/shaders/composite.fsh (+19 -0)
➕ crates/horizon-shaders/tests/packs/terrain-test/shaders/composite.vsh (+8 -0)
➕ crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_terrain.fsh (+22 -0)
➕ crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_terrain.vsh (+16 -0)

📄 Description

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

Shader packs, clean room 14 (slice 6d): terrain drawn by the pack's program. Stacked on #1697.

What

With a pack whose terrain program loads, solid and cutout terrain is drawn by it into the pack's buffers, in place, between prepare and deferred, and Horizon's own solid terrain draw is skipped (translucent terrain stays Horizon's until the water slice).

  • depthtex0 becomes a Depth32Float attachment: the blit writes the world's depth there (GL window depth, GL rows), terrain tests and writes against it, so entities and terrain occlude each other; later programs sample it as before.
  • Vertex glue reads Horizon's TerrainVertex on both draw paths (instanced, and flat with the page tables in bind group 1): atlas coordinates, lightmap coordinates, vertex colour, mc_midTexCoord at the sprite's centre, mc_Entity = -1. Normals, tangents and block ids come in a later PR.
  • texture/gtexture/tex sample the block atlas of #1670, lightmap the lightmap; atlasSize is set. Uniforms a program reads that are not provided yet are listed in the log.
  • Occlusion culling is off while a pack draws terrain (it reads the depth of Horizon's own terrain draw) and flat draws stay on.
  • build_pass/bind are shared by full-screen and terrain passes: most of pack_post.rs's ~700-line diff is code moved out of PackPost::new, not new code.
  • tests/packs/terrain-test: Horizon's own pack for this slice (atlas, lightmap, sky-light tint, a dot at mc_midTexCoord, view distance in a composite).

Clean room

Clean-room: implemented from cleanroom/shader-packs-spec.md revision 1, §2.1, §5.1, §5.2, §5.5, §6.1; no other loader's code read.

How tested

  • terrain-test screenshots on both single-player paths (server thread and --in-frame): blocks from the atlas the right way up, mid-texture dots in each block's centre, depth and occlusion right against entities and the hand.
  • Benchmark with terrain-test (720p, RD 8, Mac mini under load ~50, noisy): median 1678 vs 1851 FPS without a pack (90.7%). A rerun on a quieter machine and the performance work toward ≥95% follow.

Self-check (whole stack, on its top branch feat/shader-packs-real-buffers)

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 07e46daa5, 7 min 3 s)

Check Result
Scope ⚠️ 41 files, +6862 −25; 6553 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (24 s)
tests: workspace ✅ 1974 passed (5 min 47 s)
doc tests ✅ 1 passed (47 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: 326 harnesses selected (the root Cargo.toml and gfx.rs earlier in the stack); CI runs them. Nothing here acts without HORIZON_SHADER_PACK. The Label row is the tool's generic hint: these PRs are skip-release.

Needs Ludovic

Nothing. Label skip-release: it runs only behind HORIZON_SHADER_PACK.

🤖 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/1698 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-packs-terrain-draw` --- ### 📝 Commits (3) - [`0f9de6d`](https://github.com/horizon-rust/horizon/commit/0f9de6dbb0ce0e1aeef50e5b960a3040357a6132) Shader packs, clean room 14: terrain drawn by the pack's program - [`2f527aa`](https://github.com/horizon-rust/horizon/commit/2f527aaaf24e9e4bc077e23f21d2edbf0f79a393) Merge remote-tracking branch 'origin/main' into feat/shader-packs-terrain-draw - [`7bbd715`](https://github.com/horizon-rust/horizon/commit/7bbd715c8cc7c1116490bf58a3d3fb8aaf89e41f) Merge origin/main into feat/shader-packs-terrain-draw ### 📊 Changes **12 files changed** (+700 additions, -280 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/shader_packs.rs` (+2 -1) 📝 `crates/horizon-client/src/gfx.rs` (+91 -13) 📝 `crates/horizon-client/src/gfx/flat.rs` (+2 -1) 📝 `crates/horizon-client/src/gfx/pack_atlas.rs` (+64 -5) 📝 `crates/horizon-client/src/gfx/pack_post.rs` (+459 -257) 📝 `crates/horizon-client/src/gfx/pack_post.wgsl` (+4 -3) 📝 `crates/horizon-client/src/gfx/pack_uniforms.rs` (+5 -0) ➕ `crates/horizon-shaders/tests/packs/terrain-test/README.md` (+8 -0) ➕ `crates/horizon-shaders/tests/packs/terrain-test/shaders/composite.fsh` (+19 -0) ➕ `crates/horizon-shaders/tests/packs/terrain-test/shaders/composite.vsh` (+8 -0) ➕ `crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_terrain.fsh` (+22 -0) ➕ `crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_terrain.vsh` (+16 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Shader packs, clean room 14 (slice 6d):** terrain drawn by the pack's program. Stacked on #1697. ## What With a pack whose terrain program loads, solid and cutout terrain is drawn by it into the pack's buffers, in place, between `prepare` and `deferred`, and Horizon's own solid terrain draw is skipped (translucent terrain stays Horizon's until the water slice). - `depthtex0` becomes a `Depth32Float` attachment: the blit writes the world's depth there (GL window depth, GL rows), terrain tests and writes against it, so entities and terrain occlude each other; later programs sample it as before. - Vertex glue reads Horizon's `TerrainVertex` on both draw paths (instanced, and flat with the page tables in bind group 1): atlas coordinates, lightmap coordinates, vertex colour, `mc_midTexCoord` at the sprite's centre, `mc_Entity = -1`. Normals, tangents and block ids come in a later PR. - `texture`/`gtexture`/`tex` sample the block atlas of #1670, `lightmap` the lightmap; `atlasSize` is set. Uniforms a program reads that are not provided yet are listed in the log. - Occlusion culling is off while a pack draws terrain (it reads the depth of Horizon's own terrain draw) and flat draws stay on. - `build_pass`/`bind` are shared by full-screen and terrain passes: most of `pack_post.rs`'s ~700-line diff is code moved out of `PackPost::new`, not new code. - `tests/packs/terrain-test`: Horizon's own pack for this slice (atlas, lightmap, sky-light tint, a dot at `mc_midTexCoord`, view distance in a composite). ## Clean room Clean-room: implemented from `cleanroom/shader-packs-spec.md` revision 1, §2.1, §5.1, §5.2, §5.5, §6.1; no other loader's code read. ## How tested - `terrain-test` screenshots on both single-player paths (server thread and `--in-frame`): blocks from the atlas the right way up, mid-texture dots in each block's centre, depth and occlusion right against entities and the hand. - Benchmark with `terrain-test` (720p, RD 8, Mac mini under load ~50, noisy): median 1678 vs 1851 FPS without a pack (90.7%). A rerun on a quieter machine and the performance work toward ≥95% follow. ## Self-check (whole stack, on its top branch `feat/shader-packs-real-buffers`) **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 07e46daa5, 7 min 3 s) | Check | Result | | --- | --- | | Scope | ⚠️ 41 files, +6862 −25; 6553 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (24 s) | | tests: workspace | ✅ 1974 passed (5 min 47 s) | | doc tests | ✅ 1 passed (47 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: 326 harnesses selected (the root `Cargo.toml` and `gfx.rs` earlier in the stack); CI runs them. Nothing here acts without `HORIZON_SHADER_PACK`. The Label row is the tool's generic hint: these PRs are `skip-release`. ## Needs Ludovic Nothing. Label `skip-release`: it runs only behind `HORIZON_SHADER_PACK`. 🤖 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:11:31 +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#3698
No description provided.