Code cleanup / Cycles:
* Use M_2PI_F in more places and do multiplication instead of division in gradient texture.
This commit is contained in:
@@ -125,7 +125,7 @@ __device float3 sample_uniform_sphere(float u1, float u2)
|
||||
{
|
||||
float z = 1.0f - 2.0f*u1;
|
||||
float r = sqrtf(fmaxf(0.0f, 1.0f - z*z));
|
||||
float phi = 2.0f*M_PI_F*u2;
|
||||
float phi = M_2PI_F*u2;
|
||||
float x = r*cosf(phi);
|
||||
float y = r*sinf(phi);
|
||||
|
||||
|
@@ -45,10 +45,10 @@ float gradient(point p, string type)
|
||||
result = (3.0 * t - 2.0 * t * r);
|
||||
}
|
||||
else if (type == "Diagonal") {
|
||||
result = (x + y) / 2.0;
|
||||
result = (x + y) * 0.5;
|
||||
}
|
||||
else if (type == "Radial") {
|
||||
result = atan2(y, x) / (2.0 * M_PI) + 0.5;
|
||||
result = atan2(y, x) / M_2PI + 0.5;
|
||||
}
|
||||
else {
|
||||
float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0);
|
||||
|
@@ -42,7 +42,7 @@ __device float svm_gradient(float3 p, NodeGradientType type)
|
||||
return (3.0f*t - 2.0f*t*r);
|
||||
}
|
||||
else if(type == NODE_BLEND_DIAGONAL) {
|
||||
return (x + y)/2.0f;
|
||||
return (x + y) * 0.5f;
|
||||
}
|
||||
else if(type == NODE_BLEND_RADIAL) {
|
||||
return atan2f(y, x) / M_2PI_F + 0.5f;
|
||||
|
Reference in New Issue
Block a user