[PR #2478] [MERGED] Mod API: render.set-far-terrain, and the official Far View mod #4354

Closed
opened 2026-11-03 04:16:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2478
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @ludovic111

Base: main ← Head: feat/far-view-mod-api


📝 Commits (2)

  • ae3737b Mod API: render.set-far-terrain, and the official Far View mod
  • 2374396 Merge main into feat/far-view-mod-api

📊 Changes

17 files changed (+263 additions, -27 deletions)

View changed files

📝 Cargo.lock (+7 -0)
📝 Cargo.toml (+1 -0)
📝 crates/horizon-client/src/game.rs (+25 -9)
📝 crates/horizon-client/src/game/mod_input.rs (+18 -0)
📝 crates/horizon-client/src/graphics.rs (+10 -6)
📝 crates/horizon-mod-sdk/wit/horizon.wit (+17 -0)
📝 crates/horizon-mods/src/api_level.rs (+3 -2)
📝 crates/horizon-mods/src/runtime.rs (+22 -3)
📝 crates/horizon-mods/tests/sandbox.rs (+18 -3)
📝 crates/horizon-mods/tests/ui_guest/src/lib.rs (+10 -0)
📝 docs/api/mods-reference.md (+8 -0)
📝 docs/api/stability.md (+6 -1)
📝 docs/graphics.md (+1 -1)
📝 docs/mods.md (+3 -2)
➕ mods/official/far-view/Cargo.toml (+16 -0)
➕ mods/official/far-view/horizon-mod.toml (+9 -0)
➕ mods/official/far-view/src/lib.rs (+89 -0)

📄 Description

Far terrain (LOD) is built into the game today and turned on with Graphics > LOD Distance. This PR lets a mod turn it on, the same way the minimap moved to the mod browser (#2056 API, #2058 mod): the game keeps the distant terrain engine, a mod picks how far it reaches. The official mod that uses it, Far View, is in this PR too (mods/official/far-view).

What a modder can do now

render.set-far-terrain(option<far-terrain>) draws the world past the render distance as distant terrain until the next call; none ends it.

  • distance: 64 to 1024 chunks (clamped). On integrated GPUs other than Apple's it is capped at 128, as LOD Distance is.
  • reduced: Far Detail's Reduced (coarser far tiles, 2 to 4 ms less GPU time on integrated graphics).

The game builds the tiles on its own workers, as it does for the setting: seed sampling, real chunks where they exist, the same frame and upload budgets. Simulation distance doesn't change. It shows where the setting shows (single player and a LAN world you host).

The player's own LOD Distance wins while it is on, as the minimap extra won over a mod. One far terrain shows at a time: the first loaded mod's.

It is API level 4 (api_level.rs). #2284 and #2300 also take levels 4 and 5; whichever merges second renumbers, the change is one line.

The Far View mod

mods/official/far-view (id far_view, capabilities render, ui, storage). Its settings page has two rows:

  • Distance: 64, 128, 256 (default), 512, 1024 chunks;
  • Far detail: Full (default) or Reduced.

They are kept in the mod's storage (distance, detail). The mod has no tick or frame hook: it tells the game what it wants at start and on each change.

Where it reads in the game

Game::far_terrain_choice returns the setting when it is on, else the mod's choice. prepare_lod, lod_distance (and so terrain_distance, fog and the depth range) and the per-frame Lod::update all read it, so nothing else changes with the setting on or no mod loaded. graphics::lod_distance_capped is the old lod_distance_on body, shared by both.

Self-check

  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings, and clippy for horizon-mods, far-view and the UI test guest, pass.
  • horizon-mods sandbox: render_far_terrain_is_clamped_and_ended (new, as the minimap's), a_mod_for_a_newer_horizon_is_refused (the UI guest now needs level 4) and render_minimap_is_clamped_and_hidden pass. docs/api/mods-reference.md regenerated (api_reference passes).
  • In game (fast build with --features mods, offscreen, fresh HORIZON_HOME, seed 42, server thread, render distance 8, LOD Distance left at 0):
    • without a mod: lod.source none, effective_distance 0, no far tiles;
    • with --dev-mod far_view.hmod (defaults): effective_distance 256, terrain_distance 256, source integrated, and the far terrain fills to 4064 active tiles (4321 target, all sampled, 5.9 M quads) about 40 s after joining. The view from y 160 at noon shows coasts and mountains to the horizon past the 8 loaded chunks.

🔄 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/2478 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/far-view-mod-api` --- ### 📝 Commits (2) - [`ae3737b`](https://github.com/horizon-rust/horizon/commit/ae3737b1c279efb2acb3092f04d6711820c2de61) Mod API: render.set-far-terrain, and the official Far View mod - [`2374396`](https://github.com/horizon-rust/horizon/commit/23743968e1caae0626b84bbeeb103fc18bd32827) Merge main into feat/far-view-mod-api ### 📊 Changes **17 files changed** (+263 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+7 -0) 📝 `Cargo.toml` (+1 -0) 📝 `crates/horizon-client/src/game.rs` (+25 -9) 📝 `crates/horizon-client/src/game/mod_input.rs` (+18 -0) 📝 `crates/horizon-client/src/graphics.rs` (+10 -6) 📝 `crates/horizon-mod-sdk/wit/horizon.wit` (+17 -0) 📝 `crates/horizon-mods/src/api_level.rs` (+3 -2) 📝 `crates/horizon-mods/src/runtime.rs` (+22 -3) 📝 `crates/horizon-mods/tests/sandbox.rs` (+18 -3) 📝 `crates/horizon-mods/tests/ui_guest/src/lib.rs` (+10 -0) 📝 `docs/api/mods-reference.md` (+8 -0) 📝 `docs/api/stability.md` (+6 -1) 📝 `docs/graphics.md` (+1 -1) 📝 `docs/mods.md` (+3 -2) ➕ `mods/official/far-view/Cargo.toml` (+16 -0) ➕ `mods/official/far-view/horizon-mod.toml` (+9 -0) ➕ `mods/official/far-view/src/lib.rs` (+89 -0) </details> ### 📄 Description Far terrain (LOD) is built into the game today and turned on with Graphics > LOD Distance. This PR lets a mod turn it on, the same way the minimap moved to the mod browser (#2056 API, #2058 mod): the game keeps the distant terrain engine, a mod picks how far it reaches. The official mod that uses it, **Far View**, is in this PR too (`mods/official/far-view`). ## What a modder can do now `render.set-far-terrain(option<far-terrain>)` draws the world past the render distance as distant terrain until the next call; `none` ends it. - `distance`: 64 to 1024 chunks (clamped). On integrated GPUs other than Apple's it is capped at 128, as LOD Distance is. - `reduced`: Far Detail's Reduced (coarser far tiles, 2 to 4 ms less GPU time on integrated graphics). The game builds the tiles on its own workers, as it does for the setting: seed sampling, real chunks where they exist, the same frame and upload budgets. Simulation distance doesn't change. It shows where the setting shows (single player and a LAN world you host). **The player's own LOD Distance wins** while it is on, as the minimap extra won over a mod. One far terrain shows at a time: the first loaded mod's. It is API level 4 (`api_level.rs`). #2284 and #2300 also take levels 4 and 5; whichever merges second renumbers, the change is one line. ## The Far View mod `mods/official/far-view` (id `far_view`, capabilities render, ui, storage). Its settings page has two rows: - **Distance**: 64, 128, 256 (default), 512, 1024 chunks; - **Far detail**: Full (default) or Reduced. They are kept in the mod's storage (`distance`, `detail`). The mod has no tick or frame hook: it tells the game what it wants at start and on each change. ## Where it reads in the game `Game::far_terrain_choice` returns the setting when it is on, else the mod's choice. `prepare_lod`, `lod_distance` (and so `terrain_distance`, fog and the depth range) and the per-frame `Lod::update` all read it, so nothing else changes with the setting on or no mod loaded. `graphics::lod_distance_capped` is the old `lod_distance_on` body, shared by both. ## Self-check - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`, and clippy for `horizon-mods`, `far-view` and the UI test guest, pass. - `horizon-mods` sandbox: `render_far_terrain_is_clamped_and_ended` (new, as the minimap's), `a_mod_for_a_newer_horizon_is_refused` (the UI guest now needs level 4) and `render_minimap_is_clamped_and_hidden` pass. `docs/api/mods-reference.md` regenerated (`api_reference` passes). - **In game** (fast build with `--features mods`, offscreen, fresh `HORIZON_HOME`, seed 42, server thread, render distance 8, LOD Distance left at 0): - without a mod: `lod.source` none, `effective_distance` 0, no far tiles; - with `--dev-mod far_view.hmod` (defaults): `effective_distance` 256, `terrain_distance` 256, source `integrated`, and the far terrain fills to 4064 active tiles (4321 target, all sampled, 5.9 M quads) about 40 s after joining. The view from y 160 at noon shows coasts and mountains to the horizon past the 8 loaded chunks. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:16:33 +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#4354
No description provided.