[PR #5778] [MERGED] terrain: sample distant tiles at an explicit mip so anisotropic filtering stops streaking #6490

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5778
Author: @abit-foggy
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/lod-anisotropic-streaks


📝 Commits (2)

  • 80a8c27 terrain: sample distant tiles at an explicit mip so anisotropic filtering stops streaking
  • 2ec0f2b Merge main into #5778

📊 Changes

1 file changed (+19 additions, -6 deletions)

View changed files

📝 crates/horizon-client-render/src/terrain.wgsl (+19 -6)

📄 Description

🤖 Opened by abit-foggy's AI agent (Codebuff), not by abit-foggy personally.

What and why

Fixes #5179: the far LOD band streaks into long parallel lines under anisotropic filtering, worst at 8x.

Far LOD tiles repeat one sprite per block: their UVs count blocks, and tile_uv wraps them back into a single sprite. Their gradients still come from the unwrapped UV, so near the LOD boundary one pixel spans a good fraction of a sprite.

An anisotropic sampler lays its taps along those gradients. For a near block the UVs stay inside one sprite, so the taps do too — that is why the near terrain is clean. For a tiled face the coordinate is inside one sprite while the taps reach past its edge, and the sampler is ClampToEdge, so it returns that edge texel again and again: the streaks. It scales with the tap count, which is why 2x barely showed it and 8x made it obvious.

The fix asks for the mip level those gradients give (sprite_level) instead: the single filtered tap an anisotropy of 1 would take, at the same mip the sampler would have chosen. Only tiled faces take that path (any(tiled - uv >= 0.5) — the wrap shifts UVs by whole blocks); near blocks, RGSS and the meshes are untouched.

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: vanilla has no LOD tiles, so there is nothing to match. The per-block sampling this borrows (sampleNearest/sampleRGSS in terrain.wgsl, from terrain.fsh) is unchanged for blocks that are not tiled. No harness covers the LOD path.

Other projects' code

none

Self-check

**pr_ready** (`tools/pr_ready.py --base upstream/main` on foggy-MacBookPro, against upstream/main at 26747867d, 3 min 22 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 1 files, +19 −6 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ✅ 511 passed (38 s) |
| rustfmt | ✅ (12 s) |
| clippy | ✅ (1 min 23 s) |
| tests: horizon-client-render | ❌ 827 passed, 1 failed (1 min 7 s) |
| doc tests | ✅ 0 passed (1 s) |
| 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 | ➖ 364 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 352 more |
| Label | player-facing: `feature` if players get something new, no label for a fix |

The failing row is gfx::frame_gen::interpolation::tests::moves_the_view_halfway_with_the_camera: it dispatches GPU work and returns early when no adapter is available, so CI skips it. On this machine it fails identically on untouched upstream/main (verified with this change stashed), so it is not from this PR.

The 364 parity harnesses are chosen by the changed file; they are CPU-side JSON comparisons, and CI runs them.

Screenshots

Before: the 8x streak on the far band in #5179 and in the tester's own capture of the same world.

After: 2x, 4x and 8x now look the same on Intel Iris Plus Graphics (Vulkan, Mesa 26.2.5), with the near terrain unchanged. The tester confirmed the fix on their machine.

Note

Horizon's Max Anisotropy slider only offers 2x/4x/8x (maxAnisotropyBit 1..3), so players cannot turn anisotropic filtering off to dodge this; vanilla offers Off..16x. Deliberately not changed here.

🤖 Generated with Codebuff


🔄 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/5778 **Author:** [@abit-foggy](https://github.com/abit-foggy) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/lod-anisotropic-streaks` --- ### 📝 Commits (2) - [`80a8c27`](https://github.com/horizon-rust/horizon/commit/80a8c274d196da902b80df5f74aae03da31a3a5a) terrain: sample distant tiles at an explicit mip so anisotropic filtering stops streaking - [`2ec0f2b`](https://github.com/horizon-rust/horizon/commit/2ec0f2bdc1155ad168467ba407c219fad60001c9) Merge main into #5778 ### 📊 Changes **1 file changed** (+19 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/terrain.wgsl` (+19 -6) </details> ### 📄 Description > 🤖 Opened by abit-foggy's AI agent (Codebuff), not by abit-foggy personally. ## What and why Fixes #5179: the far LOD band streaks into long parallel lines under anisotropic filtering, worst at 8x. Far LOD tiles repeat one sprite per block: their UVs count blocks, and `tile_uv` wraps them back into a single sprite. Their gradients still come from the unwrapped UV, so near the LOD boundary one pixel spans a good fraction of a sprite. An anisotropic sampler lays its taps along those gradients. For a near block the UVs stay inside one sprite, so the taps do too — that is why the near terrain is clean. For a tiled face the coordinate is inside one sprite while the taps reach past its edge, and the sampler is `ClampToEdge`, so it returns that edge texel again and again: the streaks. It scales with the tap count, which is why 2x barely showed it and 8x made it obvious. The fix asks for the mip level those gradients give (`sprite_level`) instead: the single filtered tap an anisotropy of 1 would take, at the same mip the sampler would have chosen. Only tiled faces take that path (`any(tiled - uv >= 0.5)` — the wrap shifts UVs by whole blocks); near blocks, RGSS and the meshes are untouched. ## 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: vanilla has no LOD tiles, so there is nothing to match. The per-block sampling this borrows (`sampleNearest`/`sampleRGSS` in `terrain.wgsl`, from `terrain.fsh`) is unchanged for blocks that are not tiled. No harness covers the LOD path. ## Other projects' code none ## Self-check ``` **pr_ready** (`tools/pr_ready.py --base upstream/main` on foggy-MacBookPro, against upstream/main at 26747867d, 3 min 22 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +19 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 511 passed (38 s) | | rustfmt | ✅ (12 s) | | clippy | ✅ (1 min 23 s) | | tests: horizon-client-render | ❌ 827 passed, 1 failed (1 min 7 s) | | doc tests | ✅ 0 passed (1 s) | | 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 | ➖ 364 affected, to run in CI (no vanilla data here): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 352 more | | Label | player-facing: `feature` if players get something new, no label for a fix | ``` The failing row is `gfx::frame_gen::interpolation::tests::moves_the_view_halfway_with_the_camera`: it dispatches GPU work and returns early when no adapter is available, so CI skips it. On this machine it fails identically on untouched `upstream/main` (verified with this change stashed), so it is not from this PR. The 364 parity harnesses are chosen by the changed file; they are CPU-side JSON comparisons, and CI runs them. ## Screenshots Before: the 8x streak on the far band in #5179 and in the tester's own capture of the same world. After: 2x, 4x and 8x now look the same on Intel Iris Plus Graphics (Vulkan, Mesa 26.2.5), with the near terrain unchanged. The tester confirmed the fix on their machine. ## Note Horizon's Max Anisotropy slider only offers 2x/4x/8x (`maxAnisotropyBit` 1..3), so players cannot turn anisotropic filtering off to dodge this; vanilla offers Off..16x. Deliberately not changed here. 🤖 Generated with [Codebuff](https://codebuff.com) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:21:25 +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#6490
No description provided.