From 263d7ab765947332099f3c662f32ee5de605eded Mon Sep 17 00:00:00 2001
From: pkuzic
Date: Fri, 25 Sep 2026 17:02:09 +0100
Subject: [PATCH] MONKEY (fix-sky): order the sky and cloud FX readers after
tick_clouds
Review B9: update_sky_colors and update_cloud_fx read the cloud coverage with no
order against tick_clouds, so the glow's cover sample was this frame's or the
last one's nondeterministically. New CloudTick set; both run after it.
Co-Authored-By: Claude Opus 5.5
---
crates/benilla-world/src/clouds/mod.rs | 13 +++++++++++--
crates/benilla-world/src/sky.rs | 5 ++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/crates/benilla-world/src/clouds/mod.rs b/crates/benilla-world/src/clouds/mod.rs
index 8464004e..58d5463b 100644
--- a/crates/benilla-world/src/clouds/mod.rs
+++ b/crates/benilla-world/src/clouds/mod.rs
@@ -63,14 +63,18 @@ impl Plugin for CloudsPlugin {
// air's density and palette rather than the water's.
tick_clouds
.after(crate::liquid::SubmersionVerdict)
- .in_set(crate::lighting::LightingConsumeSet),
+ .in_set(crate::lighting::LightingConsumeSet)
+ .in_set(CloudTick),
// After the skybox resolve and the submersion verdict, so the dome hides in
// the same frame as the rest of the sky.
layer::apply_cloud_visibility
.after(crate::skybox::SkyboxResolve)
.after(crate::liquid::SubmersionVerdict),
// MONKEY (sky): the High cloud shading's per-frame inputs.
- layer::update_cloud_fx.in_set(crate::lighting::LightingConsumeSet),
+ // MONKEY (fix-sky): after this frame's tile, deterministically.
+ layer::update_cloud_fx
+ .in_set(crate::lighting::LightingConsumeSet)
+ .after(CloudTick),
),
)
// Camera-anchored after transform propagation, like the sky dome.
@@ -83,6 +87,11 @@ impl Plugin for CloudsPlugin {
/// Advances the coverage field (a full rebuild first, then the 10 Hz band scroll) and re-uploads
/// its texels when they change, as the reference does per regen (`0x58ac70`).
+/// MONKEY (fix-sky): the cloud tile/coverage update, so the sky and cloud FX readers can order
+/// after it (review B9: the ambiguous order made the glow's cover sample frame-nondeterministic).
+#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
+pub(crate) struct CloudTick;
+
fn tick_clouds(
mut cov: ResMut,
light: Res,
diff --git a/crates/benilla-world/src/sky.rs b/crates/benilla-world/src/sky.rs
index f41bbf0f..90552c67 100644
--- a/crates/benilla-world/src/sky.rs
+++ b/crates/benilla-world/src/sky.rs
@@ -137,7 +137,10 @@ impl Plugin for SkyPlugin {
(
// Reads the resolved atmosphere: unordered, it would paint last frame's
// palette, the underwater one on a surfacing frame.
- update_sky_colors.in_set(crate::lighting::LightingConsumeSet),
+ // MONKEY (fix-sky): after the cloud tile, so the glow reads this frame's cover.
+ update_sky_colors
+ .in_set(crate::lighting::LightingConsumeSet)
+ .after(crate::clouds::CloudTick),
// The skybox and submersion gates must read their settled resolves.
apply_sky_visibility
.after(crate::skybox::SkyboxResolve)