[PR #647] [MERGED] Block textures: share identical sprites, and draw past 2048 layers #2695

Closed
opened 2026-11-02 15:58:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/sprite-arrays


📝 Commits (1)

  • 7384db3 Block textures: share identical sprites, and draw past 2048 layers

📊 Changes

4 files changed (+328 additions, -148 deletions)

View changed files

📝 crates/horizon-client/src/assets.rs (+1 -1)
📝 crates/horizon-client/src/gfx.rs (+199 -112)
📝 crates/horizon-client/src/sprites.rs (+103 -33)
📝 crates/horizon-client/src/terrain.wgsl (+25 -2)

📄 Description

Every block sprite is one layer of a texture array, and GPUs give an array at most 2048 layers (Metal and most Vulkan drivers). Vanilla 26.3 takes 1,250. The eight real NeoForge mods from the modpack stack (#630–#633) take 2,183, and the game stopped at start with GPU supports 2048 texture layers; 2200 required.

  • Shared sprites. A still texture whose pixels and mip settings match one already loaded reuses its layer: mods copy vanilla's textures under their own names. This saves 17 layers for those mods and none for vanilla. Animated textures always get their own layers.
  • Up to four arrays. The renderer splits the layers over up to four arrays of 2048, so 8,192 sprites. terrain.wgsl picks the array per fragment with textureSampleGrad, taking the derivatives in uniform control flow. A pipeline override constant (SPRITE_ARRAYS) keeps vanilla, which needs one array, on the same single textureSample as before. Animated sprites upload to their array.
  • HORIZON_SPRITE_SPLIT (dev only) forces a smaller split. Vanilla drawn from three arrays of 512 renders the same blocks as from one: I compared screenshots of a wall of leaves, magma, prismarine, sea lantern, glass, planks and diamond.

The eight mods now load and render in game, measured in #648. Independent of the stack: it is based on main.

Checks

  • cargo fmt --all --check: clean. cargo clippy -p horizon-client --all-targets -- -D warnings on this branch: clean
  • horizon-client sprite and gfx tests (50), including a new one: identical still textures share a layer, and an item sprite with the same pixels does not
  • Local parity (--changed origin/main, with #648's changes in the tree): 293 harnesses depend on the changes; the 20 without a pass for their current inputs ran and passed (2.3 min), the other 273 had passed for the same inputs in the stack's run

🤖 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/647 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/sprite-arrays` --- ### 📝 Commits (1) - [`7384db3`](https://github.com/horizon-rust/horizon/commit/7384db307d5f9be26ddd5f5a1f31cf2260c542cb) Block textures: share identical sprites, and draw past 2048 layers ### 📊 Changes **4 files changed** (+328 additions, -148 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/assets.rs` (+1 -1) 📝 `crates/horizon-client/src/gfx.rs` (+199 -112) 📝 `crates/horizon-client/src/sprites.rs` (+103 -33) 📝 `crates/horizon-client/src/terrain.wgsl` (+25 -2) </details> ### 📄 Description Every block sprite is one layer of a texture array, and GPUs give an array at most 2048 layers (Metal and most Vulkan drivers). Vanilla 26.3 takes 1,250. The eight real NeoForge mods from the modpack stack (#630–#633) take 2,183, and the game stopped at start with `GPU supports 2048 texture layers; 2200 required`. - **Shared sprites.** A still texture whose pixels and mip settings match one already loaded reuses its layer: mods copy vanilla's textures under their own names. This saves 17 layers for those mods and none for vanilla. Animated textures always get their own layers. - **Up to four arrays.** The renderer splits the layers over up to four arrays of 2048, so 8,192 sprites. `terrain.wgsl` picks the array per fragment with `textureSampleGrad`, taking the derivatives in uniform control flow. A pipeline override constant (`SPRITE_ARRAYS`) keeps vanilla, which needs one array, on the same single `textureSample` as before. Animated sprites upload to their array. - **`HORIZON_SPRITE_SPLIT`** (dev only) forces a smaller split. Vanilla drawn from three arrays of 512 renders the same blocks as from one: I compared screenshots of a wall of leaves, magma, prismarine, sea lantern, glass, planks and diamond. The eight mods now load and render in game, measured in #648. Independent of the stack: it is based on `main`. ## Checks - `cargo fmt --all --check`: clean. `cargo clippy -p horizon-client --all-targets -- -D warnings` on this branch: clean - `horizon-client` sprite and gfx tests (50), including a new one: identical still textures share a layer, and an item sprite with the same pixels does not - Local parity (`--changed origin/main`, with #648's changes in the tree): 293 harnesses depend on the changes; the 20 without a pass for their current inputs ran and passed (2.3 min), the other 273 had passed for the same inputs in the stack's run 🤖 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-02 15:58:19 +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#2695
No description provided.