Cycles Denoising: Speedup reconstruction by skipping near-zero weights
authorLukas Stockner <lukas.stockner@freenet.de>
Fri, 9 Jun 2017 20:27:49 +0000 (22:27 +0200)
committerLukas Stockner <lukas.stockner@freenet.de>
Fri, 9 Jun 2017 20:38:16 +0000 (22:38 +0200)
intern/cycles/kernel/filter/filter_nlm_cpu.h
intern/cycles/kernel/filter/filter_nlm_gpu.h
intern/cycles/kernel/filter/filter_reconstruction.h

index 88afc00ccb32f7636c97ab66e82f19a4bdd870eb..3e752bce68f01afd5bae510ad0a0b707aaee517c 100644 (file)
@@ -101,7 +101,7 @@ ccl_device_inline void kernel_filter_nlm_calc_weight(const float *ccl_restrict d
                for(int x = rect.x; x < rect.z; x++) {
                        const int low = max(rect.x, x-f);
                        const int high = min(rect.z, x+f+1);
-                       out_image[y*w+x] = expf(-max(out_image[y*w+x] * (1.0f/(high - low)), 0.0f));
+                       out_image[y*w+x] = fast_expf(-max(out_image[y*w+x] * (1.0f/(high - low)), 0.0f));
                }
        }
 }
index 62bd5be1de5b56f637e7c79d336cb7482611e049..2c5ac8070513f231ea50c26cfea3c6650c3de9cf 100644 (file)
@@ -66,7 +66,7 @@ ccl_device_inline void kernel_filter_nlm_calc_weight(int x, int y,
                sum += difference_image[y*w+x1];
        }
        sum *= 1.0f/(high-low);
-       out_image[y*w+x] = expf(-max(sum, 0.0f));
+       out_image[y*w+x] = fast_expf(-max(sum, 0.0f));
 }
 
 ccl_device_inline void kernel_filter_nlm_update_output(int x, int y,
index 90a2816ddf78b3b054b23d8eefc04241e1f6827d..538d57d3dc9aced961fec16b73559ffd0e9a8401 100644 (file)
@@ -29,6 +29,10 @@ ccl_device_inline void kernel_filter_construct_gramian(int x, int y,
                                                        ccl_global float3 *XtWY,
                                                        int localIdx)
 {
+       if(weight < 1e-3f) {
+               return;
+       }
+
        int p_offset =  y    *w +  x;
        int q_offset = (y+dy)*w + (x+dx);