Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 30 Oct 2018 13:13:47 +0000 (14:13 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 30 Oct 2018 13:13:47 +0000 (14:13 +0100)
1  2 
intern/cycles/blender/addon/engine.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp

Simple merge
@@@ -757,76 -503,115 +757,72 @@@ class CYCLES_RENDER_PT_layer_passes(Cyc
          split = layout.split()
  
          col = split.column()
 -        col.prop(rl, "use_pass_combined")
 -        col.prop(rl, "use_pass_z")
 -        col.prop(rl, "use_pass_mist")
 -        col.prop(rl, "use_pass_normal")
 +        col.prop(view_layer, "use_pass_combined")
 +        col.prop(view_layer, "use_pass_z")
 +        col.prop(view_layer, "use_pass_mist")
 +        col.prop(view_layer, "use_pass_normal")
          row = col.row()
 -        row.prop(rl, "use_pass_vector")
 +        row.prop(view_layer, "use_pass_vector")
          row.active = not rd.use_motion_blur
 -        col.prop(rl, "use_pass_uv")
 -        col.prop(rl, "use_pass_object_index")
 -        col.prop(rl, "use_pass_material_index")
 +        col.prop(view_layer, "use_pass_uv")
 +        col.prop(view_layer, "use_pass_object_index")
 +        col.prop(view_layer, "use_pass_material_index")
          col.separator()
 -        col.prop(rl, "use_pass_shadow")
 -        col.prop(rl, "use_pass_ambient_occlusion")
 +        col.prop(view_layer, "use_pass_shadow")
 +        col.prop(view_layer, "use_pass_ambient_occlusion", text="Ambient Occlusion")
          col.separator()
 -        col.prop(crl, "denoising_store_passes", text="Denoising Data")
++        col.prop(cycles_view_layer, "denoising_store_passes", text="Denoising Data")
+         col.separator()
 -        col.prop(rl, "pass_alpha_threshold")
 +        col.prop(view_layer, "pass_alpha_threshold")
  
          col = split.column()
          col.label(text="Diffuse:")
          row = col.row(align=True)
 -        row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
 -        row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
 -        row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
 +        row.prop(view_layer, "use_pass_diffuse_direct", text="Direct", toggle=True)
 +        row.prop(view_layer, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
 +        row.prop(view_layer, "use_pass_diffuse_color", text="Color", toggle=True)
          col.label(text="Glossy:")
          row = col.row(align=True)
 -        row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
 -        row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
 -        row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
 +        row.prop(view_layer, "use_pass_glossy_direct", text="Direct", toggle=True)
 +        row.prop(view_layer, "use_pass_glossy_indirect", text="Indirect", toggle=True)
 +        row.prop(view_layer, "use_pass_glossy_color", text="Color", toggle=True)
          col.label(text="Transmission:")
          row = col.row(align=True)
 -        row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
 -        row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
 -        row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
 +        row.prop(view_layer, "use_pass_transmission_direct", text="Direct", toggle=True)
 +        row.prop(view_layer, "use_pass_transmission_indirect", text="Indirect", toggle=True)
 +        row.prop(view_layer, "use_pass_transmission_color", text="Color", toggle=True)
          col.label(text="Subsurface:")
          row = col.row(align=True)
 -        row.prop(rl, "use_pass_subsurface_direct", text="Direct", toggle=True)
 -        row.prop(rl, "use_pass_subsurface_indirect", text="Indirect", toggle=True)
 -        row.prop(rl, "use_pass_subsurface_color", text="Color", toggle=True)
 +        row.prop(view_layer, "use_pass_subsurface_direct", text="Direct", toggle=True)
 +        row.prop(view_layer, "use_pass_subsurface_indirect", text="Indirect", toggle=True)
 +        row.prop(view_layer, "use_pass_subsurface_color", text="Color", toggle=True)
          col.label(text="Volume:")
          row = col.row(align=True)
 -        row.prop(crl, "use_pass_volume_direct", text="Direct", toggle=True)
 -        row.prop(crl, "use_pass_volume_indirect", text="Indirect", toggle=True)
 +        row.prop(cycles_view_layer, "use_pass_volume_direct", text="Direct", toggle=True)
 +        row.prop(cycles_view_layer, "use_pass_volume_indirect", text="Indirect", toggle=True)
  
          col.separator()
 -        col.prop(rl, "use_pass_emit", text="Emission")
 -        col.prop(rl, "use_pass_environment")
 +        col.prop(view_layer, "use_pass_emit", text="Emission")
 +        col.prop(view_layer, "use_pass_environment")
  
-         if context.scene.cycles.feature_set == 'EXPERIMENTAL':
-             col.separator()
-             sub = col.column()
-             sub.active = cycles_view_layer.use_denoising
-             sub.prop(cycles_view_layer, "denoising_store_passes", text="Denoising")
          col = layout.column()
 -        col.prop(crl, "pass_debug_render_time")
 +        col.prop(cycles_view_layer, "pass_debug_render_time")
          if _cycles.with_cycles_debug:
 -            col.prop(crl, "pass_debug_bvh_traversed_nodes")
 -            col.prop(crl, "pass_debug_bvh_traversed_instances")
 -            col.prop(crl, "pass_debug_bvh_intersections")
 -            col.prop(crl, "pass_debug_ray_bounces")
 +            col.prop(cycles_view_layer, "pass_debug_bvh_traversed_nodes")
 +            col.prop(cycles_view_layer, "pass_debug_bvh_traversed_instances")
 +            col.prop(cycles_view_layer, "pass_debug_bvh_intersections")
 +            col.prop(cycles_view_layer, "pass_debug_ray_bounces")
  
 -        crl = rl.cycles
 -        layout.label("Cryptomatte:")
 +        layout.label(text="Cryptomatte:")
          row = layout.row(align=True)
 -        row.prop(crl, "use_pass_crypto_object", text="Object", toggle=True)
 -        row.prop(crl, "use_pass_crypto_material", text="Material", toggle=True)
 -        row.prop(crl, "use_pass_crypto_asset", text="Asset", toggle=True)
 +        row.prop(cycles_view_layer, "use_pass_crypto_object", text="Object", toggle=True)
 +        row.prop(cycles_view_layer, "use_pass_crypto_material", text="Material", toggle=True)
 +        row.prop(cycles_view_layer, "use_pass_crypto_asset", text="Asset", toggle=True)
          row = layout.row(align=True)
 -        row.prop(crl, "pass_crypto_depth")
 +        row.prop(cycles_view_layer, "pass_crypto_depth")
          row = layout.row(align=True)
          row.active = use_cpu(context)
 -        row.prop(crl, "pass_crypto_accurate", text="Accurate Mode")
 -
 -class CYCLES_RENDER_PT_views(CyclesButtonsPanel, Panel):
 -    bl_label = "Views"
 -    bl_context = "render_layer"
 -    bl_options = {'DEFAULT_CLOSED'}
 -
 -    def draw_header(self, context):
 -        rd = context.scene.render
 -        self.layout.prop(rd, "use_multiview", text="")
 -
 -    def draw(self, context):
 -        layout = self.layout
 -
 -        scene = context.scene
 -        rd = scene.render
 -        rv = rd.views.active
 -
 -        layout.active = rd.use_multiview
 -        basic_stereo = (rd.views_format == 'STEREO_3D')
 -
 -        row = layout.row()
 -        row.prop(rd, "views_format", expand=True)
 -
 -        if basic_stereo:
 -            row = layout.row()
 -            row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
 -
 -            row = layout.row()
 -            row.label(text="File Suffix:")
 -            row.prop(rv, "file_suffix", text="")
 -
 -        else:
 -            row = layout.row()
 -            row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
 -
 -            col = row.column(align=True)
 -            col.operator("scene.render_view_add", icon='ZOOMIN', text="")
 -            col.operator("scene.render_view_remove", icon='ZOOMOUT', text="")
 -
 -            row = layout.row()
 -            row.label(text="Camera Suffix:")
 -            row.prop(rv, "camera_suffix", text="")
 +        row.prop(cycles_view_layer, "pass_crypto_accurate", text="Accurate Mode")
  
  
  class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
  
          scene = context.scene
          cscene = scene.cycles
 -        rd = scene.render
 -        rl = rd.layers.active
 -        crl = rl.cycles
 +        view_layer = context.view_layer
 +        cycles_view_layer = view_layer.cycles
  
-         layout.active = cycles_view_layer.use_denoising
-         col = layout.column()
-         sub = col.column()
-         sub.prop(cycles_view_layer, "denoising_radius", text="Radius")
-         sub.prop(cycles_view_layer, "denoising_strength", slider=True, text="Strength")
-         sub = col.column(align=True)
-         sub.prop(cycles_view_layer, "denoising_feature_strength", slider=True, text="Feature Strength")
-         sub.prop(cycles_view_layer, "denoising_relative_pca")
+         split = layout.split()
 -        split.active = crl.use_denoising
++        split.active = cycles_view_layer.use_denoising
  
- #        layout.use_property_split = False
 -        col = split.column()
 -        sub = col.column(align=True)
 -        sub.prop(crl, "denoising_radius", text="Radius")
 -        sub.prop(crl, "denoising_strength", slider=True, text="Strength")
 -
 -        col = split.column()
 -        sub = col.column(align=True)
 -        sub.prop(crl, "denoising_feature_strength", slider=True, text="Feature Strength")
 -        sub.prop(crl, "denoising_relative_pca")
++        layout = layout.column(align=True)
++        layout.prop(cycles_view_layer, "denoising_feature_strength", slider=True, text="Feature Strength")
++        layout.prop(cycles_view_layer, "denoising_relative_pca")
  
-         """
          layout.separator()
  
-         col = layout.column(align=True)
-         col.prop(cycles_view_layer, "denoising_diffuse_direct", text="Diffuse Direct")
-         col.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect")
-         col = layout.column(align=True)
-         col.prop(cycles_view_layer, "denoising_glossy_direct", text="Glossy Direct")
-         col.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect")
-         col = layout.column(align=True)
-         col.prop(cycles_view_layer, "denoising_transmission_direct", text="Transmission Direct")
-         col.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect")
-         col = layout.column(align=True)
-         col.prop(cycles_view_layer, "denoising_subsurface_direct", text="Subsurface Direct")
-         col.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect")
-         """
-         layout.use_property_split = False
-         split = layout.split(factor=0.5)
-         split.label(text="Diffuse")
-         col = split.column()
-         row = col.row(align=True)
 -        row = layout.row()
 -        row.active = crl.use_denoising or crl.denoising_store_passes
 -        row.label(text="Diffuse:")
 -        sub = row.row(align=True)
 -        sub.prop(crl, "denoising_diffuse_direct", text="Direct", toggle=True)
 -        sub.prop(crl, "denoising_diffuse_indirect", text="Indirect", toggle=True)
++        row = layout.row(align=True)
++        row.active = cycles_view_layer.use_denoising or cycles_view_layer.denoising_store_passes
++        row.label(text="Diffuse")
++        row.use_property_split = False
 +        row.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True)
 +        row.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True)
  
-         split = layout.split(factor=0.5)
-         split.label(text="Glossy")
-         col = split.column()
-         row = col.row(align=True)
 -        row = layout.row()
 -        row.active = crl.use_denoising or crl.denoising_store_passes
 -        row.label(text="Glossy:")
 -        sub = row.row(align=True)
 -        sub.prop(crl, "denoising_glossy_direct", text="Direct", toggle=True)
 -        sub.prop(crl, "denoising_glossy_indirect", text="Indirect", toggle=True)
++        row = layout.row(align=True)
++        row.active = cycles_view_layer.use_denoising or cycles_view_layer.denoising_store_passes
++        row.label(text="Glossy")
++        row.use_property_split = False
 +        row.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True)
 +        row.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True)
  
-         split = layout.split(factor=0.5)
-         split.label(text="Transmission")
-         col = split.column()
-         row = col.row(align=True)
 -        row = layout.row()
 -        row.active = crl.use_denoising or crl.denoising_store_passes
 -        row.label(text="Transmission:")
 -        sub = row.row(align=True)
 -        sub.prop(crl, "denoising_transmission_direct", text="Direct", toggle=True)
 -        sub.prop(crl, "denoising_transmission_indirect", text="Indirect", toggle=True)
++        row = layout.row(align=True)
++        row.active = cycles_view_layer.use_denoising or cycles_view_layer.denoising_store_passes
++        row.label(text="Transmission")
++        row.use_property_split = False
 +        row.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True)
 +        row.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True)
  
-         split = layout.split(factor=0.5)
-         split.label(text="Subsurface")
-         col = split.column()
-         row = col.row(align=True)
 -        row = layout.row()
 -        row.active = crl.use_denoising or crl.denoising_store_passes
 -        row.label(text="Subsurface:")
 -        sub = row.row(align=True)
 -        sub.prop(crl, "denoising_subsurface_direct", text="Direct", toggle=True)
 -        sub.prop(crl, "denoising_subsurface_indirect", text="Indirect", toggle=True)
++        row = layout.row(align=True)
++        row.active = cycles_view_layer.use_denoising or cycles_view_layer.denoising_store_passes
++        row.label(text="Subsurface")
++        row.use_property_split = False
 +        row.prop(cycles_view_layer, "denoising_subsurface_direct", text="Direct", toggle=True)
 +        row.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect", toggle=True)
  
  
  class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
@@@ -395,89 -381,113 +395,91 @@@ void BlenderSession::render(BL::Depsgra
        BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_v3d, b_rv3d, scene->camera, width, height);
  
        /* render each layer */
 -      BL::RenderSettings r = b_scene.render();
 -      BL::RenderSettings::layers_iterator b_layer_iter;
 -      BL::RenderResult::views_iterator b_view_iter;
 +      BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
  
        /* We do some special meta attributes when we only have single layer. */
 -      const bool is_single_layer = (r.layers.length() == 1);
 +      const bool is_single_layer = (b_scene.view_layers.length() == 1);
  
 -      for(r.layers.begin(b_layer_iter); b_layer_iter != r.layers.end(); ++b_layer_iter) {
 -              b_rlay_name = b_layer_iter->name();
 -
 -              /* temporary render result to find needed passes and views */
 -              BL::RenderResult b_rr = begin_render_result(b_engine, 0, 0, 1, 1, b_rlay_name.c_str(), NULL);
 -              BL::RenderResult::layers_iterator b_single_rlay;
 -              b_rr.layers.begin(b_single_rlay);
 -
 -              /* layer will be missing if it was disabled in the UI */
 -              if(b_single_rlay == b_rr.layers.end()) {
 -                      end_render_result(b_engine, b_rr, true, true, false);
 -                      continue;
 -              }
 +      /* temporary render result to find needed passes and views */
 +      BL::RenderResult b_rr = begin_render_result(b_engine, 0, 0, 1, 1, b_view_layer.name().c_str(), NULL);
 +      BL::RenderResult::layers_iterator b_single_rlay;
 +      b_rr.layers.begin(b_single_rlay);
 +      BL::RenderLayer b_rlay = *b_single_rlay;
  
 -              BL::RenderLayer b_rlay = *b_single_rlay;
 -
 -              /* add passes */
 -              vector<Pass> passes = sync->sync_render_passes(b_rlay, *b_layer_iter, session_params);
 -              buffer_params.passes = passes;
 -
 -              PointerRNA crl = RNA_pointer_get(&b_layer_iter->ptr, "cycles");
 -              bool use_denoising = get_boolean(crl, "use_denoising");
 -              bool denoising_passes = use_denoising || get_boolean(crl, "denoising_store_passes");
 -
 -              session->tile_manager.schedule_denoising = use_denoising;
 -              buffer_params.denoising_data_pass = denoising_passes;
 -              buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
 -
 -              session->params.use_denoising = use_denoising;
 -              session->params.denoising_passes = denoising_passes;
 -              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);
 -              scene->integrator->tag_update(scene);
 -
 -              int view_index = 0;
 -              for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) {
 -                      b_rview_name = b_view_iter->name();
 -
 -                      /* set the current view */
 -                      b_engine.active_view_set(b_rview_name.c_str());
 -
 -                      /* update scene */
 -                      BL::Object b_camera_override(b_engine.camera_override());
 -                      sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
 -                      sync->sync_data(b_render,
 -                                      b_v3d,
 -                                      b_camera_override,
 -                                      width, height,
 -                                      &python_thread_state,
 -                                      b_rlay_name.c_str());
 -
 -                      /* Make sure all views have different noise patterns. - hardcoded value just to make it random */
 -                      if(view_index != 0) {
 -                              scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef));
 -                              scene->integrator->tag_update(scene);
 -                      }
 +      /* add passes */
 +      vector<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer, session_params);
 +      buffer_params.passes = passes;
 +
 +      PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
 +      bool use_denoising = get_boolean(crl, "use_denoising");
++      bool denoising_passes = use_denoising || get_boolean(crl, "denoising_store_passes");
 +
 +      session->tile_manager.schedule_denoising = use_denoising;
-       buffer_params.denoising_data_pass = use_denoising;
++      buffer_params.denoising_data_pass = denoising_passes;
 +      buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES);
 +
 +      session->params.use_denoising = use_denoising;
++      session->params.denoising_passes = denoising_passes;
 +      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;
 +      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->pass_alpha_threshold = b_view_layer.pass_alpha_threshold();
 +      scene->film->tag_passes_update(scene, passes);
 +      scene->film->tag_update(scene);
 +      scene->integrator->tag_update(scene);
  
 -                      /* Update number of samples per layer. */
 -                      int samples = sync->get_layer_samples();
 -                      bool bound_samples = sync->get_layer_bound_samples();
 -                      int effective_layer_samples;
 +      BL::RenderResult::views_iterator b_view_iter;
 +      int view_index = 0;
 +      for(b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index) {
 +              b_rlay_name = b_view_layer.name();
 +              b_rview_name = b_view_iter->name();
  
 -                      if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 -                              effective_layer_samples = samples;
 -                      else
 -                              effective_layer_samples = session_params.samples;
 +              /* set the current view */
 +              b_engine.active_view_set(b_rview_name.c_str());
  
 -                      /* Update tile manager if we're doing resumable render. */
 -                      update_resumable_tile_manager(effective_layer_samples);
 +              /* update scene */
 +              BL::Object b_camera_override(b_engine.camera_override());
 +              sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
 +              sync->sync_data(b_render,
 +                              b_depsgraph,
 +                              b_v3d,
 +                              b_camera_override,
 +                              width, height,
 +                              &python_thread_state);
 +              builtin_images_load();
 +
 +              /* Make sure all views have different noise patterns. - hardcoded value just to make it random */
 +              if(view_index != 0) {
 +                      scene->integrator->seed += hash_int_2d(scene->integrator->seed, hash_int(view_index * 0xdeadbeef));
 +                      scene->integrator->tag_update(scene);
 +              }
  
 -                      /* Update session itself. */
 -                      session->reset(buffer_params, effective_layer_samples);
 +              int effective_layer_samples = session_params.samples;
  
 -                      /* render */
 -                      session->start();
 -                      session->wait();
 +              /* TODO: Update number of samples per layer. */
 +#if 0
 +              if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 +                      effective_layer_samples = samples;
 +#endif
  
 -                      if(session->progress.get_cancel())
 -                              break;
 -              }
 +              /* Update tile manager if we're doing resumable render. */
 +              update_resumable_tile_manager(effective_layer_samples);
  
 -              if(is_single_layer) {
 -                      BL::RenderResult b_rr = b_engine.get_result();
 -                      string num_aa_samples = string_printf("%d", session->params.samples);
 -                      b_rr.stamp_data_add_field("Cycles Samples", num_aa_samples.c_str());
 -                      /* TODO(sergey): Report whether we're doing resumable render
 -                       * and also start/end sample if so.
 -                       */
 -              }
 +              /* Update session itself. */
 +              session->reset(buffer_params, effective_layer_samples);
  
 -              /* free result without merging */
 -              end_render_result(b_engine, b_rr, true, true, false);
 +              /* render */
 +              session->start();
 +              session->wait();
  
                if(!b_engine.is_preview() && background && print_render_stats) {
                        RenderStats stats;
@@@ -510,9 -578,11 +510,11 @@@ vector<Pass> BlenderSync::sync_render_p
                        Pass::add(pass_type, passes);
        }
  
-       scene->film->denoising_flags = 0;
 -      PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
 +      PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles");
-       if(get_boolean(crp, "use_denoising")) {
+       bool use_denoising = get_boolean(crp, "use_denoising");
+       bool store_denoising_passes = get_boolean(crp, "denoising_store_passes");
+       scene->film->denoising_flags = 0;
+       if(use_denoising || store_denoising_passes) {
  #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_subsurface_direct",     DENOISING_CLEAN_SUBSURFACE_DIR);
                MAP_OPTION("denoising_subsurface_indirect",   DENOISING_CLEAN_SUBSURFACE_IND);
  #undef MAP_OPTION
 -              b_engine.add_pass("Noisy Image", 4, "RGBA", b_srlay.name().c_str());
 +              b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str());
-               if(get_boolean(crp, "denoising_store_passes")) {
-                       b_engine.add_pass("Denoising Normal",          3, "XYZ", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Albedo",          3, "RGB", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Depth",           1, "Z",   b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Depth Variance",  1, "Z",   b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Shadow A",        3, "XYV", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_view_layer.name().c_str());
-                       b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_view_layer.name().c_str());
-                       if(scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) {
-                               b_engine.add_pass("Denoising Clean",   3, "RGB", b_view_layer.name().c_str());
-                       }
+       }
+       if(store_denoising_passes) {
 -              b_engine.add_pass("Denoising Normal",          3, "XYZ", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Albedo",          3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Depth",           1, "Z",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Depth Variance",  1, "Z",   b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Shadow A",        3, "XYV", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_srlay.name().c_str());
 -              b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_srlay.name().c_str());
++              b_engine.add_pass("Denoising Normal",          3, "XYZ", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Albedo",          3, "RGB", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Depth",           1, "Z",   b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Depth Variance",  1, "Z",   b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Shadow A",        3, "XYV", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Shadow B",        3, "XYV", b_view_layer.name().c_str());
++              b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_view_layer.name().c_str());
+               if(scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES) {
 -                      b_engine.add_pass("Denoising Clean",   3, "RGB", b_srlay.name().c_str());
++                      b_engine.add_pass("Denoising Clean",   3, "RGB", b_view_layer.name().c_str());
                }
        }
  #ifdef __KERNEL_DEBUG__