[PR #4159] [MERGED] Far terrain fades in and out chunk by chunk, near chunks too #5452

Closed
opened 2026-11-03 05:12:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4159
Author: @spidercraft
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: far-terrain-fade


📝 Commits (8)

  • 2e321e3 Far terrain: decorated chunks kept on disk, read again next session
  • 8922550 Far terrain cache: a chunk cached already is not written again
  • fb9db82 Far terrain: real chunks out to level 2 on idle threads, loading outward from the player
  • ee7d443 Far terrain: shaded water and canopies, swamp grass, no floor pillars or water walls
  • ada4e65 Far terrain fades in chunk by chunk, and near chunks fade in over it
  • 94f48bb Far terrain: near chunks and far tiles fade out as they came
  • 3554efb Far terrain: a circular range; tiles leaving it fade out instead of being cut
  • 963b7d8 Far terrain: chunks leaving the render distance stay in front until they have faded

📊 Changes

12 files changed (+1375 additions, -310 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+128 -16)
📝 crates/horizon-client-render/src/gfx/lod.rs (+305 -26)
📝 crates/horizon-client-render/src/gfx/pack_atlas.rs (+1 -1)
📝 crates/horizon-client-render/src/gfx/resident.rs (+8 -0)
📝 crates/horizon-client-render/src/lod.rs (+125 -160)
➕ crates/horizon-client-render/src/lod/cache.rs (+356 -0)
📝 crates/horizon-client-render/src/lod/mesh.rs (+198 -65)
📝 crates/horizon-client-render/src/mesher.rs (+9 -0)
📝 crates/horizon-client-render/src/terrain.wgsl (+81 -6)
📝 crates/horizon-client/src/game.rs (+0 -1)
📝 crates/horizon-client/src/save.rs (+41 -7)
📝 crates/horizon-client/src/vanillagen/lod.rs (+123 -28)

📄 Description

🤖 Opened by Claude Code.

Far terrain, part 4 of 4. This PR: fades. Built on #4158 (part 3, which contains #4157 and #4156: merge them first; review this PR's own commit).

What and why

Far tiles and near chunks appeared at once, popping in over each other. They now fade in, chunk by chunk:

  • New far tiles fade in over the ones they replace, and new near sections over far terrain. Each chunk-sized column of a tile (wider for coarse tiles) starts in turn over the first half of 600 ms and fades over the second, as a 4×4 ordered dither fixed to the terrain. Its unit is the power of two of a block nearest 1.5 pixels, so it stays fine up close, does not sparkle far off, and does not crawl as the camera moves (a screen-space pattern shimmered under FXAA).
  • No pixel drawn twice, no hole. The tiles being replaced stay whole behind until the fade ends, and a fading tile or section is drawn a hair toward the camera, the newest most, so wherever it draws it wins the depth test.
  • Far tiles sit 0.2% of their distance behind near chunks. While a column's near chunks load, its far tile stays under them; near water lies a little below far water (vanilla's fluid corner heights), and the previous hair-sized step let far water draw over near water: two waters, opaque. Found by tinting each layer.
  • Water and other see-through faces are not dithered, and near water is drawn before far water, replaced tiles' last, so depth keeps each layer to where the one before has none.
  • A tile re-meshed around new near chunks or finer tiles keeps drawing its old mesh until they are in, and a tile over nothing shows whole (its hidden chunks opened holes to the sea bed: dark patches while far terrain first loads).

Unloading fades too (second commit): a section whose column far terrain now draws (a shorter render distance, the player moving away) fades out over it, chunk by chunk as it came, and is released once it has (Renderer::leave_section); columns far tiles still leave out stay drawn until they don't (#3765), then fade out the same way. A far tile leaving the plan with nothing to replace it (out of range) fades out; one replaced by new tiles or near chunks stays whole behind them, as two patterns fading at once left holes between them. The fade code gains a fading-out range (65 to 128 sixty-fourths, 129 values a level); a section's largest code, 129, keeps its UV step exact.

A circular range (third commit): the renderer cut far tiles past the LOD distance, a circle, every frame, while the plan kept tiles out to a square, so tiles popped out at the circle as the player moved, before the plan dropped them and before their fade-out could run. The plan's range is now that circle (TileKey::reach) and the renderer cuts by the frustum only: a tile leaving the range leaves the plan and fades out, as tiles entering it fade in.

Chunks leaving the render distance (fourth commit) popped to far terrain: their fading-out sections were culled past the render distance, so the fade ran unseen, and far terrain's coarser blocks, standing a little out of the real ones, hid them the moment the tile under them was meshed. Columns with sections fading out are drawn past the render distance, and held or fading-out sections (lod::HELD) go 2% of their distance toward the camera. Measured frame by frame over a forest, render distance 10 to 3: the change spreads over about 0.33 s instead of one frame.

The fade rides in the instance's UV step: a fading tile or section negates it past a fade code. terrain.wgsl and GLSL packs (pack_atlas.rs) read the step as fract(abs(w)), unchanged for anything whole. Shader packs draw without the fade; not tried with a pack in game.

Tests

#4144 (kelp is water in loaded chunks) merges cleanly with every part of this stack, and the merge of this PR with it builds and passes the far terrain tests (#4144's own included).

tiles_fade_in_on_their_own_grid checks the fade codes; the WGSL validates in the renderer's shader tests. Checked in game by its author: flying, render distance 2 → 13, reopening the world; unloading, render distance 10 → 3 over a bay on this branch (with main's #3765): no hole or pop.

pr_ready (tools/pr_ready.py --quick on SpiderPC, against origin/main at 25f9cd3a9, 1 min 17 s)

Check Result
Scope ⚠️ 12 files, +1355 −310; 1665 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 480 passed (25 s)
rustfmt ✅ (5 s)
clippy ✅ (17 s)
tests: horizon-client, horizon-client-render ✅ 1527 passed (28 s)
doc tests ✅ 0 passed (2 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 ➖ 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)

🤖 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/4159 **Author:** [@spidercraft](https://github.com/spidercraft) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `far-terrain-fade` --- ### 📝 Commits (8) - [`2e321e3`](https://github.com/horizon-rust/horizon/commit/2e321e385a769bcaaff350c4fb194c89eefbfd1a) Far terrain: decorated chunks kept on disk, read again next session - [`8922550`](https://github.com/horizon-rust/horizon/commit/8922550fdf258558b0a03609772168ce8c5fe6d6) Far terrain cache: a chunk cached already is not written again - [`fb9db82`](https://github.com/horizon-rust/horizon/commit/fb9db82d1b32968e3ab419498cefefe39c733a2f) Far terrain: real chunks out to level 2 on idle threads, loading outward from the player - [`ee7d443`](https://github.com/horizon-rust/horizon/commit/ee7d443c8f0f4c56d10882cde7d6e330e00b6278) Far terrain: shaded water and canopies, swamp grass, no floor pillars or water walls - [`ada4e65`](https://github.com/horizon-rust/horizon/commit/ada4e6567d7980fd31875e0724901a0100dfd6e3) Far terrain fades in chunk by chunk, and near chunks fade in over it - [`94f48bb`](https://github.com/horizon-rust/horizon/commit/94f48bbf6a5d3d0939560c376b91178601605a51) Far terrain: near chunks and far tiles fade out as they came - [`3554efb`](https://github.com/horizon-rust/horizon/commit/3554efb04f356bc27c2caa4cf4f50ee8b61740fe) Far terrain: a circular range; tiles leaving it fade out instead of being cut - [`963b7d8`](https://github.com/horizon-rust/horizon/commit/963b7d8bd9a082756cbb6298b2866c706bf2eef6) Far terrain: chunks leaving the render distance stay in front until they have faded ### 📊 Changes **12 files changed** (+1375 additions, -310 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+128 -16) 📝 `crates/horizon-client-render/src/gfx/lod.rs` (+305 -26) 📝 `crates/horizon-client-render/src/gfx/pack_atlas.rs` (+1 -1) 📝 `crates/horizon-client-render/src/gfx/resident.rs` (+8 -0) 📝 `crates/horizon-client-render/src/lod.rs` (+125 -160) ➕ `crates/horizon-client-render/src/lod/cache.rs` (+356 -0) 📝 `crates/horizon-client-render/src/lod/mesh.rs` (+198 -65) 📝 `crates/horizon-client-render/src/mesher.rs` (+9 -0) 📝 `crates/horizon-client-render/src/terrain.wgsl` (+81 -6) 📝 `crates/horizon-client/src/game.rs` (+0 -1) 📝 `crates/horizon-client/src/save.rs` (+41 -7) 📝 `crates/horizon-client/src/vanillagen/lod.rs` (+123 -28) </details> ### 📄 Description > 🤖 Opened by Claude Code. **Far terrain, part 4 of 4.** This PR: fades. Built on #4158 (part 3, which contains #4157 and #4156: merge them first; review this PR's own commit). ## What and why Far tiles and near chunks appeared at once, popping in over each other. They now fade in, chunk by chunk: - **New far tiles fade in over the ones they replace, and new near sections over far terrain.** Each chunk-sized column of a tile (wider for coarse tiles) starts in turn over the first half of 600 ms and fades over the second, as a 4×4 ordered dither fixed to the terrain. Its unit is the power of two of a block nearest 1.5 pixels, so it stays fine up close, does not sparkle far off, and does not crawl as the camera moves (a screen-space pattern shimmered under FXAA). - **No pixel drawn twice, no hole.** The tiles being replaced stay whole behind until the fade ends, and a fading tile or section is drawn a hair toward the camera, the newest most, so wherever it draws it wins the depth test. - **Far tiles sit 0.2% of their distance behind near chunks.** While a column's near chunks load, its far tile stays under them; near water lies a little below far water (vanilla's fluid corner heights), and the previous hair-sized step let far water draw over near water: two waters, opaque. Found by tinting each layer. - **Water and other see-through faces are not dithered**, and near water is drawn before far water, replaced tiles' last, so depth keeps each layer to where the one before has none. - **A tile re-meshed around new near chunks or finer tiles keeps drawing its old mesh** until they are in, and a tile over nothing shows whole (its hidden chunks opened holes to the sea bed: dark patches while far terrain first loads). **Unloading fades too** (second commit): a section whose column far terrain now draws (a shorter render distance, the player moving away) fades out over it, chunk by chunk as it came, and is released once it has (`Renderer::leave_section`); columns far tiles still leave out stay drawn until they don't (#3765), then fade out the same way. A far tile leaving the plan with nothing to replace it (out of range) fades out; one replaced by new tiles or near chunks stays whole behind them, as two patterns fading at once left holes between them. The fade code gains a fading-out range (65 to 128 sixty-fourths, 129 values a level); a section's largest code, 129, keeps its UV step exact. **A circular range** (third commit): the renderer cut far tiles past the LOD distance, a circle, every frame, while the plan kept tiles out to a square, so tiles popped out at the circle as the player moved, before the plan dropped them and before their fade-out could run. The plan's range is now that circle (`TileKey::reach`) and the renderer cuts by the frustum only: a tile leaving the range leaves the plan and fades out, as tiles entering it fade in. **Chunks leaving the render distance** (fourth commit) popped to far terrain: their fading-out sections were culled past the render distance, so the fade ran unseen, and far terrain's coarser blocks, standing a little out of the real ones, hid them the moment the tile under them was meshed. Columns with sections fading out are drawn past the render distance, and held or fading-out sections (`lod::HELD`) go 2% of their distance toward the camera. Measured frame by frame over a forest, render distance 10 to 3: the change spreads over about 0.33 s instead of one frame. The fade rides in the instance's UV step: a fading tile or section negates it past a fade code. `terrain.wgsl` and GLSL packs (`pack_atlas.rs`) read the step as `fract(abs(w))`, unchanged for anything whole. Shader packs draw without the fade; not tried with a pack in game. ## Tests #4144 (kelp is water in loaded chunks) merges cleanly with every part of this stack, and the merge of this PR with it builds and passes the far terrain tests (#4144's own included). `tiles_fade_in_on_their_own_grid` checks the fade codes; the WGSL validates in the renderer's shader tests. Checked in game by its author: flying, render distance 2 → 13, reopening the world; unloading, render distance 10 → 3 over a bay on this branch (with main's #3765): no hole or pop. **pr_ready** (`tools/pr_ready.py --quick` on SpiderPC, against origin/main at 25f9cd3a9, 1 min 17 s) | Check | Result | | --- | --- | | Scope | ⚠️ 12 files, +1355 −310; 1665 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 480 passed (25 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (17 s) | | tests: horizon-client, horizon-client-render | ✅ 1527 passed (28 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 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) | 🤖 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 05:12:41 +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#5452
No description provided.