[PR #1162] [MERGED] Dynamic lights: held, dropped and burning light sources (Horizon Extras, off by default) #3377

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

📋 Pull Request Information

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

Base: main ← Head: feat/dynamic-lights


📝 Commits (1)

  • 832f879 Dynamic lights: held, dropped and burning light sources (Horizon Extras)

📊 Changes

9 files changed (+301 additions, -11 deletions)

View changed files

➕ crates/horizon-client/src/dynamic_light.rs (+133 -0)
📝 crates/horizon-client/src/entity.wgsl (+16 -2)
📝 crates/horizon-client/src/extras.rs (+21 -4)
📝 crates/horizon-client/src/game.rs (+14 -0)
➕ crates/horizon-client/src/game/dynamic_lights.rs (+67 -0)
📝 crates/horizon-client/src/gfx.rs (+14 -2)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/terrain.wgsl (+18 -2)
📝 docs/extras.md (+17 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #814. Asked for on Discord by famescare.

What

A new Horizon Extras option, Lighting > Dynamic lights (dynamicLights in horizon-extras.txt, off by default). When it is on, these light the blocks, mobs and hand around them, as LambDynamicLights and OptiFine do:

  • a torch, lantern, glowstone or other light-emitting item held by a player or mob (main or off hand);
  • the same item dropped on the ground;
  • any entity on fire.

An item glows like its block's default state: torch 14, lantern and glowstone 15, lit redstone torch 7. A lava bucket and burning entities give 15.

It runs only on the client, at render time. The light engine, chunk meshes, saves and the server never see it.

How

  • Each frame, game/dynamic_lights.rs gathers the sources (interpolated positions) and dynamic_light::select keeps the 16 nearest within 96 blocks, camera-relative.
  • They go into Globals.dynamic_lights, with the count in globals.time.z.
  • terrain.wgsl and entity.wgsl raise each vertex's block light to level - distance when that is brighter. That is one level per block, as block light falls off.
  • Off: the list is empty, so the count is 0. Nothing is gathered and the shader loop runs zero times (a uniform branch). No pipeline is rebuilt when the option is toggled.

Limits are written down in docs/extras.md and the FEATURES LATER list:

  • no occlusion: light reaches through walls up to its radius, like LambDynamicLights' fast mode;
  • at most 16 sources;
  • blazes, glow squids, magma cubes, spectral arrows and lit TNT or creepers don't glow yet.

Screenshots

M4 Pro, offscreen, 1280×720, midnight, the same process with the option toggled live. The player holds a torch.

Off On
off room on room
off shore on shore

In the dark stone-brick room, a zombie holds a lantern, a glowstone item sits on the floor and the player holds a torch. On the shore, 15 glowstone items lie in a ring 6 blocks around the player, plus the held torch.

Frame time

Setup: Mac mini M4 Pro, render distance 12, uncapped (maxFps:260, vsync off), the shore scene with 16 sources (15 dropped glowstone and the held torch).

The machine was not idle. Other sessions kept the load average at 90 to 106 on 14 threads, so the absolute numbers swing 3× to 10× between runs. Read them as an upper bound, not a clean measurement.

  • On vs off: 12 pairs of 5 s benches in one process, toggling the option between benches, alternating which goes first.

    median frame p50 median CPU p50
    Off 1.242 ms 0.894 ms
    On (16 sources) 1.310 ms 0.895 ms

    The paired difference is +0.14 ms by median and −0.03 ms by mean, which is within the noise. CPU time is unchanged.

  • main vs this branch with the option off: in separate processes the noise is larger than any effect (p50 0.8 ms to 14 ms for the same binary), so no number is meaningful here. By construction, off costs:

    • one if per frame;
    • 256 more bytes in the Globals uniform;
    • one uniform load and compare per vertex.

    It gathers nothing and samples nothing.

  • The renderer's GPU timer reads about 0 on Metal offscreen, so the bench gives no GPU-side split.

A quiet machine (the desktop, or the Mac mini when idle) would give a clean before/after. ~/scratch/f3-shots/pair.py and bench.sh on the Mac mini do the run.

Checks

  • cargo fmt --all -- --check: ok
  • cargo clippy -p horizon-client --all-targets -- -D warnings (pipefail): ok
  • cargo test -p horizon-client --lib: 983 passed. This includes the new dynamic_light tests, extras and the shader translation tests.
  • bin tests for options: ok
  • tools/parity.py --changed origin/main: 89 of the 94 selected harnesses pass. The other 5 (music, situational_music, sound_engine, sound_event, subtitle) fail in 0 s before running: this Mac mini's prepared shared-local/horizon-client/26.3 has no assets/minecraft/sounds.json (an environment gap, not this change; CI parity runs them)

🤖 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/1162 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/dynamic-lights` --- ### 📝 Commits (1) - [`832f879`](https://github.com/horizon-rust/horizon/commit/832f879b27f2fd9e4db913db51c6f836bf928d3f) Dynamic lights: held, dropped and burning light sources (Horizon Extras) ### 📊 Changes **9 files changed** (+301 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/src/dynamic_light.rs` (+133 -0) 📝 `crates/horizon-client/src/entity.wgsl` (+16 -2) 📝 `crates/horizon-client/src/extras.rs` (+21 -4) 📝 `crates/horizon-client/src/game.rs` (+14 -0) ➕ `crates/horizon-client/src/game/dynamic_lights.rs` (+67 -0) 📝 `crates/horizon-client/src/gfx.rs` (+14 -2) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/terrain.wgsl` (+18 -2) 📝 `docs/extras.md` (+17 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #814. Asked for on Discord by famescare. ## What A new **Horizon Extras** option, **Lighting > Dynamic lights** (`dynamicLights` in `horizon-extras.txt`, **off by default**). When it is on, these light the blocks, mobs and hand around them, as LambDynamicLights and OptiFine do: - a torch, lantern, glowstone or other light-emitting item held by a player or mob (main or off hand); - the same item dropped on the ground; - any entity on fire. An item glows like its block's default state: torch 14, lantern and glowstone 15, lit redstone torch 7. A lava bucket and burning entities give 15. It runs only on the client, at render time. The light engine, chunk meshes, saves and the server never see it. ## How - Each frame, `game/dynamic_lights.rs` gathers the sources (interpolated positions) and `dynamic_light::select` keeps the 16 nearest within 96 blocks, camera-relative. - They go into `Globals.dynamic_lights`, with the count in `globals.time.z`. - `terrain.wgsl` and `entity.wgsl` raise each vertex's block light to `level - distance` when that is brighter. That is one level per block, as block light falls off. - **Off:** the list is empty, so the count is 0. Nothing is gathered and the shader loop runs zero times (a uniform branch). No pipeline is rebuilt when the option is toggled. Limits are written down in docs/extras.md and the FEATURES LATER list: - no occlusion: light reaches through walls up to its radius, like LambDynamicLights' fast mode; - at most 16 sources; - blazes, glow squids, magma cubes, spectral arrows and lit TNT or creepers don't glow yet. ## Screenshots M4 Pro, offscreen, 1280×720, midnight, the same process with the option toggled live. The player holds a torch. | Off | On | |---|---| | ![off room](https://raw.githubusercontent.com/ludovic111/horizon/4a31b54b67289a52cf339f5f642878e8b308c4d/f3/off-room.png) | ![on room](https://raw.githubusercontent.com/ludovic111/horizon/4a31b54b67289a52cf339f5f642878e8b308c4d/f3/on-room.png) | | ![off shore](https://raw.githubusercontent.com/ludovic111/horizon/4a31b54b67289a52cf339f5f642878e8b308c4d/f3/off-shore.png) | ![on shore](https://raw.githubusercontent.com/ludovic111/horizon/4a31b54b67289a52cf339f5f642878e8b308c4d/f3/on-shore.png) | In the dark stone-brick room, a zombie holds a lantern, a glowstone item sits on the floor and the player holds a torch. On the shore, 15 glowstone items lie in a ring 6 blocks around the player, plus the held torch. ## Frame time Setup: Mac mini M4 Pro, render distance 12, uncapped (`maxFps:260`, vsync off), the shore scene with 16 sources (15 dropped glowstone and the held torch). **The machine was not idle.** Other sessions kept the load average at 90 to 106 on 14 threads, so the absolute numbers swing 3× to 10× between runs. Read them as an upper bound, not a clean measurement. - **On vs off:** 12 pairs of 5 s benches in one process, toggling the option between benches, alternating which goes first. | | median frame p50 | median CPU p50 | |---|---|---| | Off | 1.242 ms | 0.894 ms | | On (16 sources) | 1.310 ms | 0.895 ms | The paired difference is +0.14 ms by median and −0.03 ms by mean, which is within the noise. CPU time is unchanged. - **main vs this branch with the option off:** in separate processes the noise is larger than any effect (p50 0.8 ms to 14 ms for the same binary), so no number is meaningful here. By construction, off costs: - one `if` per frame; - 256 more bytes in the Globals uniform; - one uniform load and compare per vertex. It gathers nothing and samples nothing. - The renderer's GPU timer reads about 0 on Metal offscreen, so the bench gives no GPU-side split. A quiet machine (the desktop, or the Mac mini when idle) would give a clean before/after. `~/scratch/f3-shots/pair.py` and `bench.sh` on the Mac mini do the run. ## Checks - `cargo fmt --all -- --check`: ok - `cargo clippy -p horizon-client --all-targets -- -D warnings` (pipefail): ok - `cargo test -p horizon-client --lib`: 983 passed. This includes the new `dynamic_light` tests, extras and the shader translation tests. - bin tests for `options`: ok - `tools/parity.py --changed origin/main`: 89 of the 94 selected harnesses pass. The other 5 (`music`, `situational_music`, `sound_engine`, `sound_event`, `subtitle`) fail in 0 s before running: this Mac mini's prepared `shared-local/horizon-client/26.3` has no `assets/minecraft/sounds.json` (an environment gap, not this change; CI parity runs them) 🤖 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 04:09:05 +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#3377
No description provided.