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.
This commit is contained in:
qvest-ssels committed 2026-11-28 23:35:22 +01:00
1 parent 86f431d177
commit eef4dadc22
2 files changed
+20 -1

No files matched your search

@@ -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", &centre 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");
}
}
}
+3 -1
View File
@@ -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) {