Fix #110255: Cover up CPU/GPU differences with small suns in light tree #110307

Merged
Weizhen Huang merged 5 commits from Alaska/blender:fix-small-sun-light-tree-sampling into main 2023-08-07 07:29:23 +02:00
1 changed files with 12 additions and 2 deletions

View File

@ -174,9 +174,19 @@ ccl_device void light_tree_importance(const float3 N_or_D,
cos_max_incidence_angle = fmaxf(cos_theta_i * cos_theta_u - sin_theta_i * sin_theta_u, 0.0f);
}
float cos_theta, sin_theta;
if (isequal(bcone.axis, -point_to_centroid)) {
/* When `bcone.axis == -point_to_centroid`, dot(bcone.axis, -point_to_centroid) doesn't always
* return 1 due to floating point precision issues. We account for that case here. */
cos_theta = 1.0f;
sin_theta = 0.0f;
}
else {
cos_theta = dot(bcone.axis, -point_to_centroid);
sin_theta = sin_from_cos(cos_theta);
}
/* cos(theta - theta_u) */
const float cos_theta = dot(bcone.axis, -point_to_centroid);
const float sin_theta = sin_from_cos(cos_theta);
const float cos_theta_minus_theta_u = cos_theta * cos_theta_u + sin_theta * sin_theta_u;
float cos_theta_o, sin_theta_o;