forked from bartvdbraak/blender
Fix #33267: cycles math node power gave different results for CPU and GPU. The
GPU variants do not support pow(-1, 2), it doesn't check for even exponents, do manually now.
This commit is contained in:
parent
bb7fdc7935
commit
2a9b5e8f81
@ -300,7 +300,7 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
|
||||
horizontal_fit = true;
|
||||
sensor_size = bcam->sensor_width;
|
||||
}
|
||||
else if(bcam->sensor_fit == BlenderCamera::VERTICAL) {
|
||||
else { /* vertical */
|
||||
horizontal_fit = false;
|
||||
sensor_size = bcam->sensor_height;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ __device void svm_node_hsv(KernelGlobals *kg, ShaderData *sd, float *stack, uint
|
||||
|
||||
color = rgb_to_hsv(color);
|
||||
|
||||
// remember: fmod doesn't work for negative numbers
|
||||
/* remember: fmod doesn't work for negative numbers here */
|
||||
color.x += hue + 0.5f;
|
||||
color.x = fmod(color.x, 1.0f);
|
||||
color.y *= sat;
|
||||
|
@ -38,6 +38,21 @@ __device float safe_acosf(float a)
|
||||
return acosf(a);
|
||||
}
|
||||
|
||||
__device float compatible_powf(float x, float y)
|
||||
{
|
||||
/* GPU pow doesn't accept negative x, do manual checks here */
|
||||
if(x < 0.0f) {
|
||||
if(fmod(-y, 2.0f) == 0.0f)
|
||||
return powf(-x, y);
|
||||
else
|
||||
return -powf(-x, y);
|
||||
}
|
||||
else if(x == 0.0f)
|
||||
return 0.0f;
|
||||
|
||||
return powf(x, y);
|
||||
}
|
||||
|
||||
__device float safe_powf(float a, float b)
|
||||
{
|
||||
if(b == 0.0f)
|
||||
@ -47,7 +62,7 @@ __device float safe_powf(float a, float b)
|
||||
if(a < 0.0f && b != (int)b)
|
||||
return 0.0f;
|
||||
|
||||
return powf(a, b);
|
||||
return compatible_powf(a, b);
|
||||
}
|
||||
|
||||
__device float safe_logf(float a, float b)
|
||||
|
Loading…
Reference in New Issue
Block a user