diff options
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 38 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 63 |
4 files changed, 125 insertions, 0 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 023841a7a17..d15accface4 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -543,6 +543,44 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel): row.prop(rv, "camera_suffix", text="") +class CyclesRender_PT_denoising(CyclesButtonsPanel, Panel): + bl_label = "Denoising" + bl_context = "render_layer" + bl_options = {'DEFAULT_CLOSED'} + + def draw_header(self, context): + rd = context.scene.render + rl = rd.layers.active + self.layout.prop(rl, "denoise_result", text="") + + def draw(self, context): + layout = self.layout + + scene = context.scene + rd = scene.render + rl = rd.layers.active + + col = layout.column() + + col.prop(rl, "keep_denoise_data") + + sub = col.column(align=True) + sub.prop(rl, "half_window") + sub.prop(rl, "filter_strength", slider=True) + + sub = col.column(align=True) + row = sub.row(align=True) + row.prop(rl, "denoise_diffuse_direct", toggle=True) + row.prop(rl, "denoise_glossy_direct", toggle=True) + row.prop(rl, "denoise_transmission_direct", toggle=True) + row.prop(rl, "denoise_subsurface_direct", toggle=True) + row = sub.row(align=True) + row.prop(rl, "denoise_diffuse_indirect", toggle=True) + row.prop(rl, "denoise_glossy_indirect", toggle=True) + row.prop(rl, "denoise_transmission_indirect", toggle=True) + row.prop(rl, "denoise_subsurface_indirect", toggle=True) + + class Cycles_PT_post_processing(CyclesButtonsPanel, Panel): bl_label = "Post Processing" bl_options = {'DEFAULT_CLOSED'} diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 14f6e362ca7..842d08215e7 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -493,10 +493,16 @@ void BlenderSession::render() } buffer_params.passes = passes; + buffer_params.denoising_passes = b_layer_iter->keep_denoise_data() || b_layer_iter->denoise_result(); + buffer_params.selective_denoising = !(b_layer_iter->denoise_diffuse_direct() && b_layer_iter->denoise_glossy_direct() && b_layer_iter->denoise_transmission_direct() && b_layer_iter->denoise_subsurface_direct() && + b_layer_iter->denoise_diffuse_indirect() && b_layer_iter->denoise_glossy_indirect() && b_layer_iter->denoise_transmission_indirect() && b_layer_iter->denoise_subsurface_indirect()); + scene->film->denoising_passes = buffer_params.denoising_passes; + scene->film->selective_denoising = buffer_params.selective_denoising; scene->film->pass_alpha_threshold = b_layer_iter->pass_alpha_threshold(); scene->film->tag_passes_update(scene, passes); scene->film->tag_update(scene); scene->integrator->tag_update(scene); + session->tile_manager.denoise = b_layer_iter->denoise_result(); for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) { b_rview_name = b_view_iter->name(); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 39508e17be5..d7a949d6559 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -190,6 +190,11 @@ typedef struct SceneRenderLayer { int passflag; /* pass_xor has to be after passflag */ int pass_xor; + int denoiseflag; + int denoise_half_window; + float denoise_strength; + int pad; + int samples; float pass_alpha_threshold; @@ -213,6 +218,19 @@ typedef struct SceneRenderLayer { #define SCE_LAY_ZMASK 0x40000 #define SCE_LAY_NEG_ZMASK 0x80000 +typedef enum SceneDenoiseFlag { + SCE_DENOISE_RESULT = (1 << 0), + SCE_DENOISE_PASSES = (1 << 1), + SCE_DENOISE_DIFFDIR = (1 << 2), + SCE_DENOISE_DIFFIND = (1 << 3), + SCE_DENOISE_GLOSSDIR = (1 << 4), + SCE_DENOISE_GLOSSIND = (1 << 5), + SCE_DENOISE_TRANSDIR = (1 << 6), + SCE_DENOISE_TRANSIND = (1 << 7), + SCE_DENOISE_SUBDIR = (1 << 8), + SCE_DENOISE_SUBIND = (1 << 9), +} SceneDenoiseFlag; + /* srl->passflag */ typedef enum ScenePassType { SCE_PASS_COMBINED = (1 << 0), diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e89edaf74ad..aa04ebefa8b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -4579,6 +4579,69 @@ static void rna_def_scene_render_layer(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "freestyleConfig"); RNA_def_property_struct_type(prop, "FreestyleSettings"); RNA_def_property_ui_text(prop, "Freestyle Settings", ""); + + /* Cycles denoising */ + prop = RNA_def_property(srna, "denoise_result", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_RESULT); + RNA_def_property_ui_text(prop, "Denoise Render Result", "Denoise the rendered image during rendering"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "keep_denoise_data", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_PASSES); + RNA_def_property_ui_text(prop, "Keep denoising data", "Store the denoising data so that the image can be denoised later"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_diffuse_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_DIFFDIR); + RNA_def_property_ui_text(prop, "Diffuse Direct", "Denoise the direct diffuse lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_diffuse_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_DIFFIND); + RNA_def_property_ui_text(prop, "Diffuse Indirect", "Denoise the indirect diffuse lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_glossy_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_GLOSSDIR); + RNA_def_property_ui_text(prop, "Glossy Direct", "Denoise the direct glossy lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_glossy_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_GLOSSIND); + RNA_def_property_ui_text(prop, "Glossy Indirect", "Denoise the indirect glossy lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_transmission_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_TRANSDIR); + RNA_def_property_ui_text(prop, "Transmission Direct", "Denoise the direct transmission lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_transmission_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_TRANSIND); + RNA_def_property_ui_text(prop, "Transmission Indirect", "Denoise the indirect transmission lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_subsurface_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_SUBDIR); + RNA_def_property_ui_text(prop, "Subsurface Direct", "Denoise the direct subsurface lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "denoise_subsurface_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "denoiseflag", SCE_DENOISE_SUBIND); + RNA_def_property_ui_text(prop, "Subsurface Indirect", "Denoise the indirect subsurface lighting"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "filter_strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "denoise_strength"); + RNA_def_property_range(prop, -2.0, 2.0); + RNA_def_property_ui_text(prop, "Filter strength", "Strength of the denoising filter (0 = average, higher is stronger)"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); + + prop = RNA_def_property(srna, "half_window", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "denoise_half_window"); + RNA_def_property_range(prop, 1, 50); + RNA_def_property_ui_text(prop, "Half window", "Size of the filter window (the pixel area used for denoising one pixel). Higher values get rid of more noise, but might lose detail and are slower."); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); } /* Render Layers */ |