diff options
author | Charlie Jolly <mistajolly@gmail.com> | 2019-12-21 06:28:22 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2019-12-21 06:28:38 +0300 |
commit | c1242874c98be830a4bdf4db194d3a8001e4969b (patch) | |
tree | 489ace726d6c03b1f3cdb1bb8c78cbb98a8c037f | |
parent | 4d0a91d03d1cb5d4dc8ed87c8aa97d9da2193c1a (diff) |
Fix: NaN error in smoothminf function
-rw-r--r-- | intern/cycles/util/util_math.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index dc211d2ed4e..737c834e073 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -363,8 +363,13 @@ ccl_device_inline float pingpongf(float a, float b) ccl_device_inline float smoothminf(float a, float b, float k) { - float h = fmaxf(k - fabsf(a - b), 0.0f) / k; - return fminf(a, b) - h * h * h * k * (1.0f / 6.0f); + if (k != 0.0f) { + float h = fmaxf(k - fabsf(a - b), 0.0f) / k; + return fminf(a, b) - h * h * h * k * (1.0f / 6.0f); + } + else { + return fminf(a, b); + } } ccl_device_inline float signf(float f) |