forked from bartvdbraak/blender
Fix T53348: Cycles difference between gradient texture on CPU and GPU.
This commit is contained in:
parent
e704d8a616
commit
e50ed90e4d
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user