Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2017-05-08 23:09:35 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2017-05-11 04:21:54 +0300
commit58a0c275464605ccff18a56c4d82b619df069e91 (patch)
treefca5fe54a9de602fcd116c1b62e685915400d573 /intern/cycles/util/util_math_matrix.h
parentf4b7c33c1a7121c7bb20c2eeee9160bc4a270020 (diff)
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.
Diffstat (limited to 'intern/cycles/util/util_math_matrix.h')
-rw-r--r--intern/cycles/util/util_math_matrix.h5
1 files changed, 4 insertions, 1 deletions
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. */