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
parent e704d8a616
commit e50ed90e4d
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;