[PR #5916] Far terrain: disk store, coarse-first loading, per-pixel boundary, GPU walk, mesh shaders, far entities #6559

Open
opened 2026-11-03 06:22:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5916
Author: @kacpherek
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: far-terrain


📝 Commits (10+)

  • fd119b1 Lower far terrain threads on macOS and Windows too
  • 5c487c1 Far terrain: sample coarse tiles first
  • 603936b Add the far entities wire format
  • f5c96bb Far terrain: an unknown neighbour is not empty
  • 7308a9f Feed far players and mobs to Horizon clients that ask for them
  • 2d812cf Hold split tiles 5% past the detail ring and the world threshold
  • b791bf7 Expose the solid side buckets for GPU draw lists
  • d6b3ef6 Far terrain: mesh tiles whole when the renderer masks them
  • 931bf4a Far terrain: keep tiles out of complete near columns per pixel
  • 599e910 Far terrain: use the screen-space boundary where the renderer can

📊 Changes

56 files changed (+9462 additions, -253 deletions)

View changed files

📝 crates/horizon-client-render/src/entity.wgsl (+4 -0)
📝 crates/horizon-client-render/src/gfx.rs (+357 -18)
📝 crates/horizon-client-render/src/gfx/cull.rs (+127 -7)
➕ crates/horizon-client-render/src/gfx/hiz.rs (+491 -0)
➕ crates/horizon-client-render/src/gfx/hiz.wgsl (+153 -0)
➕ crates/horizon-client-render/src/gfx/impostors.rs (+247 -0)
📝 crates/horizon-client-render/src/gfx/lod.rs (+230 -2)
➕ crates/horizon-client-render/src/gfx/lod_gpu.rs (+1072 -0)
➕ crates/horizon-client-render/src/gfx/lod_gpu.wgsl (+247 -0)
➕ crates/horizon-client-render/src/gfx/lod_gpu/tree.rs (+405 -0)
➕ crates/horizon-client-render/src/gfx/lod_gpu_advance.wgsl (+16 -0)
➕ crates/horizon-client-render/src/gfx/lod_gpu_items.wgsl (+18 -0)
➕ crates/horizon-client-render/src/gfx/lod_mesh.rs (+175 -0)
➕ crates/horizon-client-render/src/gfx/lod_mesh.wgsl (+159 -0)
➕ crates/horizon-client-render/src/gfx/lod_meshlet.rs (+151 -0)
➕ crates/horizon-client-render/src/gfx/lod_visibility.wgsl (+9 -0)
📝 crates/horizon-client-render/src/graphics.rs (+126 -1)
📝 crates/horizon-client-render/src/graphics_ui.rs (+78 -1)
➕ crates/horizon-client-render/src/impostor.rs (+775 -0)
➕ crates/horizon-client-render/src/impostor.wgsl (+50 -0)

...and 36 more files

📄 Description

What changes for players

  • Joining a world shows the horizon at once. Every level of far terrain is kept on disk per world and dimension, so a world you were in before shows its far terrain within seconds instead of being sampled again every session.
  • Far terrain loads from coarse to fine. The coarsest tiles come first, so the view is never empty, only rough for the first moments.
  • Far terrain on any server. Every chunk a server sends feeds the store, so a server you have played on shows what you saw there, even without its seed. Unseen areas stay empty; nothing is generated.
  • No holes or walls where near chunks meet far tiles. The boundary is kept per pixel (a mask of the near columns) instead of cutting tile geometry.
  • Smooth loading. Tiles under chunks that are already loaded are no longer swapped in view. Far terrain work on the render thread is capped at 2 ms a frame. Far threads run below the near ones on macOS and Windows too.
  • The far sea keeps its depth. Visited areas no longer light the sea floor as open sky, which showed a bright, shallow-looking patchwork through far water. Very far sea has a bed again instead of fog.
  • Far players and mobs. On Horizon servers, players and mobs beyond the tracking range are shown as impostors (baked sprites), depth-tested against far terrain.
  • The GPU picks what to draw. The far tile tree is walked on the GPU with frustum, screen-size and hierarchical depth tests. Tiles that lie wholly under complete near chunks are not drawn at all. On Vulkan devices with VK_EXT_mesh_shader, far terrain is drawn as meshlets culled per meshlet. Graphics, Advanced has Far Terrain Culling and Mesh Shaders settings; mesh shaders default to Auto, which means Vulkan only: on Metal the meshlet path measured slower (about 9 ms more CPU and 4 ms more GPU a frame on an M1 Pro), so it stays behind HORIZON_MESH_SHADERS=1 there. DX12 keeps the indirect path, because naga has no HLSL backend for mesh shaders yet.

Measurements

Apple M1 Pro (Metal), 1280x720 window, render distance 24, far distance 256 chunks, vsync on (120 Hz). main is this branch's base, built the same way. Both runs use copies of the same world. Each one stands for 10 s, then flies 1200 blocks west at y 130 over 40 s (horizon-ctl bench, horizon-ctl fly).

main this PR
Standing: avg FPS 94.2 96.2
Standing: GPU / CPU ms a frame 10.0 / 1.9 9.9 / 2.4
Flight: avg FPS 91.7 102.7
Flight: 1% low FPS 39.4 48.3
Flight: worst frame 32.2 ms 25.6 ms
Flight: GPU ms a frame 10.2 9.0

Before the last two commits, the same flight ran at 57 FPS. Mesh shaders on Metal and tiles drawn whole under the near chunks accounted for the difference. The screenshots at the end of the flight are identical.

Structure

The commits follow the stages, each builds on the previous:

  1. Threads and loading order: far threads lowered on every OS, coarse tiles sampled first, an unknown neighbour is no longer treated as empty.
  2. Store: per-world region files for every level (lod/store.rs), any footprint of columns merged, 96 open region files.
  3. Remote source: far terrain on any server from the chunks it sends.
  4. Per-pixel boundary: tiles meshed whole and masked in terrain.wgsl where the renderer can (render distance up to 63, no shader pack or native pack), the old cutout path otherwise.
  5. Hierarchical depth culling of far tiles and the Far Terrain Culling setting.
  6. Far entities: the horizon:far_entities wire format, the server feed (horizon-far-entity-range, 2048 by default, 0 turns it off), the client memory and the impostor atlas.
  7. GPU walk of the tile tree, 16-byte packed quads, meshlets and the mesh shader path.

Then fixes found while testing side by side with the old build: far sea floor light, deferred remesh under loaded chunks, render-thread budget, mesh shaders on Vulkan only, fully masked tiles skipped.

Testing

  • cargo clippy -p horizon-client-render -p horizon-client --all-targets -- -D warnings: clean.
  • cargo test: render 872 passed, client 1132 passed, Python tools 511 passed.
  • Played side by side with the old build on the same world, camera synced, over sea and land.

🔄 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/5916 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `far-terrain` --- ### 📝 Commits (10+) - [`fd119b1`](https://github.com/horizon-rust/horizon/commit/fd119b1a2857d9aeb786d4ee681d078067c09872) Lower far terrain threads on macOS and Windows too - [`5c487c1`](https://github.com/horizon-rust/horizon/commit/5c487c1335f86a01344c78bc4fae5010aeb032e5) Far terrain: sample coarse tiles first - [`603936b`](https://github.com/horizon-rust/horizon/commit/603936bcf1e59577253eecd68dd47b4b2135696e) Add the far entities wire format - [`f5c96bb`](https://github.com/horizon-rust/horizon/commit/f5c96bb6dc3af5020bd033328803d620b2fc7770) Far terrain: an unknown neighbour is not empty - [`7308a9f`](https://github.com/horizon-rust/horizon/commit/7308a9fa82916dfaf6e56171ff50dafd7fe2b373) Feed far players and mobs to Horizon clients that ask for them - [`2d812cf`](https://github.com/horizon-rust/horizon/commit/2d812cfb9a675f5a4bde6365bb43cdbf4b48a0ca) Hold split tiles 5% past the detail ring and the world threshold - [`b791bf7`](https://github.com/horizon-rust/horizon/commit/b791bf73db15c4eed19546a0876a31972c14f6f2) Expose the solid side buckets for GPU draw lists - [`d6b3ef6`](https://github.com/horizon-rust/horizon/commit/d6b3ef61ba84cebc8ae21bd8be2f1153f6cd5293) Far terrain: mesh tiles whole when the renderer masks them - [`931bf4a`](https://github.com/horizon-rust/horizon/commit/931bf4a008be6418260e57a7910f16c4c39f9db2) Far terrain: keep tiles out of complete near columns per pixel - [`599e910`](https://github.com/horizon-rust/horizon/commit/599e91083ab6100d85ef7788dd3de5cdd8087cde) Far terrain: use the screen-space boundary where the renderer can ### 📊 Changes **56 files changed** (+9462 additions, -253 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/entity.wgsl` (+4 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+357 -18) 📝 `crates/horizon-client-render/src/gfx/cull.rs` (+127 -7) ➕ `crates/horizon-client-render/src/gfx/hiz.rs` (+491 -0) ➕ `crates/horizon-client-render/src/gfx/hiz.wgsl` (+153 -0) ➕ `crates/horizon-client-render/src/gfx/impostors.rs` (+247 -0) 📝 `crates/horizon-client-render/src/gfx/lod.rs` (+230 -2) ➕ `crates/horizon-client-render/src/gfx/lod_gpu.rs` (+1072 -0) ➕ `crates/horizon-client-render/src/gfx/lod_gpu.wgsl` (+247 -0) ➕ `crates/horizon-client-render/src/gfx/lod_gpu/tree.rs` (+405 -0) ➕ `crates/horizon-client-render/src/gfx/lod_gpu_advance.wgsl` (+16 -0) ➕ `crates/horizon-client-render/src/gfx/lod_gpu_items.wgsl` (+18 -0) ➕ `crates/horizon-client-render/src/gfx/lod_mesh.rs` (+175 -0) ➕ `crates/horizon-client-render/src/gfx/lod_mesh.wgsl` (+159 -0) ➕ `crates/horizon-client-render/src/gfx/lod_meshlet.rs` (+151 -0) ➕ `crates/horizon-client-render/src/gfx/lod_visibility.wgsl` (+9 -0) 📝 `crates/horizon-client-render/src/graphics.rs` (+126 -1) 📝 `crates/horizon-client-render/src/graphics_ui.rs` (+78 -1) ➕ `crates/horizon-client-render/src/impostor.rs` (+775 -0) ➕ `crates/horizon-client-render/src/impostor.wgsl` (+50 -0) _...and 36 more files_ </details> ### 📄 Description ## What changes for players - **Joining a world shows the horizon at once.** Every level of far terrain is kept on disk per world and dimension, so a world you were in before shows its far terrain within seconds instead of being sampled again every session. - **Far terrain loads from coarse to fine.** The coarsest tiles come first, so the view is never empty, only rough for the first moments. - **Far terrain on any server.** Every chunk a server sends feeds the store, so a server you have played on shows what you saw there, even without its seed. Unseen areas stay empty; nothing is generated. - **No holes or walls where near chunks meet far tiles.** The boundary is kept per pixel (a mask of the near columns) instead of cutting tile geometry. - **Smooth loading.** Tiles under chunks that are already loaded are no longer swapped in view. Far terrain work on the render thread is capped at 2 ms a frame. Far threads run below the near ones on macOS and Windows too. - **The far sea keeps its depth.** Visited areas no longer light the sea floor as open sky, which showed a bright, shallow-looking patchwork through far water. Very far sea has a bed again instead of fog. - **Far players and mobs.** On Horizon servers, players and mobs beyond the tracking range are shown as impostors (baked sprites), depth-tested against far terrain. - **The GPU picks what to draw.** The far tile tree is walked on the GPU with frustum, screen-size and hierarchical depth tests. Tiles that lie wholly under complete near chunks are not drawn at all. On Vulkan devices with `VK_EXT_mesh_shader`, far terrain is drawn as meshlets culled per meshlet. Graphics, Advanced has Far Terrain Culling and Mesh Shaders settings; mesh shaders default to Auto, which means Vulkan only: on Metal the meshlet path measured slower (about 9 ms more CPU and 4 ms more GPU a frame on an M1 Pro), so it stays behind `HORIZON_MESH_SHADERS=1` there. DX12 keeps the indirect path, because naga has no HLSL backend for mesh shaders yet. ## Measurements Apple M1 Pro (Metal), 1280x720 window, render distance 24, far distance 256 chunks, vsync on (120 Hz). `main` is this branch's base, built the same way. Both runs use copies of the same world. Each one stands for 10 s, then flies 1200 blocks west at y 130 over 40 s (`horizon-ctl bench`, `horizon-ctl fly`). | | `main` | this PR | |---|---|---| | Standing: avg FPS | 94.2 | 96.2 | | Standing: GPU / CPU ms a frame | 10.0 / 1.9 | 9.9 / 2.4 | | Flight: avg FPS | 91.7 | 102.7 | | Flight: 1% low FPS | 39.4 | 48.3 | | Flight: worst frame | 32.2 ms | 25.6 ms | | Flight: GPU ms a frame | 10.2 | 9.0 | Before the last two commits, the same flight ran at 57 FPS. Mesh shaders on Metal and tiles drawn whole under the near chunks accounted for the difference. The screenshots at the end of the flight are identical. ## Structure The commits follow the stages, each builds on the previous: 1. Threads and loading order: far threads lowered on every OS, coarse tiles sampled first, an unknown neighbour is no longer treated as empty. 2. Store: per-world region files for every level (`lod/store.rs`), any footprint of columns merged, 96 open region files. 3. Remote source: far terrain on any server from the chunks it sends. 4. Per-pixel boundary: tiles meshed whole and masked in `terrain.wgsl` where the renderer can (render distance up to 63, no shader pack or native pack), the old cutout path otherwise. 5. Hierarchical depth culling of far tiles and the Far Terrain Culling setting. 6. Far entities: the `horizon:far_entities` wire format, the server feed (`horizon-far-entity-range`, 2048 by default, 0 turns it off), the client memory and the impostor atlas. 7. GPU walk of the tile tree, 16-byte packed quads, meshlets and the mesh shader path. Then fixes found while testing side by side with the old build: far sea floor light, deferred remesh under loaded chunks, render-thread budget, mesh shaders on Vulkan only, fully masked tiles skipped. ## Testing - `cargo clippy -p horizon-client-render -p horizon-client --all-targets -- -D warnings`: clean. - `cargo test`: render 872 passed, client 1132 passed, Python tools 511 passed. - Played side by side with the old build on the same world, camera synced, over sea and land. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6559
No description provided.