CultMath: cycles_power has no int-range quirk (Blender returns 1 for (-1)^(2^31)); math.json regenerated with the -1 base and Compare epsilon cases

The oracle showed Cycles treats a huge exponent as integral for a negative base, so the speculative
b >= 2^31 rule is gone. CultMath.Cycles.glsl is stale at this commit (the HLSL changed), so
CommittedGlslEqualsLowering fails here; the regenerated file follows. Builds.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-12 09:07:53 +02:00
commit 7d42eb3f20
4 changed files with 17 additions and 20 deletions

View file

@ -29,12 +29,11 @@ static const float CULTMATH_CYCLES_RGB_TO_Y_B = 0.0721927434;
float cultmath_cycles_divide(float a, float b) { return b != 0.0 ? a / b : 0.0; }
// safe_powf with compatible_powf. A negative base takes an integral exponent's parity; a base below zero
// with a fractional exponent is 0, and so is one with an exponent past the int range, where Cycles' int
// round trip cannot hold it.
// with a fractional exponent is 0.
float cultmath_cycles_power(float a, float b)
{
float whole = b >= 0.0 ? floor(b) : ceil(b);
if (a < 0.0 && (b != whole || b >= 2147483648.0 || b < -2147483648.0))
if (a < 0.0 && b != whole)
return 0.0;
if (b == 0.0)
return 1.0;

View file

@ -35,13 +35,12 @@ public static partial class math
/// <summary>
/// Math node Power (safe_powf with compatible_powf): 0 for a negative base with a fractional exponent,
/// 1 for exponent 0, 0 for base 0. A negative base takes an integral exponent's parity. An exponent past
/// the int range counts as fractional for a negative base, where Cycles' int round trip cannot hold it.
/// 1 for exponent 0, 0 for base 0. A negative base takes an integral exponent's parity.
/// </summary>
public static float cycles_power(float a, float b)
{
var whole = b >= 0.0f ? floor(b) : ceil(b);
if (a < 0.0f && (b != whole || b >= 2147483648.0f || b < -2147483648.0f))
if (a < 0.0f && b != whole)
return 0.0f;
if (b == 0.0f)
return 1.0f;

View file

@ -2045,11 +2045,11 @@
"bfead630 4023964b -> 00000000",
"3f3625f4 bf389362 -> 3fa399b4",
"bfc39342 3f4e3656 -> 00000000",
"3ee9cffa 3f9b536e -> 3ec5c96a",
"c047aefe 405b5e94 -> 00000000",
"4005491a c030658d -> 3e07922a",
"3fa89cde 3fef888c -> 3fd6600e",
"c009b5b9 3f0911d7 -> 00000000",
"bf800000 4b7fffff -> bf800000",
"bf800000 4b800000 -> 3f800000",
"bf800000 4f000000 -> 3f800000",
"bf800000 cf32d05e -> 3f800000",
"bf800000 4f32d05e -> 3f800000",
"bfc00000 4b800000 -> 00000000",
"bfc00000 41880000 -> c47650b8",
"80000000 c0400000 -> 00000000",
@ -13388,12 +13388,12 @@
"4197881d 415f4c23 3ff1fa4a -> 00000000",
"40aaa0f2 419c5496 3f9ecc60 -> 00000000",
"3fd0950c 4188423c 3f98d6f9 -> 00000000",
"4164daea 41888195 3f8bc582 -> 00000000",
"c15a3a29 40800da4 3fba86d6 -> 00000000",
"c192dd18 c19799e9 3f09b118 -> 00000000",
"c1000553 c19917bf 3f82933e -> 00000000",
"bf72e3b6 41806ff9 3d1ea4fc -> 00000000",
"41764d5e c191a68f 3f6378b0 -> 00000000"
"00000000 3456bf95 33d6bf95 -> 00000000",
"40a00000 40a00000 00000000 -> 3f800000",
"00000000 33d6bf95 322bcc77 -> 3f800000",
"3f800000 3f800002 00000000 -> 00000000",
"3f800000 3f800001 00000000 -> 3f800000",
"00000000 33d6bf95 00000000 -> 3f800000"
]
},
{

View file

@ -29,12 +29,11 @@ static const float CULTMATH_CYCLES_RGB_TO_Y_B = 0.0721927434;
float cultmath_cycles_divide(float a, float b) { return b != 0.0 ? a / b : 0.0; }
// safe_powf with compatible_powf. A negative base takes an integral exponent's parity; a base below zero
// with a fractional exponent is 0, and so is one with an exponent past the int range, where Cycles' int
// round trip cannot hold it.
// with a fractional exponent is 0.
float cultmath_cycles_power(float a, float b)
{
float whole = b >= 0.0 ? floor(b) : ceil(b);
if (a < 0.0 && (b != whole || b >= 2147483648.0 || b < -2147483648.0))
if (a < 0.0 && b != whole)
return 0.0;
if (b == 0.0)
return 1.0;