diff --git a/packages/cultmath/shaders/CultMath.Cycles.hlsl b/packages/cultmath/shaders/CultMath.Cycles.hlsl index f2449e08..829a27b3 100644 --- a/packages/cultmath/shaders/CultMath.Cycles.hlsl +++ b/packages/cultmath/shaders/CultMath.Cycles.hlsl @@ -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; diff --git a/packages/cultmath/src/CultMath/math.Cycles.cs b/packages/cultmath/src/CultMath/math.Cycles.cs index 3ebdb8f1..120d6f24 100644 --- a/packages/cultmath/src/CultMath/math.Cycles.cs +++ b/packages/cultmath/src/CultMath/math.Cycles.cs @@ -35,13 +35,12 @@ public static partial class math /// /// 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. /// 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; diff --git a/packages/cultmath/tests/CultMath.Tests/fixtures/cycles-oracle/math.json b/packages/cultmath/tests/CultMath.Tests/fixtures/cycles-oracle/math.json index 9b0f1a1c..8028a178 100644 --- a/packages/cultmath/tests/CultMath.Tests/fixtures/cycles-oracle/math.json +++ b/packages/cultmath/tests/CultMath.Tests/fixtures/cycles-oracle/math.json @@ -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" ] }, { diff --git a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Cycles.hlsl b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Cycles.hlsl index f2449e08..829a27b3 100644 --- a/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Cycles.hlsl +++ b/packages/cultmath/unity/org.gamecult.cultmath/Shaders/CultMath.Cycles.hlsl @@ -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;