From eef4dadc22bf41b9dec81f7c96f3751db9488da0 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sat, 28 Nov 2026 23:35:22 +0100 Subject: [PATCH] Inner Glow noise: keep the shared law for Source Center and Precise (#14926) Only Softer with Source Edge was measured. The issue's rules keep today's behaviour for unmeasured cases, so the square root now applies to that case alone. --- .../src/effects/inner_glow_noise_tests.rs | 17 +++++++++++++++++ crates/compose/src/effects/paint.rs | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/compose/src/effects/inner_glow_noise_tests.rs b/crates/compose/src/effects/inner_glow_noise_tests.rs index 9931915d15..ab316449c1 100644 --- a/crates/compose/src/effects/inner_glow_noise_tests.rs +++ b/crates/compose/src/effects/inner_glow_noise_tests.rs @@ -139,3 +139,20 @@ fn bit_hash(m: &Map) -> u64 { fn noise_zero_maps_stay_bit_identical() { assert_eq!(bit_hash(&map(0.0)), 0xefad_fffb_8195_d0b9, "the Noise 0 inner glow map moved"); } + +/// The Centre source and the Precise technique were not measured, so they keep the shared law at every Noise: only +/// the measured Softer, Edge-sourced Inner Glow gets the stronger mid-Noise scatter. +#[test] +fn unmeasured_centre_and_precise_inner_glows_keep_the_shared_law() { + let shape = document_shape(); + let centre = |noise| Glow { source: GlowSource::Center, ..glow(noise) }; + let precise = |noise| Glow { technique: GlowTechnique::Precise, ..glow(noise) }; + let precise_centre = |noise| Glow { technique: GlowTechnique::Precise, source: GlowSource::Center, ..glow(noise) }; + for (name, make) in [("Centre", ¢re as &dyn Fn(f32) -> Glow), ("Precise", &precise), ("Precise Centre", &precise_centre)] { + for amount in [0.25f32, 0.5] { + let mut by_law = glow_map(&shape, &make(0.0), true, (0, 0)); + noise(&mut by_law, amount, 0, 0); + assert_eq!(glow_map(&shape, &make(amount), true, (0, 0)).v, by_law.v, "{name}, Noise {amount}: left the shared law"); + } + } +} diff --git a/crates/compose/src/effects/paint.rs b/crates/compose/src/effects/paint.rs index 726217b8cc..77b90c03ab 100644 --- a/crates/compose/src/effects/paint.rs +++ b/crates/compose/src/effects/paint.rs @@ -572,7 +572,9 @@ pub(super) fn glow_map(shape: &Map, g: &Glow, inner: bool, origin: (i32, i32)) - // #14926: an Inner Glow scatters harder at mid Noise than the shared law gives (measured // band: Noise 50 leaves 343 of 1620 px without glow, Noise 100 490). The square root keeps // Noise 0 and Noise 100 where they are and lifts Noise 50 to the law's 0.71 (about 340 px). - let amount = if inner && g.noise > 0.0 { g.noise.sqrt() } else { g.noise }; + // Only the measured Softer, Edge-sourced case; Centre and Precise keep the shared law. + let measured = inner && g.technique == GlowTechnique::Softer && g.source == GlowSource::Edge; + let amount = if measured && g.noise > 0.0 { g.noise.sqrt() } else { g.noise }; noise(&mut m, amount, origin.0, origin.1); if inner { for (v, a) in m.v.iter_mut().zip(&shape.v) {