Fix T53348: Cycles difference between gradient texture on CPU and GPU.

This commit is contained in:
Brecht Van Lommel 2017-11-23 16:10:38 +01:00 committed by Bastien Montagne
parent f968268c1e
commit 198fd0be43
2 changed files with 8 additions and 2 deletions

View File

@ -46,7 +46,10 @@ ccl_device float svm_gradient(float3 p, NodeGradientType type)
return atan2f(y, x) / M_2PI_F + 0.5f;
}
else {
float r = fmaxf(1.0f - sqrtf(x*x + y*y + z*z), 0.0f);
/* Bias a little bit for the case where p is a unit length vector,
* to get exactly zero instead of a small random value depending
* on float precision. */
float r = fmaxf(0.999999f - sqrtf(x*x + y*y + z*z), 0.0f);
if(type == NODE_BLEND_QUADRATIC_SPHERE)
return r*r;

View File

@ -2971,7 +2971,10 @@ float calc_gradient(vec3 p, int gradient_type)
return atan(y, x) / (M_PI * 2) + 0.5;
}
else {
float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
/* Bias a little bit for the case where p is a unit length vector,
* to get exactly zero instead of a small random value depending
* on float precision. */
float r = max(0.999999 - sqrt(x * x + y * y + z * z), 0.0);
if (gradient_type == 5) { /* quadratic sphere */
return r * r;
}