[Bf-blender-cvs] [5b9a911c4b3] master: Fix T72583: Sun Beams node artifacts

Manuel Castilla noreply at git.blender.org
Fri Oct 15 23:20:18 CEST 2021


Commit: 5b9a911c4b3c888e80e314a987e34642eb317310
Author: Manuel Castilla
Date:   Fri Oct 15 20:01:30 2021 +0200
Branches: master
https://developer.blender.org/rB5b9a911c4b3c888e80e314a987e34642eb317310

Fix T72583: Sun Beams node artifacts

The artifacts are due to the loss of precision when doing some
calculations with float precision.

===================================================================

M	source/blender/compositor/operations/COM_SunBeamsOperation.cc

===================================================================

diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cc b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
index b673a1ac754..38e9599f7e6 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cc
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cc
@@ -127,9 +127,9 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
     buffer_to_sector(source, co[0], co[1], pu, pv);
 
     /* line angle */
-    float tan_phi = pv / pu;
-    float dr = sqrtf(tan_phi * tan_phi + 1.0f);
-    float cos_phi = 1.0f / dr;
+    double tan_phi = pv / (double)pu;
+    double dr = sqrt(tan_phi * tan_phi + 1.0);
+    double cos_phi = 1.0 / dr;
 
     /* clamp u range to avoid influence of pixels "behind" the source */
     float umin = max_ff(pu - cos_phi * dist_min, 0.0f);
@@ -143,7 +143,7 @@ template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
 
     sector_to_buffer(source, end, (int)ceilf(v), x, y);
 
-    falloff_factor = dist_max > dist_min ? dr / (float)(dist_max - dist_min) : 0.0f;
+    falloff_factor = dist_max > dist_min ? dr / (double)(dist_max - dist_min) : 0.0f;
 
     float *iter = input->get_buffer() + input->get_coords_offset(x, y);
     return iter;



More information about the Bf-blender-cvs mailing list