Commit: 2eea3d1d29995aa7134a6002ada05806f822ee09 Author: Lukas Stockner Date: Thu Apr 13 00:00:22 2017 +0200 Branches: temp-cycles-denoising https://developer.blender.org/rB2eea3d1d29995aa7134a6002ada05806f822ee09
Cycles Denoising: Add back the feature strength option Note: The control is now different, reusing old values might give surprising results =================================================================== M intern/cycles/blender/addon/ui.py M intern/cycles/blender/blender_session.cpp M intern/cycles/device/device_cpu.cpp M intern/cycles/device/device_cuda.cpp M intern/cycles/device/device_denoising.cpp M intern/cycles/device/device_denoising.h M intern/cycles/device/device_task.h M intern/cycles/device/opencl/opencl_base.cpp M intern/cycles/filter/filter_transform.h M intern/cycles/filter/filter_transform_gpu.h M intern/cycles/filter/filter_transform_sse.h M intern/cycles/filter/kernels/cpu/filter_cpu.h M intern/cycles/filter/kernels/cpu/filter_cpu_impl.h M intern/cycles/filter/kernels/cuda/filter.cu M intern/cycles/filter/kernels/opencl/filter.cl M intern/cycles/render/session.cpp M intern/cycles/render/session.h M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_scene.c =================================================================== diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index b8ff195d4a9..8dd3126f3a0 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -598,6 +598,7 @@ class CyclesRender_PT_denoising(CyclesButtonsPanel, Panel): sub = col.column(align=True) sub.prop(rl, "denoising_radius") sub.prop(rl, "denoising_strength", slider=True) + sub.prop(rl, "denoising_feature_strength", slider=True) sub.prop(rl, "denoising_relative_pca") sub = col.column(align=True) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index c3ce0ea7e34..3ed005a2919 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -520,7 +520,12 @@ void BlenderSession::render() buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass; session->params.denoising_radius = b_layer_iter->denoising_radius(); session->params.denoising_k2 = powf(2.0f, b_layer_iter->denoising_strength() - 1.0f); - session->params.denoising_relative_pca = b_layer_iter->denoising_relative_pca(); + if(b_layer_iter->denoising_relative_pca()) { + session->params.denoising_pca = -powf(10.0f, b_layer_iter->denoising_feature_strength() - 4.0f); + } + else { + session->params.denoising_pca = powf(10.0f, b_layer_iter->denoising_feature_strength() - 1.0f); + } scene->film->pass_alpha_threshold = b_layer_iter->pass_alpha_threshold(); scene->film->tag_passes_update(scene, passes); diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index e12bbd62eea..12f95f65af0 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -185,7 +185,7 @@ public: KernelFunctions<void(*)(int, int, float*, float*, float*, float*, int*, int, int)> filter_nlm_update_output_kernel; KernelFunctions<void(*)(float*, float*, int*, int)> filter_nlm_normalize_kernel; - KernelFunctions<void(*)(int, float*, int, int, int, float*, int*, int*, int, int, bool)> filter_construct_transform_kernel; + KernelFunctions<void(*)(int, float*, int, int, int, float*, int*, int*, int, int, float)> filter_construct_transform_kernel; KernelFunctions<void(*)(int, int, float*, float*, float*, float*, float*, int*, float*, float3*, int*, int*, int, int, int, int)> filter_nlm_construct_gramian_kernel; KernelFunctions<void(*)(int, int, int, int, int, float*, int*, float*, float3*, int*, int)> filter_finalize_kernel; @@ -456,7 +456,7 @@ public: &task->rect.x, task->buffer.pass_stride, task->radius, - task->relative_pca); + task->pca_threshold); } } return true; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 7aff8133783..1151302c49b 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1023,7 +1023,7 @@ public: &task->filter_area, &task->rect, &task->radius, - &task->relative_pca, + &task->pca_threshold, &task->buffer.pass_stride}; CUDA_LAUNCH_KERNEL(cuFilterConstructTransform, args); cuda_assert(cuCtxSynchronize()); diff --git a/intern/cycles/device/device_denoising.cpp b/intern/cycles/device/device_denoising.cpp index ae880f08f14..4b6a0097604 100644 --- a/intern/cycles/device/device_denoising.cpp +++ b/intern/cycles/device/device_denoising.cpp @@ -24,7 +24,7 @@ void DenoisingTask::init_from_devicetask(const DeviceTask &task) { radius = task.denoising_radius; nlm_k_2 = task.denoising_k2; - relative_pca = task.denoising_relative_pca; + pca_threshold = task.denoising_pca; render_buffer.pass_stride = task.pass_stride; render_buffer.denoising_data_offset = task.pass_denoising_data; diff --git a/intern/cycles/device/device_denoising.h b/intern/cycles/device/device_denoising.h index 3dbc03b7861..090e3be70b5 100644 --- a/intern/cycles/device/device_denoising.h +++ b/intern/cycles/device/device_denoising.h @@ -30,7 +30,7 @@ public: /* Parameters of the denoising algorithm. */ int radius; float nlm_k_2; - bool relative_pca; + float pca_threshold; bool use_split_variance; /* Pointer and parameters of the RenderBuffers. */ diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index b7e8a50f790..0766ae3d281 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -70,7 +70,7 @@ public: int denoising_radius; float denoising_k2; - bool denoising_relative_pca; + float denoising_pca; int pass_stride; int pass_denoising_data; int pass_denoising_clean; diff --git a/intern/cycles/device/opencl/opencl_base.cpp b/intern/cycles/device/opencl/opencl_base.cpp index 112c09753fb..9580e4b1245 100644 --- a/intern/cycles/device/opencl/opencl_base.cpp +++ b/intern/cycles/device/opencl/opencl_base.cpp @@ -667,7 +667,6 @@ bool OpenCLDeviceBase::denoising_construct_transform(DenoisingTask *task) cl_kernel ckFilterConstructTransform = denoising_program(ustring("filter_construct_transform")); - int relative_pca = task->relative_pca; kernel_set_args(ckFilterConstructTransform, 0, task->render_buffer.samples, buffer_mem, @@ -677,7 +676,7 @@ bool OpenCLDeviceBase::denoising_construct_transform(DenoisingTask *task) task->rect, task->buffer.pass_stride, task->radius, - relative_pca); + task->pca_threshold); enqueue_kernel(ckFilterConstructTransform, task->storage.w, diff --git a/intern/cycles/filter/filter_transform.h b/intern/cycles/filter/filter_transform.h index 7e2504612e7..143a89a1708 100644 --- a/intern/cycles/filter/filter_transform.h +++ b/intern/cycles/filter/filter_transform.h @@ -20,7 +20,7 @@ ccl_device void kernel_filter_construct_transform(int sample, float ccl_readonly int x, int y, int4 rect, int pass_stride, float *transform, int *rank, - int radius, bool relative_pca) + int radius, float pca_threshold) { int buffer_w = align_up(rect.z - rect.x, 4); @@ -80,12 +80,12 @@ ccl_device void kernel_filter_construct_transform(int sample, float ccl_readonly math_trimatrix_jacobi_eigendecomposition(feature_matrix, transform, DENOISE_FEATURES, 1); *rank = 0; - if(relative_pca) { + if(pca_threshold < 0.0f) { float threshold_energy = 0.0f; for(int i = 0; i < DENOISE_FEATURES; i++) { threshold_energy += feature_matrix[i*DENOISE_FEATURES+i]; } - threshold_energy *= 0.999f; + threshold_energy *= 1.0f - (-pca_threshold); float reduced_energy = 0.0f; for(int i = 0; i < DENOISE_FEATURES; i++, (*rank)++) { @@ -100,7 +100,7 @@ ccl_device void kernel_filter_construct_transform(int sample, float ccl_readonly else { for(int i = 0; i < DENOISE_FEATURES; i++, (*rank)++) { float s = feature_matrix[i*DENOISE_FEATURES+i]; - if(i >= 2 && sqrtf(s) < 1.0f) + if(i >= 2 && sqrtf(s) < pca_threshold) break; /* Bake the feature scaling into the transformation matrix. */ math_vector_mul(transform + (*rank)*DENOISE_FEATURES, feature_scale, DENOISE_FEATURES); diff --git a/intern/cycles/filter/filter_transform_gpu.h b/intern/cycles/filter/filter_transform_gpu.h index 74810e63945..9069f79534e 100644 --- a/intern/cycles/filter/filter_transform_gpu.h +++ b/intern/cycles/filter/filter_transform_gpu.h @@ -22,7 +22,7 @@ ccl_device void kernel_filter_construct_transform(int sample, int pass_stride, ccl_global float *transform, ccl_global int *rank, - int radius, bool relative_pca, + int radius, float pca_threshold, int transform_stride, int localIdx) { int buffer_w = align_up(rect.z - rect.x, 4); @@ -78,12 +78,12 @@ ccl_device void kernel_filter_construct_transform(int sample, math_trimatrix_jacobi_eigendecomposition(feature_matrix, transform, DENOISE_FEATURES, transform_stride); *rank = 0; - if(relative_pca) { + if(pca_threshold < 0.0f) { float threshold_energy = 0.0f; for(int i = 0; i < DENOISE_FEATURES; i++) { threshold_energy += feature_matrix[i*DENOISE_FEATURES+i]; } - threshold_energy *= 0.999f; + threshold_energy *= 1.0f - (-pca_threshold); float reduced_energy = 0.0f; for(int i = 0; i < DENOISE_FEATURES; i++, (*rank)++) { @@ -98,7 +98,7 @@ ccl_device void kernel_filter_construct_transform(int sample, else { for(int i = 0; i < DENOISE_FEATURES; i++, (*rank)++) { float s = feature_matrix[i*DENOISE_FEATURES+i]; - if(i >= 2 && sqrtf(s) < 1.0f) + if(i >= 2 && sqrtf(s) < pca_threshold) break; /* Bake the feature scaling into the transformation matrix. */ math_vector_mul_strided(transform + i*DENOISE_FEATURES*transform_stride, feature_scale, transform_stride, DENOISE_FEATURES); diff --git a/intern/cycles/filter/filter_transform_sse.h b/intern/cycles/filter/filter_transform_sse.h index 5c4074ee3b8..2be5a3cf116 100644 --- a/intern/cycles/filter/filter_transform_sse.h +++ b/intern/cycles/filter/filter_transform_sse.h @@ -20,7 +20,7 @@ ccl_device void kernel_filter_construct_transform(int sample, float ccl_readonly int x, int y, int4 rect, int pass_s @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs