From 5b9a911c4b3c888e80e314a987e34642eb317310 Mon Sep 17 00:00:00 2001 From: Manuel Castilla Date: Fri, 15 Oct 2021 20:01:30 +0200 Subject: Fix T72583: Sun Beams node artifacts The artifacts are due to the loss of precision when doing some calculations with float precision. --- source/blender/compositor/operations/COM_SunBeamsOperation.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender') 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 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 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; -- cgit v1.2.3