[Bf-blender-cvs] [58a0c275464] master: Cycles: Fix occasional black pixels from denoising with excessive radii

Lukas Stockner noreply at git.blender.org
Thu May 11 03:22:26 CEST 2017


Commit: 58a0c275464605ccff18a56c4d82b619df069e91
Author: Lukas Stockner
Date:   Mon May 8 22:09:35 2017 +0200
Branches: master
https://developer.blender.org/rB58a0c275464605ccff18a56c4d82b619df069e91

Cycles: Fix occasional black pixels from denoising with excessive radii

Numerical inaccuracies would cause the XtWX matrix to be no longer
positive-semidefinite, which in turn caused the LSQ solver to fail.

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/kernel/kernel_passes.h
M	intern/cycles/util/util_math_matrix.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 70f704894bb..51b53a43d0b 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1255,7 +1255,7 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
         cls.denoising_radius = IntProperty(
                 name="Denoising Radius",
                 description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
-                min=1, max=50,
+                min=1, max=25,
                 default=8,
         )
         cls.denoising_relative_pca = BoolProperty(
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index 8ab4c724829..c694e60ce14 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -364,7 +364,7 @@ ccl_device_inline void kernel_write_result(KernelGlobals *kg, ccl_global float *
 			}
 			else {
 				kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_COLOR,
-				                                  sample, L_sum);
+				                                  sample, ensure_finite3(L_sum));
 			}
 
 			kernel_write_pass_float3_variance(buffer + kernel_data.film.pass_denoising_data + DENOISING_PASS_NORMAL,
diff --git a/intern/cycles/util/util_math_matrix.h b/intern/cycles/util/util_math_matrix.h
index 31ea10f18a8..2172e94a14f 100644
--- a/intern/cycles/util/util_math_matrix.h
+++ b/intern/cycles/util/util_math_matrix.h
@@ -176,7 +176,10 @@ ccl_device void math_trimatrix_cholesky(ccl_global float *A, int n, int stride)
  * symmetrical positive-semidefinite by construction, so we can just use this function with A=Xt*W*X and y=Xt*W*y. */
 ccl_device_inline void math_trimatrix_vec3_solve(ccl_global float *A, ccl_global float3 *y, int n, int stride)
 {
-	math_trimatrix_add_diagonal(A, n, 1e-4f, stride); /* Improve the numerical stability. */
+	/* Since the first entry of the design row is always 1, the upper-left element of XtWX is a good
+	 * heuristic for the amount of pixels considered (with weighting), therefore the amount of correction
+	 * is scaled based on it. */
+	math_trimatrix_add_diagonal(A, n, 3e-7f*A[0], stride); /* Improve the numerical stability. */
 	math_trimatrix_cholesky(A, n, stride); /* Replace A with L so that L*Lt = A. */
 
 	/* Use forward substitution to solve L*b = y, replacing y by b. */




More information about the Bf-blender-cvs mailing list