Delete cellular's unreachable F2=0 guard instead of leaving it undefended

Stryker (scoped to this cut's diff) survived two mutants on the grad2 ternary
in math.cellular: forcing the true branch unconditionally, and loosening
f2 > 0.0f to f2 >= 0.0f. Both are real findings about the code, not the
tests: F2 = 0 needs two distinct integer cells' pcg3d-jittered feature points
to land on the exact float32 value in every component, which the jitter's
~24-bit float precision makes unreachable for any p this function is
actually called with. The spec only asks for the degenerate guard at F1 = 0;
F2's copy of it was added for symmetry and had no reachable case to defend.

Deleted the guard (grad2 is now a bare (p - c2) / f2) in math.cs and both
HLSL mirrors, and corrected design.md's invariant-8 section, which had
overstated this as symmetric with F1's guard.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-25 19:47:36 +02:00
commit 1add078eea
4 changed files with 22 additions and 9 deletions

View file

@ -747,8 +747,12 @@ public static partial class math
}
}
// Only F1's degenerate point is guarded, matching the spec: F2 = 0 needs two distinct
// integer cells' pcg3d-jittered feature points to land on the exact same float32 value in
// every component, which the jitter's ~24-bit float precision makes unreachable for any p
// this function is actually called with, so there is no reachable case for a guard to defend.
var grad1 = f1 > 0.0f ? (p - c1) / f1 : new float3(0.0f, 0.0f, 0.0f);
var grad2 = f2 > 0.0f ? (p - c2) / f2 : new float3(0.0f, 0.0f, 0.0f);
var grad2 = (p - c2) / f2;
return new CultCellular(
new float4(grad1, f1),