[PR #6458] [MERGED] OptiFine CIT: GUI items draw their pack's enchantment glint layers #6889

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6458
Author: @some-du6e
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: optifine/cit-glint


📝 Commits (10+)

  • bea7d2d OptiFine CIT: items draw their pack's texture or model
  • 608545c OptiFine CIT: worn armour and elytra wear their pack's textures
  • f605856 OptiFine CIT: pack armour and elytra textures with the rest
  • e78f536 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • 19327fd Merge branch 'optifine/cit-items' into optifine/cit-armor
  • 1342468 OptiFine CIT: enchantment glint layers and cit.properties, chosen per stack
  • 5e553f7 OptiFine CIT: GUI items draw their enchantment glint layers
  • 123bd3f OptiFine CIT: item swap tests keep their files until the sprites are baked
  • 6fb7637 Merge branch 'optifine/cit-overlay' into optifine/cit-items
  • d4080d5 Merge branch 'optifine/cit-items' into optifine/cit-armor

📊 Changes

21 files changed (+3324 additions, -81 deletions)

View changed files

📝 crates/horizon-assets/src/resolve.rs (+39 -0)
📝 crates/horizon-client-render/src/cit.rs (+206 -19)
➕ crates/horizon-client-render/src/cit_armor.rs (+319 -0)
📝 crates/horizon-client-render/src/cit_assets.rs (+184 -6)
➕ crates/horizon-client-render/src/cit_glint.rs (+386 -0)
📝 crates/horizon-client-render/src/gfx.rs (+1 -1)
📝 crates/horizon-client-render/src/hud.rs (+67 -9)
📝 crates/horizon-client-render/src/hud.wgsl (+29 -0)
➕ crates/horizon-client-render/src/hud/cit_glint.rs (+563 -0)
📝 crates/horizon-client-render/src/lib.rs (+2 -0)
📝 crates/horizon-client/src/client_lib.rs (+8 -8)
📝 crates/horizon-client/src/game.rs (+10 -1)
📝 crates/horizon-client/src/game/armor_stands.rs (+36 -11)
📝 crates/horizon-client/src/game/item_draw.rs (+58 -1)
📝 crates/horizon-client/src/game/mob_blocks.rs (+6 -1)
📝 crates/horizon-client/src/game/perspective.rs (+11 -7)
📝 crates/horizon-client/src/item_render.rs (+46 -13)
➕ crates/horizon-client/src/item_render/cit.rs (+810 -0)
📝 crates/horizon-client/src/item_render/gui.rs (+135 -2)
📝 crates/horizon-optifine/src/cit.rs (+405 -0)

...and 1 more files

📄 Description

With #6392, Horizon works out which enchantment glint layers a stack's CIT rules give it, but nothing draws them. This PR draws them on GUI items: the hotbar, inventories and every other screen that draws items. Each layer uses its own texture, blend, scroll speed, rotation, colour and strength (including cycle's fades). On GUI items the layers replace vanilla's glint (unless a layer keeps it with useGlint=true). Held, dropped and framed items keep vanilla's glint until their own passes exist, except that a pack's useGlint=false turns vanilla's glint off everywhere.

This PR builds on #6392 (and the PRs under it). GitHub shows their commits too. This PR's own changes are hud/cit_glint.rs (new), hud.rs, hud.wgsl, item_render/gui.rs, the glint fields in item_render.rs and item_render/cit.rs, game/item_draw.rs, and the renderer hook in game.rs.

How:

  • Textures: each enchantment rule's texture is loaded once per resource load into a texture array, scaled to one shared size, with a repeating sampler (linear, or nearest for blur=false). Limits: at most 1024 per side, 256 layers and 64 MiB in total, halving the side to fit; blur textures are scaled bilinearly. On OpenGL the layer count is padded as the block array's is. A rule whose texture doesn't load, or past the 256th, matches nothing (with a warning), so it can't hide vanilla's glint or another layer.
  • Blend: each distinct blend gets one pipeline. The named methods and custom GL factor pairs map onto wgpu blend factors, and replace draws unblended.
  • Drawing: after a GUI item's own faces, each CIT layer is drawn over all of them as one run, so a stack costs one draw per layer. The item's own texture alpha masks it, as vanilla's glint is, and texels under 0.1 alpha are discarded, as in vanilla's glint shader.
    • The scroll follows CIT Resewn's formula (milliseconds × speed, then rotation in degrees).
    • The layer's slot and strength travel in the vertex colour, so no new vertex format is needed.
    • The glint-strength option scales each layer's strength, so every blend fades with it, not only additive ones.
  • Caching: stacks with CIT glints skip the GUI vertex cache, since their layers move every frame.
  • Without enchantment rules nothing changes: no texture, no bind group, no extra pass.

Not yet:

  • Custom layers on held, dropped and framed items, and on worn armour. Those glints are drawn inside the entity shader's item pass and need their own passes; that's the next PR. Today those items keep vanilla's glint (or none, with useGlint=false).
  • Animated glint textures (anim/*.properties).
  • On 3D items in the GUI (block items), a layer drawn over a far face can show through a nearer one, because layers are drawn after the whole item. Flat items, nearly every enchanted item, aren't affected.
  • Scissored GUI lists that draw no glint today get no layers either.

Tests: texture array packing and scaling (upscale, a 2048-wide downscale, the 64 MiB halving, bilinear against nearest values), the UV formula, the blend mapping, the vertex colour's raw bytes, one draw run per layer with a layer at strength 0 left out, and a rule with no texture slot matching nothing. Also updated: the CIT and glint rows of docs/resource-packs.md.

Docs used: OptiFine's cit_single.properties ("Enchantments") and CIT Resewn's wiki (CIT Enchantment). For the scroll formula, CIT Resewn's MIT source (TypeEnchantment, LICENSE checked). No OptiFine code was read.

Checks:

Note

Filed by Opus 5.5 using 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/6458 **Author:** [@some-du6e](https://github.com/some-du6e) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `optifine/cit-glint` --- ### 📝 Commits (10+) - [`bea7d2d`](https://github.com/horizon-rust/horizon/commit/bea7d2d0fb614afb81cf29e7c93b3ec521d379a0) OptiFine CIT: items draw their pack's texture or model - [`608545c`](https://github.com/horizon-rust/horizon/commit/608545c23e3a3e891bb26638dc86bc967b1da66d) OptiFine CIT: worn armour and elytra wear their pack's textures - [`f605856`](https://github.com/horizon-rust/horizon/commit/f6058569cb45f1e8ae8d450c4a9fc7dafecb8dec) OptiFine CIT: pack armour and elytra textures with the rest - [`e78f536`](https://github.com/horizon-rust/horizon/commit/e78f5366c7beb213a0debd369c39a6768c6bae9f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`19327fd`](https://github.com/horizon-rust/horizon/commit/19327fd08f85fccaedff4758797a4a5307860c50) Merge branch 'optifine/cit-items' into optifine/cit-armor - [`1342468`](https://github.com/horizon-rust/horizon/commit/13424686cbc393f3d82368c4b612612483c8e154) OptiFine CIT: enchantment glint layers and cit.properties, chosen per stack - [`5e553f7`](https://github.com/horizon-rust/horizon/commit/5e553f703ef660dde6b1ca61124fe91fb48e98b8) OptiFine CIT: GUI items draw their enchantment glint layers - [`123bd3f`](https://github.com/horizon-rust/horizon/commit/123bd3ff7a01b5c4d75f54e9ed335fdb155f078d) OptiFine CIT: item swap tests keep their files until the sprites are baked - [`6fb7637`](https://github.com/horizon-rust/horizon/commit/6fb7637cf1cabf64f4ea75ea064b23f893c3513f) Merge branch 'optifine/cit-overlay' into optifine/cit-items - [`d4080d5`](https://github.com/horizon-rust/horizon/commit/d4080d5d7fc69f262c71d7f780f7e8413c57abfc) Merge branch 'optifine/cit-items' into optifine/cit-armor ### 📊 Changes **21 files changed** (+3324 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-assets/src/resolve.rs` (+39 -0) 📝 `crates/horizon-client-render/src/cit.rs` (+206 -19) ➕ `crates/horizon-client-render/src/cit_armor.rs` (+319 -0) 📝 `crates/horizon-client-render/src/cit_assets.rs` (+184 -6) ➕ `crates/horizon-client-render/src/cit_glint.rs` (+386 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+1 -1) 📝 `crates/horizon-client-render/src/hud.rs` (+67 -9) 📝 `crates/horizon-client-render/src/hud.wgsl` (+29 -0) ➕ `crates/horizon-client-render/src/hud/cit_glint.rs` (+563 -0) 📝 `crates/horizon-client-render/src/lib.rs` (+2 -0) 📝 `crates/horizon-client/src/client_lib.rs` (+8 -8) 📝 `crates/horizon-client/src/game.rs` (+10 -1) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+36 -11) 📝 `crates/horizon-client/src/game/item_draw.rs` (+58 -1) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+6 -1) 📝 `crates/horizon-client/src/game/perspective.rs` (+11 -7) 📝 `crates/horizon-client/src/item_render.rs` (+46 -13) ➕ `crates/horizon-client/src/item_render/cit.rs` (+810 -0) 📝 `crates/horizon-client/src/item_render/gui.rs` (+135 -2) 📝 `crates/horizon-optifine/src/cit.rs` (+405 -0) _...and 1 more files_ </details> ### 📄 Description With #6392, Horizon works out which enchantment glint layers a stack's CIT rules give it, but nothing draws them. This PR draws them on GUI items: the hotbar, inventories and every other screen that draws items. Each layer uses its own texture, blend, scroll speed, rotation, colour and strength (including `cycle`'s fades). On GUI items the layers replace vanilla's glint (unless a layer keeps it with `useGlint=true`). Held, dropped and framed items keep vanilla's glint until their own passes exist, except that a pack's `useGlint=false` turns vanilla's glint off everywhere. **This PR builds on #6392** (and the PRs under it). GitHub shows their commits too. This PR's own changes are `hud/cit_glint.rs` (new), `hud.rs`, `hud.wgsl`, `item_render/gui.rs`, the glint fields in `item_render.rs` and `item_render/cit.rs`, `game/item_draw.rs`, and the renderer hook in `game.rs`. How: - **Textures:** each enchantment rule's texture is loaded once per resource load into a texture array, scaled to one shared size, with a repeating sampler (linear, or nearest for `blur=false`). Limits: at most 1024 per side, 256 layers and 64 MiB in total, halving the side to fit; `blur` textures are scaled bilinearly. On OpenGL the layer count is padded as the block array's is. A rule whose texture doesn't load, or past the 256th, matches nothing (with a warning), so it can't hide vanilla's glint or another layer. - **Blend:** each distinct blend gets one pipeline. The named methods and custom GL factor pairs map onto wgpu blend factors, and `replace` draws unblended. - **Drawing:** after a GUI item's own faces, each CIT layer is drawn over all of them as one run, so a stack costs one draw per layer. The item's own texture alpha masks it, as vanilla's glint is, and texels under 0.1 alpha are discarded, as in vanilla's glint shader. - The scroll follows CIT Resewn's formula (milliseconds × `speed`, then `rotation` in degrees). - The layer's slot and strength travel in the vertex colour, so no new vertex format is needed. - The glint-strength option scales each layer's strength, so every blend fades with it, not only additive ones. - **Caching:** stacks with CIT glints skip the GUI vertex cache, since their layers move every frame. - **Without enchantment rules nothing changes:** no texture, no bind group, no extra pass. Not yet: - Custom layers on held, dropped and framed items, and on worn armour. Those glints are drawn inside the entity shader's item pass and need their own passes; that's the next PR. Today those items keep vanilla's glint (or none, with `useGlint=false`). - Animated glint textures (`anim/*.properties`). - On 3D items in the GUI (block items), a layer drawn over a far face can show through a nearer one, because layers are drawn after the whole item. Flat items, nearly every enchanted item, aren't affected. - Scissored GUI lists that draw no glint today get no layers either. **Tests:** texture array packing and scaling (upscale, a 2048-wide downscale, the 64 MiB halving, bilinear against nearest values), the UV formula, the blend mapping, the vertex colour's raw bytes, one draw run per layer with a layer at strength 0 left out, and a rule with no texture slot matching nothing. Also updated: the CIT and glint rows of `docs/resource-packs.md`. **Docs used:** OptiFine's `cit_single.properties` ("Enchantments") and CIT Resewn's wiki (CIT Enchantment). For the scroll formula, CIT Resewn's MIT source (`TypeEnchantment`, LICENSE checked). No OptiFine code was read. **Checks:** - `cargo fmt` - Fork CI (`verify` job: workspace clippy `-D warnings` and every test): on the current head: https://github.com/some-du6e/horizon/actions/runs/41352807747 (an earlier head passed: https://github.com/some-du6e/horizon/actions/runs/41350418283) - Nothing was built locally: the machine is shared. - **The live game test was skipped:** there is no vanilla data (`.local/`) here. Before merging, someone with it should look at a GUI with a test pack using `add`, `multiply` and `method=cycle`. > [!NOTE] > Filed by Opus 5.5 using 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:28:40 +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#6889
No description provided.