diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-08 03:10:02 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-08 03:15:37 +0300 |
commit | 7fcb6bc59c85beab36dbfcec91d0cfaf5291f029 (patch) | |
tree | 0e7c93521d34efd2ba43ea8847dc2661effa34c3 /intern/cycles/kernel/svm | |
parent | afcb41a0aaafce5b99891487a402d78a337f3809 (diff) |
Fix T78324: Different Sky Texture results between CPU and GPU
The problem here was numerical precision: The code calculates the angle between
sun and view direction, and the usual acos(dot(a, b)) approach for that has
poor numerical performance for almost parallel angles.
As a result, the generally tiny difference between floating point computation
between CPU and GPU was enough to make the sun vanish at different radii,
causing different results.
The new version fixes the difference by making the computation much more robust
on both platforms.
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r-- | intern/cycles/kernel/svm/svm_sky.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index e877bd9a5c8..214c0cd1a9a 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -145,7 +145,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, if (dir.z >= 0.0f) { /* definitions */ float3 sun_dir = geographical_to_direction(sun_elevation, sun_rotation + M_PI_2_F); - float sun_dir_angle = acos(dot(dir, sun_dir)); + float sun_dir_angle = precise_angle(dir, sun_dir); float half_angular = angular_diameter / 2.0f; float dir_elevation = M_PI_2_F - direction.x; |