[Bf-blender-cvs] [2259c75] soc-2016-cycles_denoising: Cycles: Fix combined feature bandwidth calculation

Lukas Stockner noreply at git.blender.org
Sun Jul 24 03:46:05 CEST 2016


Commit: 2259c750646330ee7b85e31ef54f09706ea3206f
Author: Lukas Stockner
Date:   Sun Jul 24 02:13:38 2016 +0200
Branches: soc-2016-cycles_denoising
https://developer.blender.org/rB2259c750646330ee7b85e31ef54f09706ea3206f

Cycles: Fix combined feature bandwidth calculation

As explained in the code, the bandwidth variables actually store the inverse of the bandwidth
to save a couple of divides. However, if the bandwidth is to be multiplied with a factor, that means
that the variable must be divided by that factor, which was not done currently.

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

M	intern/cycles/kernel/kernel_filter.h

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

diff --git a/intern/cycles/kernel/kernel_filter.h b/intern/cycles/kernel/kernel_filter.h
index 01e5f76..90ea94b 100644
--- a/intern/cycles/kernel/kernel_filter.h
+++ b/intern/cycles/kernel/kernel_filter.h
@@ -215,7 +215,7 @@ ccl_device void kernel_filter_estimate_params(KernelGlobals *kg, int sample, flo
 
 	rank = 0;
 	for(int i = 0; i < DENOISE_FEATURES; i++, rank++) {
-		float s = sqrtf(singular[i]);
+		float s = sqrtf(fabsf(singular[i]));
 		if(i >= 2 && s < singular_threshold)
 			break;
 		/* Bake the feature scaling into the transformation matrix. */
@@ -288,7 +288,8 @@ ccl_device void kernel_filter_estimate_params(KernelGlobals *kg, int sample, flo
 	for(int g = 0; g < 6; g++) {
 		float g_bandwidth_factor[DENOISE_FEATURES];
 		for(int i = 0; i < rank; i++)
-			g_bandwidth_factor[i] = candidate_bw[g]*bandwidth_factor[i];
+			/* Divide by the candidate bandwidth since the bandwidth_factor actually is the inverse of the bandwidth. */
+			g_bandwidth_factor[i] = bandwidth_factor[i]/candidate_bw[g];
 
 		matrix_size = rank+1;
 		math_matrix_zero_lower(XtX, matrix_size);
@@ -436,7 +437,8 @@ ccl_device void kernel_filter_final_pass(KernelGlobals *kg, int sample, float **
 	/* === Calculate the final pixel color. === */
 	float XtX[(DENOISE_FEATURES+1)*(DENOISE_FEATURES+1)], design_row[DENOISE_FEATURES+1];
 	for(int i = 0; i < rank; i++)
-		bandwidth_factor[i] *= global_bandwidth;
+		/* Same as above, divide by the bandwidth since the bandwidth_factor actually is the inverse of the bandwidth. */
+		bandwidth_factor[i] /= global_bandwidth;
 
 	int matrix_size = rank+1;
 	math_matrix_zero_lower(XtX, matrix_size);




More information about the Bf-blender-cvs mailing list