Files
test/intern/cycles/kernel
Alaska 8e6a981487 Fix #131927: Cycles: Reduce uncertain light tree traversal in scenes with one distant light
When a scene contains distant lights and local lights, the first step
of the light tree traversal is to compute the importance of
distant lights vs local lights and pick one based on a random number.

In the specific case of when there is only one distant light,
the line of code that had been changed in this commit
effectively reduced to:
`min_importance = fast_cosf(x) < cosf(x) ? 0.0 : compute_min_importance`

And depending on the hardware, compiler, and the specific value being
tested, different configurations could take different code paths.

This commit fixes this issue by turning the comparison into
`fast_cosf(x) < fast_cosf(x)`.

---

Why does `cos_theta_plus_theta_u < cosf(bcone.theta_e - bcone.theta_o)`
reduce to `fast_cos(x) < cos(x)` in this specific case?

- `cos_theta_plus_theta_u` is computed as
`cos_theta * cos_theta_u - sin_theta * sin_theta_u`
- `cos_theta` is always 1.0 in the case of a single distant light.
- `cos_theta_u` is computed earlier as `fast_cosf(theta_e)` in
`distant_light_tree_parameters()`
- `sin_theta` is zero, and so that side of the equation doesn't matter.

This reduces `cos_theta_plus_theta_u` to `fast_cosf(theta_e)`.

`cosf(bcone.theta_e - bcone.theta_o)` reduces to `cosf(bcone.theta_e)`
because for the case of a single distant light `theta_o` is always 0.

Pull Request: https://projects.blender.org/blender/blender/pulls/131932
2024-12-17 10:51:43 +01:00
..
2023-11-27 10:55:39 +11:00