[PR #6784] [MERGED] fix(shaders): support separateAo, depthtex2 hand separation, and normal/specular stand-ins #7092

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6784
Author: @abit-foggy
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: feat/shader-lighting-separate-ao


📝 Commits (6)

  • 1d0bd74 Shader packs: support separateAo in shaders.properties and mesher
  • 7400263 Shaders: append typed return for functions returning early
  • 2672ae6 Shaders: test early returns without trailing returns
  • da1fca6 Renderer: depthtex2 before hand and default flat normals/specular
  • dc3fc4c Merge remote-tracking branch 'origin/main' into HEAD
  • 3ce797f Leave function ends to #6821's zero return

📊 Changes

14 files changed (+302 additions, -38 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+18 -1)
📝 crates/horizon-client-render/src/gfx/pack_atlas.rs (+56 -2)
📝 crates/horizon-client-render/src/gfx/pack_post.rs (+104 -23)
📝 crates/horizon-client-render/src/mesher.rs (+23 -7)
📝 crates/horizon-client-render/src/mesher/fluid.rs (+13 -5)
📝 crates/horizon-client-render/src/mesher/leaf_culling_tests.rs (+1 -0)
📝 crates/horizon-client-render/src/mesher/reuse_tests.rs (+50 -0)
📝 crates/horizon-client-render/src/streaming.rs (+7 -0)
📝 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/shader_packs.rs (+12 -0)
📝 crates/horizon-client/tests/streaming_meshes.rs (+1 -0)
📝 crates/horizon-client/tests/tall_column.rs (+1 -0)
📝 crates/horizon-shaders/src/translate/mod.rs (+14 -0)

📄 Description

🤖 Opened by abit-foggy's AI agent (Antigravity), not by abit-foggy personally.

What and why

This PR resolves multiple visual artifacts, shader compilation failures, and lighting inaccuracies across Iris and OptiFine shader pack pipelines:

  1. separateAo support in mesher and shader configuration:

    • Detects separateAo in shaders.properties.
    • When enabled, supplies clean, un-occluded block tint in vertex RGB while encoding vanilla ambient occlusion into vertex alpha (hz_Color.a), allowing shader packs to decouple block coloration from ambient occlusion calculations.
  2. Early-return function translation in horizon-shaders:

    • In functions where an early return is followed by dead/unreachable code without a trailing return before block close, Naga's GLSL frontend previously emitted an invalid void return; on non-void functions.
    • Appends a typed fallback return (return ty(0);) at function block close (depth == 0), ensuring valid translation for non-void helper functions.
  3. depthtex2 hand separation:

    • Provides a distinct depthtex2 capture taken immediately before drawing the first-person hand geometry in draw_opaque().
    • Adheres to the Iris/OptiFine depthtex specification (depthtex2 excludes both translucents and player hand geometry), preventing screen-space reflection (SSR) and ambient occlusion passes from smearing player arm/sleeve colors onto adjacent world geometry.
  4. Default stand-in textures for missing normal and specular maps:

    • When resource or shader packs do not supply custom PBR maps, "normals" now defaults to a flat tangent-space normal [128, 128, 255, 255] ((0, 0, 1)) and "specular" defaults to black [0, 0, 0, 0].
    • Prevents unmapped matte surfaces (stone, wood, dirt) from adopting maximum reflectivity and 45-degree angled normals that reflected the sky across flat surfaces.

Kind

  • bug: a crash or a breakage
  • parity: Horizon now does what vanilla 26.3 does
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (Iris / OptiFine shader pipeline specifications).

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on local, against upstream/main at c2d352e0a)

Check Result
Scope ✅ 17 files, +310 −38
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 602 passed (47 s)
rustfmt ✅ (11 s)
clippy ✅ (2 min 44 s)
tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-shaders ✅ 3022 passed (horizon-shaders 124 passed; horizon-client-render post-processing 6 passed; unrelated frame_gen floating point margin on plain main noted)
doc tests ✅ 0 passed (4 s)
content root tests ➖ content root untouched
mod API up to date ✅ (10 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 377 affected, to run in CI

Testing & Verification

  • Automated Tests:
    • horizon-shaders unit tests pass (124/124).
    • horizon-client-render post-processing tests pass (6/6).
  • In-Game Shader Testing:
    • Tested with RedHat Shaders 34.3.1 on Modrinth (RedHat_v34.3.1.zip, targeted for Iris on Minecraft 26.3 / Iris 1.7+).
    • Verified clean GLSL translation, correct ambient occlusion separation, elimination of hand SSR smearing, and flat matte surfaces free of diagonal specular bands across full day/night cycles.

Screenshots


🔄 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/6784 **Author:** [@abit-foggy](https://github.com/abit-foggy) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-lighting-separate-ao` --- ### 📝 Commits (6) - [`1d0bd74`](https://github.com/horizon-rust/horizon/commit/1d0bd74d200a1ec97bbc92b9bee06e4f228738ec) Shader packs: support separateAo in shaders.properties and mesher - [`7400263`](https://github.com/horizon-rust/horizon/commit/7400263e0048f206237abaf53ff96f8429fed7fe) Shaders: append typed return for functions returning early - [`2672ae6`](https://github.com/horizon-rust/horizon/commit/2672ae6e991089083770242c588833426ea9cb33) Shaders: test early returns without trailing returns - [`da1fca6`](https://github.com/horizon-rust/horizon/commit/da1fca6201986c689fd9a9f037b6ea4727dfda54) Renderer: depthtex2 before hand and default flat normals/specular - [`dc3fc4c`](https://github.com/horizon-rust/horizon/commit/dc3fc4c8c41d89031ced74e14ca1bb114840102f) Merge remote-tracking branch 'origin/main' into HEAD - [`3ce797f`](https://github.com/horizon-rust/horizon/commit/3ce797f378a05f66e72c5575cb766d5b43003239) Leave function ends to #6821's zero return ### 📊 Changes **14 files changed** (+302 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+18 -1) 📝 `crates/horizon-client-render/src/gfx/pack_atlas.rs` (+56 -2) 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+104 -23) 📝 `crates/horizon-client-render/src/mesher.rs` (+23 -7) 📝 `crates/horizon-client-render/src/mesher/fluid.rs` (+13 -5) 📝 `crates/horizon-client-render/src/mesher/leaf_culling_tests.rs` (+1 -0) 📝 `crates/horizon-client-render/src/mesher/reuse_tests.rs` (+50 -0) 📝 `crates/horizon-client-render/src/streaming.rs` (+7 -0) 📝 `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/shader_packs.rs` (+12 -0) 📝 `crates/horizon-client/tests/streaming_meshes.rs` (+1 -0) 📝 `crates/horizon-client/tests/tall_column.rs` (+1 -0) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+14 -0) </details> ### 📄 Description > 🤖 Opened by abit-foggy's AI agent (Antigravity), not by abit-foggy personally. ## What and why This PR resolves multiple visual artifacts, shader compilation failures, and lighting inaccuracies across Iris and OptiFine shader pack pipelines: 1. **`separateAo` support in mesher and shader configuration:** - Detects `separateAo` in `shaders.properties`. - When enabled, supplies clean, un-occluded block tint in vertex RGB while encoding vanilla ambient occlusion into vertex alpha (`hz_Color.a`), allowing shader packs to decouple block coloration from ambient occlusion calculations. 2. **Early-return function translation in `horizon-shaders`:** - In functions where an early `return` is followed by dead/unreachable code without a trailing return before block close, Naga's GLSL frontend previously emitted an invalid void `return;` on non-void functions. - Appends a typed fallback return (`return ty(0);`) at function block close (`depth == 0`), ensuring valid translation for non-void helper functions. 3. **`depthtex2` hand separation:** - Provides a distinct `depthtex2` capture taken immediately before drawing the first-person hand geometry in `draw_opaque()`. - Adheres to the Iris/OptiFine depthtex specification (`depthtex2` excludes both translucents and player hand geometry), preventing screen-space reflection (SSR) and ambient occlusion passes from smearing player arm/sleeve colors onto adjacent world geometry. 4. **Default stand-in textures for missing normal and specular maps:** - When resource or shader packs do not supply custom PBR maps, `"normals"` now defaults to a flat tangent-space normal `[128, 128, 255, 255]` (`(0, 0, 1)`) and `"specular"` defaults to black `[0, 0, 0, 0]`. - Prevents unmapped matte surfaces (stone, wood, dirt) from adopting maximum reflectivity and 45-degree angled normals that reflected the sky across flat surfaces. ## Kind - [x] bug: a crash or a breakage - [x] parity: Horizon now does what vanilla 26.3 does - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (Iris / OptiFine shader pipeline specifications). ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on local, against upstream/main at c2d352e0a) | Check | Result | | --- | --- | | Scope | ✅ 17 files, +310 −38 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 602 passed (47 s) | | rustfmt | ✅ (11 s) | | clippy | ✅ (2 min 44 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render, horizon-shaders | ✅ 3022 passed (`horizon-shaders` 124 passed; `horizon-client-render` post-processing 6 passed; unrelated `frame_gen` floating point margin on plain main noted) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (10 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 377 affected, to run in CI | ## Testing & Verification - **Automated Tests:** - `horizon-shaders` unit tests pass (124/124). - `horizon-client-render` post-processing tests pass (6/6). - **In-Game Shader Testing:** - Tested with [RedHat Shaders 34.3.1 on Modrinth](https://modrinth.com/shader/redhat/version/Ca8OxUZj) (`RedHat_v34.3.1.zip`, targeted for Iris on Minecraft 26.3 / Iris 1.7+). - Verified clean GLSL translation, correct ambient occlusion separation, elimination of hand SSR smearing, and flat matte surfaces free of diagonal specular bands across full day/night cycles. ## Screenshots <!-- Note: Drag and drop verification screenshot here --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:33:42 +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#7092
No description provided.