[PR #7460] [MERGED] Shader packs: scale.<program> draws a composite-style pass into part of its buffers #7613

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

📋 Pull Request Information

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

Base: main ← Head: shaderpacks/composite-scale


📝 Commits (1)

  • ec8cebc Shader packs: scale. draws a composite-style pass into part of its buffers

📊 Changes

2 files changed (+136 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/pack_post.rs (+55 -2)
📝 crates/horizon-shaders/src/post.rs (+81 -0)

📄 Description

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

What and why

Fixes #7453.

Found while investigating #6812; it doesn't change Shrimple's picture.

scale.<program>=<scale> [offsetX offsetY] in shaders.properties (OptiFine's "Composite render scale") was not read: such a program drew all of its buffers. Iris 1.11.7, with a probe pack of my own, draws a scaled program only into the viewport (offsetX × width, offsetY × height, scale × width, scale × height), from GL's bottom-left corner. Its texture coordinates span that viewport, and its buffers keep what they held outside it. Now:

  • post.rs: PostProgram::scale is scale.<name> of a deferred or composite program (OptiFine's "Composite render scale"; composite probed, deferred per the doc; prepare programs are treated the same, unverified), [1, 0, 0] without one or for a value that is not a scale in (0, 1] with offsets in [0, 1).
  • pack_post.rs: such a pass loads its attachments instead of clearing them, and sets that viewport (viewport: whole pixels, at least one, inside the buffer). Buffer rows are already GL's, so the offsets apply as they are.

ShaderDoc's passes/composite.md says the offset can't be adjusted ("always rooted at the corner"). Iris 1.11.7 applied it in the probe, so this follows the observation.

How the cause was found

  1. An earlier unpushed WIP commit of ours on #6812 (d380c2e50, shaderpacks/program-scale) read scale.<program> without offsets; this branch builds on it, and every behaviour below was re-established with probe scale1.
  2. From Horizon's code: post.rs reads flip.<program>.* and size.buffer.* but no scale.* key. OptiFine's shaders.properties documentation lists scale.<program>.
  3. Probe pack scale1 (my own): composite writes colortex1 dark red. composite1 (scale.composite1 = 0.5) and composite2 (scale.composite2 = 0.25 0.5 0.25) each read colortex1 and write it with their texture coordinates in green and blue. final shows colortex1.
    • Iris 1.11.7: composite2's output fills only one box, x 640–960, y 360–540 (from the screenshot; the branch drawing exactly that box differs from Iris only in the block below) from the top of the 1280×720 picture (GL y 180–360). Inside it, composite1's output fills the bottom-left quarter. Everything else is composite's dark red.
    • Horizon main 7504abf07: composite2's gradient fills the whole picture. Mean absolute difference to Iris 104.5 (0..255); 921,530 of 921,600 pixels differ by more than 4.
    • This branch: the same boxes in the same places. Mean absolute difference 6.9. 43,200 pixels (one 240×180 block) still differ: the part of composite1's buffer that no pass writes. There Iris shows colortex1's clear colour (white) and Horizon content from earlier frames. Why Horizon keeps older content there is undiagnosed; it is separate from this change.

I was looking for why Shrimple v0.12 is dark. This does not change Shrimple's picture (below), so it is not that cause; it is an Iris difference any pack using scale.* hits. I did not open, extract, or read any pack's files, nor Horizon's preprocessed or translated text of any pack. What I know of Shrimple comes only from running it: real_packs output, Horizon's and Iris's game logs, HORIZON_SHADER_PACK_SKIP runs, screenshots, and #6812's text.

Measured

  • real_packs (SHOW_ERRORS=1), Shrimple alone, main 7504abf07 vs this branch (3a9dbf8dd): identical apart from timings (this changes PostProgram, which real_packs doesn't print, and the renderer).
  • In the game (fast builds, Xvfb, fresh homes, scenes ow_ground_noon, ow_ground_sunset, ow_ground_night), main 7504abf07 vs this branch: Shrimple's scores against Iris are the same (diff 88.9 / 58.4 / 13.0, 0..255), and the mean absolute difference between the two builds' pictures is 0.03 / 0.02 / 0.00.

Tests

  • post::tests::scale_keys_give_composite_style_programs_a_viewport: scale.deferred = 0.5 and scale.composite = 0.25 0.5 0.25 give those viewports. A scale of 2, a missing offset, a program without a key and scale.final draw everything. It reads PostProgram::scale, which main lacks, so it doesn't build there; it was not run on main.
  • pack_post::tests::a_scaled_pass_draws_its_part_from_gl_s_corner: the probe's 0.25 0.5 0.25 on 1280×720 is [640, 180, 320, 180], plus rounding and clamping cases. viewport is new, so it doesn't build on main either.
  • The renderer's loading and viewport are covered by the probe pack above, not by a unit test: no test drives PackPost::run.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • 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 (shader packs; vanilla has no such feature). Sources:

  • OptiFine's shaders.properties documentation (OptiFineDoc/doc/shaders.properties at 83d482c38): scale.<program>=<scale|scale offsetX ofsetY>.
  • ShaderDoc passes/composite.md at ddf47372 (viewport from scale.<program>).
  • Black-box runs of Iris 1.11.7 with a probe pack of my own.

Other projects' code

none. No Iris, OptiFine or pack code read.

Self-check

pr_ready (tools/pr_ready.py --quick on plony-pc, against origin/main at f696adc89, 2 min 36 s)

Check Result
Scope ✅ 2 files, +136 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (30 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 7 s)
tests: horizon-client-render, horizon-shaders ✅ 1324 passed (51 s)
doc tests ✅ 0 passed
content root tests ➖ content root untouched
mod API up to date ➖ native hooks 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/7460 **Author:** [@arslanarm](https://github.com/arslanarm) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shaderpacks/composite-scale` --- ### 📝 Commits (1) - [`ec8cebc`](https://github.com/horizon-rust/horizon/commit/ec8cebc6a83babf95698869edade4889cf027f5e) Shader packs: scale.<program> draws a composite-style pass into part of its buffers ### 📊 Changes **2 files changed** (+136 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+55 -2) 📝 `crates/horizon-shaders/src/post.rs` (+81 -0) </details> ### 📄 Description > 🤖 Opened by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally. ## What and why Fixes #7453. Found while investigating #6812; it doesn't change Shrimple's picture. `scale.<program>=<scale> [offsetX offsetY]` in `shaders.properties` (OptiFine's "Composite render scale") was not read: such a program drew all of its buffers. Iris 1.11.7, with a probe pack of my own, draws a scaled program only into the viewport `(offsetX × width, offsetY × height, scale × width, scale × height)`, from GL's bottom-left corner. Its texture coordinates span that viewport, and its buffers keep what they held outside it. Now: - `post.rs`: `PostProgram::scale` is `scale.<name>` of a deferred or composite program (OptiFine's "Composite render scale"; composite probed, deferred per the doc; prepare programs are treated the same, unverified), `[1, 0, 0]` without one or for a value that is not a scale in (0, 1] with offsets in [0, 1). - `pack_post.rs`: such a pass loads its attachments instead of clearing them, and sets that viewport (`viewport`: whole pixels, at least one, inside the buffer). Buffer rows are already GL's, so the offsets apply as they are. ShaderDoc's `passes/composite.md` says the offset can't be adjusted ("always rooted at the corner"). Iris 1.11.7 applied it in the probe, so this follows the observation. ### How the cause was found 0. An earlier unpushed WIP commit of ours on #6812 (d380c2e50, `shaderpacks/program-scale`) read `scale.<program>` without offsets; this branch builds on it, and every behaviour below was re-established with probe `scale1`. 1. From Horizon's code: `post.rs` reads `flip.<program>.*` and `size.buffer.*` but no `scale.*` key. OptiFine's `shaders.properties` documentation lists `scale.<program>`. 2. Probe pack `scale1` (my own): `composite` writes colortex1 dark red. `composite1` (`scale.composite1 = 0.5`) and `composite2` (`scale.composite2 = 0.25 0.5 0.25`) each read colortex1 and write it with their texture coordinates in green and blue. `final` shows colortex1. - Iris 1.11.7: composite2's output fills only one box, x 640–960, y 360–540 (from the screenshot; the branch drawing exactly that box differs from Iris only in the block below) from the top of the 1280×720 picture (GL y 180–360). Inside it, composite1's output fills the bottom-left quarter. Everything else is composite's dark red. - Horizon main 7504abf07: composite2's gradient fills the whole picture. Mean absolute difference to Iris 104.5 (0..255); 921,530 of 921,600 pixels differ by more than 4. - This branch: the same boxes in the same places. Mean absolute difference 6.9. 43,200 pixels (one 240×180 block) still differ: the part of composite1's buffer that no pass writes. There Iris shows colortex1's clear colour (white) and Horizon content from earlier frames. Why Horizon keeps older content there is undiagnosed; it is separate from this change. I was looking for why Shrimple v0.12 is dark. This does not change Shrimple's picture (below), so it is not that cause; it is an Iris difference any pack using `scale.*` hits. I did not open, extract, or read any pack's files, nor Horizon's preprocessed or translated text of any pack. What I know of Shrimple comes only from running it: `real_packs` output, Horizon's and Iris's game logs, `HORIZON_SHADER_PACK_SKIP` runs, screenshots, and #6812's text. ### Measured - `real_packs` (`SHOW_ERRORS=1`), Shrimple alone, main 7504abf07 vs this branch (3a9dbf8dd): identical apart from timings (this changes `PostProgram`, which `real_packs` doesn't print, and the renderer). - In the game (fast builds, Xvfb, fresh homes, scenes `ow_ground_noon`, `ow_ground_sunset`, `ow_ground_night`), main 7504abf07 vs this branch: Shrimple's scores against Iris are the same (diff 88.9 / 58.4 / 13.0, 0..255), and the mean absolute difference between the two builds' pictures is 0.03 / 0.02 / 0.00. ### Tests - `post::tests::scale_keys_give_composite_style_programs_a_viewport`: `scale.deferred = 0.5` and `scale.composite = 0.25 0.5 0.25` give those viewports. A scale of 2, a missing offset, a program without a key and `scale.final` draw everything. It reads `PostProgram::scale`, which main lacks, so it doesn't build there; it was not run on main. - `pack_post::tests::a_scaled_pass_draws_its_part_from_gl_s_corner`: the probe's `0.25 0.5 0.25` on 1280×720 is `[640, 180, 320, 180]`, plus rounding and clamping cases. `viewport` is new, so it doesn't build on main either. - The renderer's loading and viewport are covered by the probe pack above, not by a unit test: no test drives `PackPost::run`. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] 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 (shader packs; vanilla has no such feature). Sources: - OptiFine's `shaders.properties` documentation (OptiFineDoc/doc/shaders.properties at 83d482c38): `scale.<program>=<scale|scale offsetX ofsetY>`. - ShaderDoc `passes/composite.md` at ddf47372 (viewport from `scale.<program>`). - Black-box runs of Iris 1.11.7 with a probe pack of my own. ## Other projects' code none. No Iris, OptiFine or pack code read. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on plony-pc, against origin/main at f696adc89, 2 min 36 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +136 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (30 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 7 s) | | tests: horizon-client-render, horizon-shaders | ✅ 1324 passed (51 s) | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks 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 07:20: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#7613
No description provided.