[PR #3848] [MERGED] Light: an emitter placed in its own light only brightens (vanilla checkNode) #5246

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

📋 Pull Request Information

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

Base: main ← Head: perf/block-light-check-node


📝 Commits (1)

  • 01b4e5c Light: an emitter placed in its own light only brightens

📊 Changes

1 file changed (+61 additions, -0 deletions)

View changed files

📝 crates/horizon-client-render/src/light.rs (+61 -0)

📄 Description

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

What and why

Second fix for the RD 32 ocean flight's lows in #3471 (first: #3831). While a fresh area loads, fluids settle and falling blocks drop. Over the ocean that means air → flowing water, sand/gravel → air, and air → flowing lava (cave lava below the sea floor). The server sends these, and the client relights each changed block on the render thread (Streaming::relight_edits, lt_block in HORIZON_SPIKES).

relight_layer cleared every changed block's light and ran a decrease from its old level. Vanilla's BlockLightEngine.checkNode (26.3, read with tools/rea_vanilla.py method net.minecraft.world.level.lighting.BlockLightEngine checkNode) does that only when the new emission is below the stored level:

if (lightEmission < oldLevel) {
    storage.setStoredLevel(blockNode, 0);
    enqueueDecrease(blockNode, QueueEntry.decreaseAllDirections(oldLevel));
} else {
    enqueueDecrease(blockNode, PULL_LIGHT_IN_ENTRY);
}
if (lightEmission > 0) enqueueIncrease(blockNode, QueueEntry.increaseLightFromEmission(...));

So each flowing-lava block placed beside lava (light 14 there, emission 15) darkened and relit up to 14 blocks around it, and marked every section in that radius changed, so they were all queued for remeshing. Now the block layer follows checkNode. A block emitting at least the stored light keeps it, pulls its neighbours' light in (a decrease entry from level 0, which only sends lit neighbours to the increase pass), and spreads from its emission. Sky light and the forced replays (force) are unchanged.

Measured (Mac mini M4 Pro, tools/perf_bench.py --scenes ocean --distances 32 --offscreen, fast build, HORIZON_SPIKES=0)

Base and this branch alternated 3 times each. Load average 36–67 from other builds (the session was locked, hence --offscreen). The base binary is main 0a95d1c04, whose light.rs is the same as main's now.

per run base this PR
in-frame lt_block, sum of spans ≥ 0.5 ms 28.1, 16.7, 30.0 ms 6.6, 7.4, 7.7 ms
frames with lt_block ≥ 1 ms 11, 7, 8 3, 3, 3
longest lt_block 2.3, 2.0, 2.2 ms 1.2, 1.1, 1.3 ms
flight avg / 1% / 0.1% FPS 358/195/152, 366/189/157, 360/178/104 365/179/120, 362/186/129, 364/196/156

The Mac is GPU-bound in this scene (p50 2.7 ms), so the flight's FPS stays within noise. What changes is the CPU the render thread spends relighting, plus the remeshes no longer queued. On #3471's Windows machine (p50 0.8 ms) that time is part of the slow frames. d3grando's idle-machine rerun after #3831 and this PR will tell how much.

Tests

New emitters_placed_in_their_own_light_only_brighten: torches placed one after another in their own light never darken a cell, end equal to a full relight, and relighting an emitter whose level is unchanged reports no change, so nothing is remeshed. It fails on main (the last assertion) and passes here. The existing exact-match tests (incremental_relight_matches_full_relight, random_border_relights_match_full_relight, relighting_reports_exactly_the_changed_positions) pass.

Vanilla reference

net.minecraft.world.level.lighting.BlockLightEngine.checkNode (26.3); LightEngine.PULL_LIGHT_IN_ENTRY is the decrease entry with level 0.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at c7065027b, 8 min 14 s)

Check Result
Scope ✅ 1 files, +61 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 423 passed (3 min 15 s)
rustfmt ✅ (8 s)
clippy ❌ failed (44 s)
tests: horizon-client-render ✅ 548 passed (1 min 24 s)
doc tests ✅ 0 passed (12 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 ➖ 108 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 96 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The clippy ❌ is not this PR: on macOS, gfx.rs's log_display (from #3461) is dead code, because its only caller is Linux-only, so -D warnings fails on plain main too; CI's verify runs on Linux. Parity: the light harness runs locally (result in a comment); CI's parity job runs the 108 affected harnesses.

🤖 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/3848 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/block-light-check-node` --- ### 📝 Commits (1) - [`01b4e5c`](https://github.com/horizon-rust/horizon/commit/01b4e5cbc4fa6cdb4d90e0256cc617ce006eeeb4) Light: an emitter placed in its own light only brightens ### 📊 Changes **1 file changed** (+61 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/light.rs` (+61 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Second fix for the RD 32 ocean flight's lows in #3471 (first: #3831). While a fresh area loads, fluids settle and falling blocks drop. Over the ocean that means air → flowing water, sand/gravel → air, and air → **flowing lava** (cave lava below the sea floor). The server sends these, and the client relights each changed block on the render thread (`Streaming::relight_edits`, `lt_block` in `HORIZON_SPIKES`). `relight_layer` cleared every changed block's light and ran a decrease from its old level. Vanilla's `BlockLightEngine.checkNode` (26.3, read with `tools/rea_vanilla.py method net.minecraft.world.level.lighting.BlockLightEngine checkNode`) does that only when the new emission is **below** the stored level: ```java if (lightEmission < oldLevel) { storage.setStoredLevel(blockNode, 0); enqueueDecrease(blockNode, QueueEntry.decreaseAllDirections(oldLevel)); } else { enqueueDecrease(blockNode, PULL_LIGHT_IN_ENTRY); } if (lightEmission > 0) enqueueIncrease(blockNode, QueueEntry.increaseLightFromEmission(...)); ``` So each flowing-lava block placed beside lava (light 14 there, emission 15) darkened and relit up to 14 blocks around it, and marked every section in that radius changed, so they were all queued for remeshing. Now the block layer follows `checkNode`. A block emitting at least the stored light keeps it, pulls its neighbours' light in (a decrease entry from level 0, which only sends lit neighbours to the increase pass), and spreads from its emission. Sky light and the forced replays (`force`) are unchanged. ## Measured (Mac mini M4 Pro, `tools/perf_bench.py --scenes ocean --distances 32 --offscreen`, fast build, `HORIZON_SPIKES=0`) Base and this branch alternated 3 times each. Load average 36–67 from other builds (the session was locked, hence `--offscreen`). The base binary is main 0a95d1c04, whose `light.rs` is the same as main's now. | per run | base | this PR | |---|---|---| | in-frame `lt_block`, sum of spans ≥ 0.5 ms | 28.1, 16.7, 30.0 ms | 6.6, 7.4, 7.7 ms | | frames with `lt_block` ≥ 1 ms | 11, 7, 8 | 3, 3, 3 | | longest `lt_block` | 2.3, 2.0, 2.2 ms | 1.2, 1.1, 1.3 ms | | flight avg / 1% / 0.1% FPS | 358/195/152, 366/189/157, 360/178/104 | 365/179/120, 362/186/129, 364/196/156 | The Mac is GPU-bound in this scene (p50 2.7 ms), so the flight's FPS stays within noise. What changes is the CPU the render thread spends relighting, plus the remeshes no longer queued. On #3471's Windows machine (p50 0.8 ms) that time is part of the slow frames. d3grando's idle-machine rerun after #3831 and this PR will tell how much. ## Tests New `emitters_placed_in_their_own_light_only_brighten`: torches placed one after another in their own light never darken a cell, end equal to a full relight, and relighting an emitter whose level is unchanged reports no change, so nothing is remeshed. It fails on main (the last assertion) and passes here. The existing exact-match tests (`incremental_relight_matches_full_relight`, `random_border_relights_match_full_relight`, `relighting_reports_exactly_the_changed_positions`) pass. ## Vanilla reference `net.minecraft.world.level.lighting.BlockLightEngine.checkNode` (26.3); `LightEngine.PULL_LIGHT_IN_ENTRY` is the decrease entry with level 0. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at c7065027b, 8 min 14 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +61 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 423 passed (3 min 15 s) | | rustfmt | ✅ (8 s) | | clippy | ❌ failed (44 s) | | tests: horizon-client-render | ✅ 548 passed (1 min 24 s) | | doc tests | ✅ 0 passed (12 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 | ➖ 108 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 96 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The clippy ❌ is not this PR: on macOS, `gfx.rs`'s `log_display` (from #3461) is dead code, because its only caller is Linux-only, so `-D warnings` fails on plain main too; CI's verify runs on Linux. Parity: the `light` harness runs locally (result in a comment); CI's parity job runs the 108 affected harnesses. 🤖 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:11:14 +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#5246
No description provided.