[PR #5236] [MERGED] Shader packs: #if takes float values, and a condition it can't read is a warning #6156

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

📋 Pull Request Information

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

Base: main ← Head: shaderpacks/if-conditions


📝 Commits (1)

  • 7042bc4 Shader packs: #if takes float values, and a condition it can't read is a warning

📊 Changes

3 files changed (+104 additions, -39 deletions)

View changed files

📝 crates/horizon-shaders/src/condition.rs (+74 -37)
📝 crates/horizon-shaders/src/post.rs (+11 -2)
📝 crates/horizon-shaders/src/preprocess.rs (+19 -0)

📄 Description

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

What and why

Fixes #5234.

  • Float values in #if. eval_condition now computes in f64: float literals (0.0, .25, 1.5f) are numbers, a fraction counts as true, comparisons and arithmetic work on them, and / and % stay integer division unless a float literal appears in the condition. GL drivers read these lines this way, and Iris loads the packs that use them. float_values_count covers it; bad_conditions_say_why keeps checking that malformed conditions are still errors.
  • A condition that can't be evaluated already reads as false (Conditionals::apply), but it went to Preprocessed::diagnostics, and any diagnostic skips the program. It now goes to a new Preprocessed::warnings, which the loader adds to its notes without skipping. bad_conditions_warn_and_read_false covers it.

Measured with Horizon main and this PR on the same world (programs the loader skipped, and #if errors in its notes):

Pack main this PR
Pastel v1.200 3 #if errors, 3 programs skipped (deferred1 among them) 0 skipped; the 3 conditions are warnings; deferred1 loads (7 programs instead of 6)
I Like Vanilla v1.5.0b 12 #if errors, 27 programs skipped 0 #if errors, 23 skipped (the rest for other reasons)

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

Not vanilla: the shaders/ pack format's preprocessor. Iris 1.11.7 on Minecraft 26.3 loads both packs with these programs (run and observed, no source read).

Self-check

pr_ready (tools/pr_ready.py --quick on 6cd182588f2d, against origin/main at 979aa64e5, 4 min 40 s)

Check Result
Scope ✅ 3 files, +104 −39
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 495 run, FAILED (errors=4) (2 min 21 s)
rustfmt ✅ (24 s)
clippy ✅ (1 min 51 s)
tests: horizon-shaders ✅ 49 passed (3 s)
doc tests ✅ 0 passed
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)

Run on a rented Linux box with GPU tests on lavapipe. The 4 Python errors are that box's git 2.34 (git merge-tree --write-tree, in test_nightly_set and test_supervise); they pass with git 2.55.

🤖 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/5236 **Author:** [@TobiasLogic](https://github.com/TobiasLogic) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shaderpacks/if-conditions` --- ### 📝 Commits (1) - [`7042bc4`](https://github.com/horizon-rust/horizon/commit/7042bc4d65d4c600eb7aedd8e9d8215bbc0fde94) Shader packs: #if takes float values, and a condition it can't read is a warning ### 📊 Changes **3 files changed** (+104 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/condition.rs` (+74 -37) 📝 `crates/horizon-shaders/src/post.rs` (+11 -2) 📝 `crates/horizon-shaders/src/preprocess.rs` (+19 -0) </details> ### 📄 Description > 🤖 Opened by TobiasLogic's AI agent (Claude Code, Claude Opus 5.5), not by TobiasLogic personally. ## What and why Fixes #5234. - **Float values in `#if`.** `eval_condition` now computes in `f64`: float literals (`0.0`, `.25`, `1.5f`) are numbers, a fraction counts as true, comparisons and arithmetic work on them, and `/` and `%` stay integer division unless a float literal appears in the condition. GL drivers read these lines this way, and Iris loads the packs that use them. `float_values_count` covers it; `bad_conditions_say_why` keeps checking that malformed conditions are still errors. - **A condition that can't be evaluated** already reads as false (`Conditionals::apply`), but it went to `Preprocessed::diagnostics`, and any diagnostic skips the program. It now goes to a new `Preprocessed::warnings`, which the loader adds to its notes without skipping. `bad_conditions_warn_and_read_false` covers it. Measured with Horizon main and this PR on the same world (programs the loader skipped, and `#if` errors in its notes): | Pack | main | this PR | | --- | --- | --- | | Pastel v1.200 | 3 `#if` errors, 3 programs skipped (deferred1 among them) | 0 skipped; the 3 conditions are warnings; deferred1 loads (7 programs instead of 6) | | I Like Vanilla v1.5.0b | 12 `#if` errors, 27 programs skipped | 0 `#if` errors, 23 skipped (the rest for other reasons) | ## 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 Not vanilla: the `shaders/` pack format's preprocessor. Iris 1.11.7 on Minecraft 26.3 loads both packs with these programs (run and observed, no source read). ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on 6cd182588f2d, against origin/main at 979aa64e5, 4 min 40 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +104 −39 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 495 run, FAILED (errors=4) (2 min 21 s) | | rustfmt | ✅ (24 s) | | clippy | ✅ (1 min 51 s) | | tests: horizon-shaders | ✅ 49 passed (3 s) | | doc tests | ✅ 0 passed | | 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) | Run on a rented Linux box with GPU tests on lavapipe. The 4 Python errors are that box's git 2.34 (`git merge-tree --write-tree`, in `test_nightly_set` and `test_supervise`); they pass with git 2.55. 🤖 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 06:15:00 +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#6156
No description provided.