[PR #404] [MERGED] Preserve native sprite mipmaps in mixed-size texture arrays #2537

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

📋 Pull Request Information

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

Base: main ← Head: fix/rail-mipmap-cutout


📝 Commits (1)

  • 725146c Generate sprite mips before array-only enlargement

📊 Changes

4 files changed (+104 additions, -23 deletions)

View changed files

📝 crates/horizon-client/examples/mipmap_probe.rs (+1 -8)
📝 crates/horizon-client/src/gfx.rs (+59 -4)
📝 crates/horizon-client/src/mipmap.rs (+43 -11)
📝 crates/horizon-client/src/sprites.rs (+1 -0)

📄 Description

Generate each sprite's mip chain at its native resolution before expanding levels needed only by Horizon's square texture array.

Previously, a native 16px texture was enlarged to 32px when an unrelated 32px sprite (for example block/oak_sign) joined the array. mipmap::generate then ran alpha-coverage adjustment on the artificial 32→16 reduction before generating the real smaller mips. This changed the sprite's mip pixels based on other loaded textures. In the actual prepared rail textures, normal rail's 8×8 mip went from 48 to 16 pixels passing the terrain alpha cutoff; detector rail went from 48 to 24.

Settings now retains the original frame edge. For reversible power-of-two enlargement, generate the native mip chain once and prepend nearest-expanded copies of its processed base. Already-native, downscaled, non-power-of-two and non-square inputs retain their existing path. Initial uploads, cached/uncached animation uploads and mipmap_probe use the same generator. No shader, sampler, alpha cutoff or user setting changes.

Validation:

  • Actual-resource regression failed before the fix and passes after it. It loads all five rail textures alone and again with a 32px sign, then compares every matching mip byte through the real upload helper.
  • Seven sprite-upload tests and five sprite/animation tests pass, including cache behavior and native 32px frame detail.
  • Client all-target Clippy with warnings denied, formatting, diff and public-tree checks pass. Independent focused review covered partial mip counts, fallback dimensions, transparent recovery and animation callers.

This was found while investigating a Discord screenshot of coarse intermediate rail textures. No game window or matched visual comparison was run, so this PR does not claim to fully explain or resolve that screenshot. A separate comparison of Vanilla's texture filtering is still pending. Draft for visual testing.


🔄 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/404 **Author:** [@Online5277](https://github.com/Online5277) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/rail-mipmap-cutout` --- ### 📝 Commits (1) - [`725146c`](https://github.com/horizon-rust/horizon/commit/725146c0ca1f3a37568ec5db440cfe4d5fce2e85) Generate sprite mips before array-only enlargement ### 📊 Changes **4 files changed** (+104 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/mipmap_probe.rs` (+1 -8) 📝 `crates/horizon-client/src/gfx.rs` (+59 -4) 📝 `crates/horizon-client/src/mipmap.rs` (+43 -11) 📝 `crates/horizon-client/src/sprites.rs` (+1 -0) </details> ### 📄 Description Generate each sprite's mip chain at its native resolution before expanding levels needed only by Horizon's square texture array. Previously, a native 16px texture was enlarged to 32px when an unrelated 32px sprite (for example `block/oak_sign`) joined the array. `mipmap::generate` then ran alpha-coverage adjustment on the artificial 32→16 reduction before generating the real smaller mips. This changed the sprite's mip pixels based on other loaded textures. In the actual prepared rail textures, normal rail's 8×8 mip went from 48 to 16 pixels passing the terrain alpha cutoff; detector rail went from 48 to 24. `Settings` now retains the original frame edge. For reversible power-of-two enlargement, generate the native mip chain once and prepend nearest-expanded copies of its processed base. Already-native, downscaled, non-power-of-two and non-square inputs retain their existing path. Initial uploads, cached/uncached animation uploads and `mipmap_probe` use the same generator. No shader, sampler, alpha cutoff or user setting changes. Validation: - Actual-resource regression failed before the fix and passes after it. It loads all five rail textures alone and again with a 32px sign, then compares every matching mip byte through the real upload helper. - Seven sprite-upload tests and five sprite/animation tests pass, including cache behavior and native 32px frame detail. - Client all-target Clippy with warnings denied, formatting, diff and public-tree checks pass. Independent focused review covered partial mip counts, fallback dimensions, transparent recovery and animation callers. This was found while investigating a Discord screenshot of coarse intermediate rail textures. No game window or matched visual comparison was run, so this PR does not claim to fully explain or resolve that screenshot. A separate comparison of Vanilla's texture filtering is still pending. Draft for visual testing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:01 +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#2537
No description provided.