diff options
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 1 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_cuda.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_denoising.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_denoising.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_task.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/opencl/opencl_base.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/filter/filter_transform.h | 8 | ||||
-rw-r--r-- | intern/cycles/filter/filter_transform_gpu.h | 8 | ||||
-rw-r--r-- | intern/cycles/filter/filter_transform_sse.h | 8 | ||||
-rw-r--r-- | intern/cycles/filter/kernels/cpu/filter_cpu.h | 2 | ||||
-rw-r--r-- | intern/cycles/filter/kernels/cpu/filter_cpu_impl.h | 4 | ||||
-rw-r--r-- | intern/cycles/filter/kernels/cuda/filter.cu | 4 | ||||
-rw-r--r-- | intern/cycles/filter/kernels/opencl/filter.cl | 4 | ||||
-rw-r--r-- | intern/cycles/render/session.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/session.h | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 6 |
19 files changed, 45 insertions, 34 deletions
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_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); @@ -69,12 +69,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)++) { @@ -91,7 +91,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. */ for(int j = 0; j < DENOISE_FEATURES; j++) { diff --git a/intern/cycles/filter/kernels/cpu/filter_cpu.h b/intern/cycles/filter/kernels/cpu/filter_cpu.h index 74e6e107532..201b377f1d7 100644 --- a/intern/cycles/filter/kernels/cpu/filter_cpu.h +++ b/intern/cycles/filter/kernels/cpu/filter_cpu.h @@ -61,7 +61,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_construct_transform)(int sample, int* rect, int pass_stride, int radius, - bool relative_pca); + float pca_threshold); void KERNEL_FUNCTION_FULL_NAME(filter_divide_combined)(int x, int y, int sample, diff --git a/intern/cycles/filter/kernels/cpu/filter_cpu_impl.h b/intern/cycles/filter/kernels/cpu/filter_cpu_impl.h index 0d87771c1ae..f79fc3a66b0 100644 --- a/intern/cycles/filter/kernels/cpu/filter_cpu_impl.h +++ b/intern/cycles/filter/kernels/cpu/filter_cpu_impl.h @@ -116,7 +116,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_construct_transform)(int sample, int* prefilter_rect, int pass_stride, int radius, - bool relative_pca) + float pca_threshold) { #ifdef KERNEL_STUB STUB_ASSERT(KERNEL_ARCH, filter_construct_transform); @@ -130,7 +130,7 @@ void KERNEL_FUNCTION_FULL_NAME(filter_construct_transform)(int sample, transform, rank, radius, - relative_pca); + pca_threshold); #endif } diff --git a/intern/cycles/filter/kernels/cuda/filter.cu b/intern/cycles/filter/kernels/cuda/filter.cu index 0fc6eef067a..b06215b69bd 100644 --- a/intern/cycles/filter/kernels/cuda/filter.cu +++ b/intern/cycles/filter/kernels/cuda/filter.cu @@ -102,7 +102,7 @@ CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) kernel_cuda_filter_construct_transform(int sample, float const* __restrict__ buffer, float *transform, int *rank, int4 filter_area, int4 rect, - int radius, bool relative_pca, + int radius, float pca_threshold, int pass_stride) { int x = blockDim.x*blockIdx.x + threadIdx.x; @@ -114,7 +114,7 @@ kernel_cuda_filter_construct_transform(int sample, float const* __restrict__ buf x + filter_area.x, y + filter_area.y, rect, pass_stride, l_transform, l_rank, - radius, relative_pca, + radius, pca_threshold, filter_area.z*filter_area.w, threadIdx.y*blockDim.x + threadIdx.x); } diff --git a/intern/cycles/filter/kernels/opencl/filter.cl b/intern/cycles/filter/kernels/opencl/filter.cl index e71c88fd54b..d91f9dad84d 100644 --- a/intern/cycles/filter/kernels/opencl/filter.cl +++ b/intern/cycles/filter/kernels/opencl/filter.cl @@ -100,7 +100,7 @@ __kernel void kernel_ocl_filter_construct_transform(int sample, int4 rect, int pass_stride, int radius, - int relative_pca) + float pca_threshold) { int x = get_global_id(0); int y = get_global_id(1); @@ -111,7 +111,7 @@ __kernel void kernel_ocl_filter_construct_transform(int sample, x + filter_area.x, y + filter_area.y, rect, pass_stride, l_transform, l_rank, - radius, relative_pca, + radius, pca_threshold, filter_area.z*filter_area.w, get_local_id(1)*get_local_size(0) + get_local_id(0)); } diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index b5e4328db29..621c330f663 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -978,7 +978,7 @@ void Session::render() if(params.use_denoising) { task.denoising_radius = params.denoising_radius; task.denoising_k2 = params.denoising_k2; - task.denoising_relative_pca = params.denoising_relative_pca; + task.denoising_pca = params.denoising_pca; assert(!scene->film->need_update); task.pass_stride = scene->film->pass_stride; diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h index a98300fdd67..f480d6ea884 100644 --- a/intern/cycles/render/session.h +++ b/intern/cycles/render/session.h @@ -60,7 +60,7 @@ public: bool use_denoising; int denoising_radius; float denoising_k2; - bool denoising_relative_pca; + float denoising_pca; double cancel_timeout; double reset_timeout; @@ -89,7 +89,7 @@ public: denoising_radius = 8; denoising_k2 = 0.5f; - denoising_relative_pca = false; + denoising_pca = false; cancel_timeout = 0.1; reset_timeout = 0.1; @@ -114,7 +114,7 @@ public: && use_denoising == params.use_denoising && denoising_radius == params.denoising_radius && denoising_k2 == params.denoising_k2 - && denoising_relative_pca == params.denoising_relative_pca + && denoising_pca == params.denoising_pca && display_buffer_linear == params.display_buffer_linear && cancel_timeout == params.cancel_timeout && reset_timeout == params.reset_timeout diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c3e78993d15..47df1f9fbde 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -230,11 +230,11 @@ typedef struct SceneRenderLayer { int denoising_flag; int denoising_radius; float denoising_weighting; + float denoising_feature_strength; int samples; float pass_alpha_threshold; - - int pad; + struct FreestyleConfig freestyleConfig; } SceneRenderLayer; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a14db6c122a..b281a19958f 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -5141,6 +5141,12 @@ static void rna_def_scene_render_layer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Denoising Strength Adjust", "Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "denoising_feature_strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "denoising_feature_strength"); + RNA_def_property_range(prop, -4.0f, 4.0f); + RNA_def_property_ui_text(prop, "Denoising Feature Strength Adjust", "Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + prop = RNA_def_property(srna, "denoising_radius", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "denoising_radius"); RNA_def_property_range(prop, 1, 50); |