Cycles: Add Denoising Clean to the debugging denoising passes
authorLukas Stockner <lukas.stockner@freenet.de>
Sat, 25 Aug 2018 16:20:25 +0000 (09:20 -0700)
committerLukas Stockner <lukas.stockner@freenet.de>
Sat, 25 Aug 2018 16:32:29 +0000 (09:32 -0700)
intern/cycles/blender/addon/engine.py
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/kernel/kernel_types.h
intern/cycles/render/buffers.cpp

index c30d199ede88b807c56c6125dfb4b99fcf2d27ef..ee2dcfadad3fbe1cc765705f42a5c705bae8ce05 100644 (file)
@@ -265,3 +265,10 @@ def register_passes(engine, scene, srl):
         engine.register_pass(scene, srl, "Denoising Shadow B",        3, "XYV", 'VECTOR')
         engine.register_pass(scene, srl, "Denoising Image",           3, "RGB", 'COLOR')
         engine.register_pass(scene, srl, "Denoising Image Variance",  3, "RGB", 'COLOR')
+
+        clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect",
+                         "denoising_glossy_direct", "denoising_glossy_indirect",
+                         "denoising_transmission_direct", "denoising_transmission_indirect",
+                         "denoising_subsurface_direct", "denoising_subsurface_indirect")
+        if any(getattr(crl, option) for option in clean_options):
+            engine.register_pass(scene, srl, "Denoising Clean", 3, "RGB", 'COLOR')
\ No newline at end of file
index e11b8e0c70db9cc0ea0e8b64a86d188de93ab20e..a07131d04aebdf8284b1819c706450547b43dcf9 100644 (file)
@@ -410,26 +410,19 @@ void BlenderSession::render()
 
                PointerRNA crl = RNA_pointer_get(&b_layer_iter->ptr, "cycles");
                bool use_denoising = get_boolean(crl, "use_denoising");
-               buffer_params.denoising_data_pass = use_denoising;
+
                session->tile_manager.schedule_denoising = use_denoising;
+               buffer_params.denoising_data_pass = use_denoising;
+               buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
+
                session->params.use_denoising = use_denoising;
-               scene->film->denoising_data_pass = buffer_params.denoising_data_pass;
-               scene->film->denoising_flags = 0;
-               if(!get_boolean(crl, "denoising_diffuse_direct"))        scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_DIR;
-               if(!get_boolean(crl, "denoising_diffuse_indirect"))      scene->film->denoising_flags |= DENOISING_CLEAN_DIFFUSE_IND;
-               if(!get_boolean(crl, "denoising_glossy_direct"))         scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_DIR;
-               if(!get_boolean(crl, "denoising_glossy_indirect"))       scene->film->denoising_flags |= DENOISING_CLEAN_GLOSSY_IND;
-               if(!get_boolean(crl, "denoising_transmission_direct"))   scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_DIR;
-               if(!get_boolean(crl, "denoising_transmission_indirect")) scene->film->denoising_flags |= DENOISING_CLEAN_TRANSMISSION_IND;
-               if(!get_boolean(crl, "denoising_subsurface_direct"))     scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_DIR;
-               if(!get_boolean(crl, "denoising_subsurface_indirect"))   scene->film->denoising_flags |= DENOISING_CLEAN_SUBSURFACE_IND;
-               scene->film->denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
-               buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass;
                session->params.denoising_radius = get_int(crl, "denoising_radius");
                session->params.denoising_strength = get_float(crl, "denoising_strength");
                session->params.denoising_feature_strength = get_float(crl, "denoising_feature_strength");
                session->params.denoising_relative_pca = get_boolean(crl, "denoising_relative_pca");
 
+               scene->film->denoising_data_pass = buffer_params.denoising_data_pass;
+               scene->film->denoising_clean_pass = buffer_params.denoising_clean_pass;
                scene->film->pass_alpha_threshold = b_layer_iter->pass_alpha_threshold();
                scene->film->tag_passes_update(scene, passes);
                scene->film->tag_update(scene);
index a08089118d514986731e83df93f729aee8573fd3..fedcb8742696efb50d8ea8956014c4c8624fb7f5 100644 (file)
@@ -541,6 +541,7 @@ int BlenderSync::get_denoising_pass(BL::RenderPass& b_pass)
        MAP_PASS("Shadow B", DENOISING_PASS_SHADOW_B);
        MAP_PASS("Image", DENOISING_PASS_COLOR);
        MAP_PASS("Image Variance", DENOISING_PASS_COLOR_VAR);
+       MAP_PASS("Clean", DENOISING_PASS_CLEAN);
 #undef MAP_PASS
 
        return -1;
@@ -570,6 +571,7 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
                        Pass::add(pass_type, passes);
        }
 
+       scene->film->denoising_flags = 0;
        PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
        if(get_boolean(crp, "denoising_store_passes") &&
           get_boolean(crp, "use_denoising"))
@@ -584,6 +586,21 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
                b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_srlay.name().c_str());
                b_engine.add_pass("Denoising Image",           3, "RGB", b_srlay.name().c_str());
                b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_srlay.name().c_str());
+
+#define MAP_OPTION(name, flag) if(!get_boolean(crp, name)) scene->film->denoising_flags |= flag;
+               MAP_OPTION("denoising_diffuse_direct",        DENOISING_CLEAN_DIFFUSE_DIR);
+               MAP_OPTION("denoising_diffuse_indirect",      DENOISING_CLEAN_DIFFUSE_IND);
+               MAP_OPTION("denoising_glossy_direct",         DENOISING_CLEAN_GLOSSY_DIR);
+               MAP_OPTION("denoising_glossy_indirect",       DENOISING_CLEAN_GLOSSY_IND);
+               MAP_OPTION("denoising_transmission_direct",   DENOISING_CLEAN_TRANSMISSION_DIR);
+               MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND);
+               MAP_OPTION("denoising_subsurface_direct",     DENOISING_CLEAN_SUBSURFACE_DIR);
+               MAP_OPTION("denoising_subsurface_indirect",   DENOISING_CLEAN_SUBSURFACE_IND);
+#undef MAP_OPTION
+
+               if(scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) {
+                       b_engine.add_pass("Denoising Clean", 3, "RGB", b_srlay.name().c_str());
+               }
        }
 #ifdef __KERNEL_DEBUG__
        if(get_boolean(crp, "pass_debug_bvh_traversed_nodes")) {
index 855484848731396597d88cc5c256477fa739b1b5..d169915cff9b95a253763bbebe022eeed6bb5ab3 100644 (file)
@@ -454,6 +454,7 @@ typedef enum DenoisingPassOffsets {
        DENOISING_PASS_SHADOW_B           = 17,
        DENOISING_PASS_COLOR              = 20,
        DENOISING_PASS_COLOR_VAR          = 23,
+       DENOISING_PASS_CLEAN              = 26,
 
        DENOISING_PASS_SIZE_BASE          = 26,
        DENOISING_PASS_SIZE_CLEAN         = 3,
index 1724e2548193d3b6c7b9fb9af431c87ded518ef8..4cd8b3726d3aac3c4ca2315d6aacefc9cc8b45b3 100644 (file)
@@ -160,7 +160,7 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
                        (offset == DENOISING_PASS_DEPTH_VAR) ||
                        (offset == DENOISING_PASS_COLOR_VAR);
 
-       if(offset == DENOISING_PASS_COLOR) {
+       if(offset == DENOISING_PASS_COLOR || offset == DENOISING_PASS_CLEAN) {
                scale *= exposure;
        }
        else if(offset == DENOISING_PASS_COLOR_VAR) {