[Cycles] Fix math problems in safe_logf
log(0) is undefined and should not have been included log(1) == 0, dividing by zero is not recommended
This commit is contained in:
parent
3cd27374ee
commit
c9451f1cff
Notes:
blender-bot
2023-12-08 16:39:08 +01:00
Referenced by issue #54275, Blender cycles volumetric shader bug Referenced by issue #51442, Compiling OpenCL program base: CL_DEVICE_NOT_AVAILABLE
|
@ -492,19 +492,19 @@ ccl_device float safe_powf(float a, float b)
|
|||
return compatible_powf(a, b);
|
||||
}
|
||||
|
||||
ccl_device float safe_logf(float a, float b)
|
||||
{
|
||||
if(UNLIKELY(a < 0.0f || b < 0.0f))
|
||||
return 0.0f;
|
||||
|
||||
return logf(a)/logf(b);
|
||||
}
|
||||
|
||||
ccl_device float safe_divide(float a, float b)
|
||||
{
|
||||
return (b != 0.0f)? a/b: 0.0f;
|
||||
}
|
||||
|
||||
ccl_device float safe_logf(float a, float b)
|
||||
{
|
||||
if(UNLIKELY(a <= 0.0f || b <= 0.0f))
|
||||
return 0.0f;
|
||||
|
||||
return safe_divide(logf(a),logf(b));
|
||||
}
|
||||
|
||||
ccl_device float safe_modulo(float a, float b)
|
||||
{
|
||||
return (b != 0.0f)? fmodf(a, b): 0.0f;
|
||||
|
|
Loading…
Reference in New Issue