From 4f3326e983eb19f945b7b4654640523695b993f6 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 00:22:27 +0200 Subject: [PATCH 1/2] Mesh a column once its neighbours' light has settled A new chunk relights its eight neighbours, and every finished light job dirties all sections of the 3x3 columns around it. Meshing waited only for the column itself to be lit, so sections near the loading frontier were meshed with half-settled light and again after each neighbour's relight: about 2.25 meshes per section while a world loads. Wait until no column of the 3x3 is being lit or queued for light. The final meshes are the same; they are built once. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/streaming.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/horizon-client/src/streaming.rs b/crates/horizon-client/src/streaming.rs index 664606fbe..1837216e5 100644 --- a/crates/horizon-client/src/streaming.rs +++ b/crates/horizon-client/src/streaming.rs @@ -821,13 +821,21 @@ impl Streaming { self.waiting.insert((x, sy, z)); continue; } - // Once per column: the 3x3 lit check would otherwise repeat for - // each of its sections every frame. - let lit = &self.lit; + // Once per column: the 3x3 check would otherwise repeat for each + // of its sections every frame. A neighbour being lit or waiting + // for light dirties this column again when it finishes (new + // chunks relight their eight neighbours), so mesh once its light + // has settled rather than once per neighbour. + let (lit, lighting, dirty_light) = (&self.lit, &self.lighting, &world.dirty_light); let ready = *ready_columns.entry((x, z)).or_insert_with(|| { - (-1..=1).all(|dz| (-1..=1).all(|dx| lit.contains(&(x + dx, z + dz)))) + (-1..=1).all(|dz| { + (-1..=1).all(|dx| { + let n = (x + dx, z + dz); + lit.contains(&n) && !lighting.contains_key(&n) && !dirty_light.contains(&n) + }) + }) }); - if !ready || self.lighting.contains_key(&(x, z)) { + if !ready { continue; } let region = columns From 78f206bc223ec4c80378f2840db4d979598fada8 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 02:24:57 +0200 Subject: [PATCH 2/2] Mesh only when no neighbour is being lit; skip columns that can't be lit yet Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/streaming.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/horizon-client/src/streaming.rs b/crates/horizon-client/src/streaming.rs index 1837216e5..9d5c7dd50 100644 --- a/crates/horizon-client/src/streaming.rs +++ b/crates/horizon-client/src/streaming.rs @@ -822,16 +822,18 @@ impl Streaming { continue; } // Once per column: the 3x3 check would otherwise repeat for each - // of its sections every frame. A neighbour being lit or waiting - // for light dirties this column again when it finishes (new - // chunks relight their eight neighbours), so mesh once its light - // has settled rather than once per neighbour. - let (lit, lighting, dirty_light) = (&self.lit, &self.lighting, &world.dirty_light); + // of its sections every frame. A neighbour being lit dirties this + // column again when its light job finishes (new chunks relight + // their eight neighbours), so wait for it rather than mesh once + // per neighbour. Columns still in `dirty_light` here can't be lit + // yet (a neighbour of theirs is missing): waiting for them could + // last until the player comes back. + let (lit, lighting) = (&self.lit, &self.lighting); let ready = *ready_columns.entry((x, z)).or_insert_with(|| { (-1..=1).all(|dz| { (-1..=1).all(|dx| { let n = (x + dx, z + dz); - lit.contains(&n) && !lighting.contains_key(&n) && !dirty_light.contains(&n) + lit.contains(&n) && !lighting.contains_key(&n) }) }) });