[PR #4861] [MERGED] Post chains run the resources' own GLSL, with texture and depth inputs #5896

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4861
Author: @levzzz5154
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: parity/E2-post-chain-shaders


📝 Commits (2)

  • b3516f6 Post chains run the resources' own GLSL: texture and depth inputs, translated with naga
  • 088390b Merge remote-tracking branch 'hr/main' into parity/E2-post-chain-shaders

📊 Changes

8 files changed (+1255 additions, -91 deletions)

View changed files

📝 crates/horizon-client-render/Cargo.toml (+1 -1)
📝 crates/horizon-client-render/src/gfx.rs (+9 -14)
📝 crates/horizon-client-render/src/gfx/cull.rs (+0 -4)
📝 crates/horizon-client-render/src/lib.rs (+1 -0)
📝 crates/horizon-client-render/src/post_chain.rs (+898 -67)
📝 crates/horizon-client-render/src/post_chain.wgsl (+15 -5)
➕ crates/horizon-client-render/src/post_glsl.rs (+316 -0)
📝 crates/horizon-client/src/game.rs (+15 -0)

📄 Description

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

Part of #3518

Follow-up to #4825 / #4826 / #4828. post_chain now runs vanilla's post_effect chains for any shader the resources provide, instead of only 8 hand-written stand-ins.

Rows:

  • PostChain.load / PostChain.createPass: a pass's vertex_shader / fragment_shader are read at run time from the active resource root (shaders/<path>.vsh|.fsh, #include <ns:path> from shaders/include/), so vanilla's GLSL and a resource pack's own both run. New horizon-client-render/src/post_glsl.rs translates them GLSL to naga (naga's GLSL frontend, the one horizon-shaders uses): blocks and samplers get bind-group bindings, NameSampler becomes sampler2D(texture, sampler), the vertex main is wrapped to negate clip y.
  • PostPass.addToFrame / PostPass.TargetInput / TextureInput: every input kind is bound as vanilla binds it: target colour (nearest/bilinear), target depth (use_depth_buffer; the frame's own depth buffer for main, a far-plane depth for an internal target), and location textures (textures/effect/<name>.png). Uniform blocks: SamplerInfo (OutSize, then each input's size in input order), Globals (GlobalSettingsUniform: camera block pos and offset, game time, screen size, menu blur radius), and the pass's own uniforms groups (std140, 128 bytes).
  • Named intermediate targets with their width/height, persistent and clear_color already worked; all targets now keep GL's rows (the frame is flipped into main and back), so GLSL reads texCoord as in vanilla.
  • The WGSL stand-ins stay only as a per-pass fallback when the GLSL is missing or does not translate; a chain that still cannot load fails once (failedPostEffects) as before.

Also: the world depth texture is always TEXTURE_BINDING (so a pass can read it); removed the now unused Cull::depth_test.

Vanilla followed: PostChain.load/createPass/addToFrame, PostPass (SamplerInfo layout, bindDefaultUniforms -> Globals), PostChainConfig (TextureInput / TargetInput xor codec), GlobalSettingsUniform.update.

Tests: config parsing of texture and depth inputs; all vanilla post shaders translate; a chain with its own GLSL, a depth input, an image input and an intermediate target runs on the GPU and checks pixels; frame orientation survives a chain; the four vanilla chains (blur, creeper, invert, spider) run on the GPU on their own GLSL with no validation error (skipped without .local / an adapter).

Visual check (fast build, offscreen, scratch homes): no effect, /posteffect add @s minecraft:invert (inverted world, HUD and chat untouched), spider (intermediate targets, rotscale, two inputs) and blur (ping-pong through swap) all render upright and as vanilla's chains describe.

🤖 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/4861 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `parity/E2-post-chain-shaders` --- ### 📝 Commits (2) - [`b3516f6`](https://github.com/horizon-rust/horizon/commit/b3516f66e28fb4050f1de6aa065914cff8c997b4) Post chains run the resources' own GLSL: texture and depth inputs, translated with naga - [`088390b`](https://github.com/horizon-rust/horizon/commit/088390b4fe6ad29f75008fc2286571c8db84bf27) Merge remote-tracking branch 'hr/main' into parity/E2-post-chain-shaders ### 📊 Changes **8 files changed** (+1255 additions, -91 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/Cargo.toml` (+1 -1) 📝 `crates/horizon-client-render/src/gfx.rs` (+9 -14) 📝 `crates/horizon-client-render/src/gfx/cull.rs` (+0 -4) 📝 `crates/horizon-client-render/src/lib.rs` (+1 -0) 📝 `crates/horizon-client-render/src/post_chain.rs` (+898 -67) 📝 `crates/horizon-client-render/src/post_chain.wgsl` (+15 -5) ➕ `crates/horizon-client-render/src/post_glsl.rs` (+316 -0) 📝 `crates/horizon-client/src/game.rs` (+15 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #3518 Follow-up to #4825 / #4826 / #4828. `post_chain` now runs vanilla's `post_effect` chains for any shader the resources provide, instead of only 8 hand-written stand-ins. Rows: - `PostChain.load` / `PostChain.createPass`: a pass's `vertex_shader` / `fragment_shader` are read at run time from the active resource root (`shaders/<path>.vsh|.fsh`, `#include <ns:path>` from `shaders/include/`), so vanilla's GLSL and a resource pack's own both run. New `horizon-client-render/src/post_glsl.rs` translates them GLSL to naga (`naga`'s GLSL frontend, the one `horizon-shaders` uses): blocks and samplers get bind-group bindings, `NameSampler` becomes `sampler2D(texture, sampler)`, the vertex `main` is wrapped to negate clip y. - `PostPass.addToFrame` / `PostPass.TargetInput` / `TextureInput`: every input kind is bound as vanilla binds it: target colour (nearest/bilinear), target depth (`use_depth_buffer`; the frame's own depth buffer for `main`, a far-plane depth for an internal target), and `location` textures (`textures/effect/<name>.png`). Uniform blocks: `SamplerInfo` (`OutSize`, then each input's size in input order), `Globals` (`GlobalSettingsUniform`: camera block pos and offset, game time, screen size, menu blur radius), and the pass's own `uniforms` groups (std140, 128 bytes). - Named intermediate targets with their `width`/`height`, `persistent` and `clear_color` already worked; all targets now keep GL's rows (the frame is flipped into `main` and back), so GLSL reads `texCoord` as in vanilla. - The WGSL stand-ins stay only as a per-pass fallback when the GLSL is missing or does not translate; a chain that still cannot load fails once (`failedPostEffects`) as before. Also: the world depth texture is always `TEXTURE_BINDING` (so a pass can read it); removed the now unused `Cull::depth_test`. Vanilla followed: `PostChain.load/createPass/addToFrame`, `PostPass` (`SamplerInfo` layout, `bindDefaultUniforms` -> `Globals`), `PostChainConfig` (`TextureInput` / `TargetInput` xor codec), `GlobalSettingsUniform.update`. Tests: config parsing of texture and depth inputs; all vanilla post shaders translate; a chain with its own GLSL, a depth input, an image input and an intermediate target runs on the GPU and checks pixels; frame orientation survives a chain; the four vanilla chains (`blur`, `creeper`, `invert`, `spider`) run on the GPU on their own GLSL with no validation error (skipped without `.local` / an adapter). Visual check (fast build, offscreen, scratch homes): no effect, `/posteffect add @s minecraft:invert` (inverted world, HUD and chat untouched), `spider` (intermediate targets, rotscale, two inputs) and `blur` (ping-pong through `swap`) all render upright and as vanilla's chains describe. 🤖 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:15:46 +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#5896
No description provided.