Fix T95977: Point Info node radius wrong under rotation

This commit is contained in:
Brecht Van Lommel 2022-02-25 20:03:25 +01:00
parent e84b42bfcf
commit 4896e72a4d
Notes: blender-bot 2023-02-14 10:35:28 +01:00
Referenced by issue #95977, Point Info Node radius output wrongly affected by object rotation in the Cycles viewport
2 changed files with 6 additions and 2 deletions

View File

@ -141,9 +141,10 @@ ccl_device float point_radius(KernelGlobals kg, ccl_private const ShaderData *sd
return r;
}
else {
float3 dir = make_float3(r, r, r);
const float normalized_r = r * (1.0f / M_SQRT3_F);
float3 dir = make_float3(normalized_r, normalized_r, normalized_r);
object_dir_transform(kg, sd, &dir);
return average(dir);
return len(dir);
}
}

View File

@ -80,6 +80,9 @@ CCL_NAMESPACE_BEGIN
#ifndef M_SQRT2_F
# define M_SQRT2_F (1.4142135623730950f) /* sqrt(2) */
#endif
#ifndef M_SQRT3_F
# define M_SQRT3_F (1.7320508075688772f) /* sqrt(3) */
#endif
#ifndef M_LN2_F
# define M_LN2_F (0.6931471805599453f) /* ln(2) */
#endif