From a8fe3a1ceef31ca39a455fee25bc1e361e1048ff Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Thu, 18 Feb 2016 01:13:07 +0100 Subject: Fix T47461: Different results on CPU and GPU when using Branched Path Tracing The issue here was actually somewhere else - the attached scene from the report used a light falloff node in a sunlamp (aka distant light). However, since distant lamps set the ray length to FLT_MAX and the light falloff node squares this value, it overflows and produces a NaN weight, which propagates and leads to a NaN intensity, which is then clamped to zero and produces the black pixels. To fix that issue, the smoothing part of the light falloff is just ignored if the smoothing term isn't finite (which makes sense since the term should converge to 1 as the distance increases). The reason for the different results on CPUs and GPUs is not perfectly clear, but probably can be explained with different handling of Inf/NaN edge cases. Also, to notice issues like these faster in the future, kernel_asserts were added that evaluate as false as soon as a non-finite intensity is produced. --- intern/cycles/kernel/kernel_accumulate.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'intern/cycles/kernel/kernel_accumulate.h') diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index 29eca865384..5f5a3609ded 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -378,6 +378,7 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi /* Reject invalid value */ if(!isfinite(sum)) { + kernel_assert(!"Non-finite sum in path_radiance_clamp_and_sum!"); L_sum = make_float3(0.0f, 0.0f, 0.0f); L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f); @@ -445,8 +446,10 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi /* Reject invalid value */ float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z); - if(!isfinite(sum)) + if(!isfinite(sum)) { + kernel_assert(!"Non-finite final sum in path_radiance_clamp_and_sum!"); L_sum = make_float3(0.0f, 0.0f, 0.0f); + } return L_sum; } -- cgit v1.2.3