Merge branch 'master' into blender2.8
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 28 Oct 2018 15:41:30 +0000 (16:41 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 28 Oct 2018 15:41:30 +0000 (16:41 +0100)
1  2 
build_files/cmake/macros.cmake
intern/cycles/blender/addon/engine.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_session.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/render/buffers.cpp
intern/cycles/render/shader.cpp
source/blender/editors/space_file/fsmenu.c

Simple merge
Simple merge
index a4a1f597455a283a212328670fa5fe02f37b97b6,848b76eb02f504a4589b0fbf74c7174266586142..05f94ebc37a7536f455154c031d18a5fa6bf9e2a
@@@ -1228,133 -1214,203 +1228,163 @@@ def update_render_passes(self, context)
  
  
  class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
 -    @classmethod
 -    def register(cls):
 -        bpy.types.SceneRenderLayer.cycles = PointerProperty(
 -            name="Cycles SceneRenderLayer Settings",
 -            description="Cycles SceneRenderLayer Settings",
 -            type=cls,
 -        )
 -        cls.pass_debug_bvh_traversed_nodes = BoolProperty(
 -            name="Debug BVH Traversed Nodes",
 -            description="Store Debug BVH Traversed Nodes pass",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.pass_debug_bvh_traversed_instances = BoolProperty(
 -            name="Debug BVH Traversed Instances",
 -            description="Store Debug BVH Traversed Instances pass",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.pass_debug_bvh_intersections = BoolProperty(
 -            name="Debug BVH Intersections",
 -            description="Store Debug BVH Intersections",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.pass_debug_ray_bounces = BoolProperty(
 -            name="Debug Ray Bounces",
 -            description="Store Debug Ray Bounces pass",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.pass_debug_render_time = BoolProperty(
 -            name="Debug Render Time",
 -            description="Render time in milliseconds per sample and pixel",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.use_pass_volume_direct = BoolProperty(
 -            name="Volume Direct",
 -            description="Deliver direct volumetric scattering pass",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.use_pass_volume_indirect = BoolProperty(
 -            name="Volume Indirect",
 -            description="Deliver indirect volumetric scattering pass",
 -            default=False,
 -            update=update_render_passes,
 -        )
  
 -        cls.use_denoising = BoolProperty(
 -            name="Use Denoising",
 -            description="Denoise the rendered image",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.denoising_diffuse_direct = BoolProperty(
 -            name="Diffuse Direct",
 -            description="Denoise the direct diffuse lighting",
 -            default=True,
 -        )
 -        cls.denoising_diffuse_indirect = BoolProperty(
 -            name="Diffuse Indirect",
 -            description="Denoise the indirect diffuse lighting",
 -            default=True,
 -        )
 -        cls.denoising_glossy_direct = BoolProperty(
 -            name="Glossy Direct",
 -            description="Denoise the direct glossy lighting",
 -            default=True,
 -        )
 -        cls.denoising_glossy_indirect = BoolProperty(
 -            name="Glossy Indirect",
 -            description="Denoise the indirect glossy lighting",
 -            default=True,
 -        )
 -        cls.denoising_transmission_direct = BoolProperty(
 -            name="Transmission Direct",
 -            description="Denoise the direct transmission lighting",
 -            default=True,
 -        )
 -        cls.denoising_transmission_indirect = BoolProperty(
 -            name="Transmission Indirect",
 -            description="Denoise the indirect transmission lighting",
 -            default=True,
 -        )
 -        cls.denoising_subsurface_direct = BoolProperty(
 -            name="Subsurface Direct",
 -            description="Denoise the direct subsurface lighting",
 -            default=True,
 -        )
 -        cls.denoising_subsurface_indirect = BoolProperty(
 -            name="Subsurface Indirect",
 -            description="Denoise the indirect subsurface lighting",
 -            default=True,
 -        )
 -        cls.denoising_strength = FloatProperty(
 -            name="Denoising Strength",
 -            description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
 -            min=0.0, max=1.0,
 -            default=0.5,
 -        )
 -        cls.denoising_feature_strength = FloatProperty(
 -            name="Denoising Feature Strength",
 -            description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
 -            min=0.0, max=1.0,
 -            default=0.5,
 -        )
 -        cls.denoising_radius = IntProperty(
 -            name="Denoising Radius",
 -            description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
 -            min=1, max=25,
 -            default=8,
 -        )
 -        cls.denoising_relative_pca = BoolProperty(
 -            name="Relative filter",
 -            description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)",
 -            default=False,
 -        )
 -        cls.denoising_store_passes = BoolProperty(
 -            name="Store denoising passes",
 -            description="Store the denoising feature passes and the noisy image",
 -            default=False,
 -            update=update_render_passes,
 -        )
 -        cls.use_pass_crypto_object = BoolProperty(
 -                name="Cryptomatte Object",
 -                description="Cryptomatte Object pass",
 -                default=False,
 -                update=update_render_passes,
 -                )
 -        cls.use_pass_crypto_material = BoolProperty(
 -                name="Cryptomatte Material",
 -                description="Cryptomatte Material pass",
 -                default=False,
 -                update=update_render_passes,
 -                )
 -        cls.use_pass_crypto_asset = BoolProperty(
 -                name="Cryptomatte Asset",
 -                description="Cryptomatte Asset pass",
 -                default=False,
 -                update=update_render_passes,
 -                )
 -        cls.pass_crypto_depth = IntProperty(
 -                name="Cryptomatte Levels",
 -                description="Describes how many unique IDs per pixel are written to Cryptomatte",
 -                default=6, min=2, max=16, step=2,
 -                update=update_render_passes,
 -                )
 -        cls.pass_crypto_accurate = BoolProperty(
 -                name="Cryptomatte Accurate",
 -                description="Gerenate a more accurate Cryptomatte pass, CPU only, may render slower and use more memory",
 -                default=True,
 -                update=update_render_passes,
 -                )
 -    @classmethod
 -    def unregister(cls):
 -        del bpy.types.SceneRenderLayer.cycles
 +    pass_debug_bvh_traversed_nodes: BoolProperty(
 +        name="Debug BVH Traversed Nodes",
 +        description="Store Debug BVH Traversed Nodes pass",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    pass_debug_bvh_traversed_instances: BoolProperty(
 +        name="Debug BVH Traversed Instances",
 +        description="Store Debug BVH Traversed Instances pass",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    pass_debug_bvh_intersections: BoolProperty(
 +        name="Debug BVH Intersections",
 +        description="Store Debug BVH Intersections",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    pass_debug_ray_bounces: BoolProperty(
 +        name="Debug Ray Bounces",
 +        description="Store Debug Ray Bounces pass",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    pass_debug_render_time: BoolProperty(
 +        name="Debug Render Time",
 +        description="Render time in milliseconds per sample and pixel",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    use_pass_volume_direct: BoolProperty(
 +        name="Volume Direct",
 +        description="Deliver direct volumetric scattering pass",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    use_pass_volume_indirect: BoolProperty(
 +        name="Volume Indirect",
 +        description="Deliver indirect volumetric scattering pass",
 +        default=False,
 +        update=update_render_passes,
 +    )
  
 +    use_denoising: BoolProperty(
 +        name="Use Denoising",
 +        description="Denoise the rendered image",
 +        default=False,
 +        update=update_render_passes,
 +    )
 +    denoising_diffuse_direct: BoolProperty(
 +        name="Diffuse Direct",
 +        description="Denoise the direct diffuse lighting",
 +        default=True,
 +    )
 +    denoising_diffuse_indirect: BoolProperty(
 +        name="Diffuse Indirect",
 +        description="Denoise the indirect diffuse lighting",
 +        default=True,
 +    )
 +    denoising_glossy_direct: BoolProperty(
 +        name="Glossy Direct",
 +        description="Denoise the direct glossy lighting",
 +        default=True,
 +    )
 +    denoising_glossy_indirect: BoolProperty(
 +        name="Glossy Indirect",
 +        description="Denoise the indirect glossy lighting",
 +        default=True,
 +    )
 +    denoising_transmission_direct: BoolProperty(
 +        name="Transmission Direct",
 +        description="Denoise the direct transmission lighting",
 +        default=True,
 +    )
 +    denoising_transmission_indirect: BoolProperty(
 +        name="Transmission Indirect",
 +        description="Denoise the indirect transmission lighting",
 +        default=True,
 +    )
 +    denoising_subsurface_direct: BoolProperty(
 +        name="Subsurface Direct",
 +        description="Denoise the direct subsurface lighting",
 +        default=True,
 +    )
 +    denoising_subsurface_indirect: BoolProperty(
 +        name="Subsurface Indirect",
 +        description="Denoise the indirect subsurface lighting",
 +        default=True,
 +    )
 +    denoising_strength: FloatProperty(
 +        name="Denoising Strength",
 +        description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
 +        min=0.0, max=1.0,
 +        default=0.5,
 +    )
 +    denoising_feature_strength: FloatProperty(
 +        name="Denoising Feature Strength",
 +        description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
 +        min=0.0, max=1.0,
 +        default=0.5,
 +    )
 +    denoising_radius: IntProperty(
 +        name="Denoising Radius",
 +        description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
 +        min=1, max=25,
 +        default=8,
 +    )
 +    denoising_relative_pca: BoolProperty(
 +        name="Relative filter",
 +        description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)",
 +        default=False,
 +    )
 +    denoising_store_passes: BoolProperty(
 +        name="Store denoising passes",
 +        description="Store the denoising feature passes and the noisy image",
 +        default=False,
 +        update=update_render_passes,
 +    )
++    use_pass_crypto_object: BoolProperty(
++        name="Cryptomatte Object",
++        description="Cryptomatte Object pass",
++        default=False,
++        update=update_render_passes,
++        )
++    use_pass_crypto_material: BoolProperty(
++        name="Cryptomatte Material",
++        description="Cryptomatte Material pass",
++        default=False,
++        update=update_render_passes,
++        )
++    use_pass_crypto_asset: BoolProperty(
++        name="Cryptomatte Asset",
++        description="Cryptomatte Asset pass",
++        default=False,
++        update=update_render_passes,
++        )
++    pass_crypto_depth: IntProperty(
++        name="Cryptomatte Levels",
++        description="Describes how many unique IDs per pixel are written to Cryptomatte",
++        default=6, min=2, max=16, step=2,
++        update=update_render_passes,
++        )
++    pass_crypto_accurate: BoolProperty(
++        name="Cryptomatte Accurate",
++        description="Gerenate a more accurate Cryptomatte pass, CPU only, may render slower and use more memory",
++        default=True,
++        update=update_render_passes,
++        )
  
 -class CyclesCurveSettings(bpy.types.PropertyGroup):
      @classmethod
      def register(cls):
 -        bpy.types.ParticleSettings.cycles = PointerProperty(
 -            name="Cycles Hair Settings",
 -            description="Cycles hair settings",
 +        bpy.types.ViewLayer.cycles = PointerProperty(
 +            name="Cycles ViewLayer Settings",
 +            description="Cycles ViewLayer Settings",
              type=cls,
          )
 -        cls.radius_scale = FloatProperty(
 -            name="Radius Scaling",
 -            description="Multiplier of width properties",
 -            min=0.0, max=1000.0,
 -            default=0.01,
 -        )
 -        cls.root_width = FloatProperty(
 -            name="Root Size",
 -            description="Strand's width at root",
 -            min=0.0, max=1000.0,
 -            default=1.0,
 -        )
 -        cls.tip_width = FloatProperty(
 -            name="Tip Multiplier",
 -            description="Strand's width at tip",
 -            min=0.0, max=1000.0,
 -            default=0.0,
 -        )
 -        cls.shape = FloatProperty(
 -            name="Strand Shape",
 -            description="Strand shape parameter",
 -            min=-1.0, max=1.0,
 -            default=0.0,
 -        )
 -        cls.use_closetip = BoolProperty(
 -            name="Close tip",
 -            description="Set tip radius to zero",
 -            default=True,
 -        )
  
      @classmethod
      def unregister(cls):
index 0b73a684a554a8673c581db67ad4f1bda3477053,6f11d3c313d3e20796046b01bdeee30e7fa2244b..bce909e345a4d90ae3ed8fd357f1bdeb527ff870
@@@ -806,17 -552,71 +806,28 @@@ class CYCLES_RENDER_PT_layer_passes(Cyc
          if context.scene.cycles.feature_set == 'EXPERIMENTAL':
              col.separator()
              sub = col.column()
 -            sub.active = crl.use_denoising
 -            sub.prop(crl, "denoising_store_passes", text="Denoising")
 +            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:")
+         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):
      bl_label = "Denoising"
index 4ac0e1f21c1c75ff8e4d2f43337d604080476cd7,e9e14a9b6c944b9432e968d4b2c80397b77c5750..1ff15284bc1ae7c2f094a94e7e4474c447b18c60
@@@ -395,89 -381,111 +395,89 @@@ 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_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;
  
 -              /* 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);
 +      /* add passes */
-       array<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer, session_params);
++      vector<Pass> passes = sync->sync_render_passes(b_rlay, b_view_layer, session_params);
 +      buffer_params.passes = passes;
  
 -              /* 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;
 -              }
 +      PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
 +      bool use_denoising = get_boolean(crl, "use_denoising");
  
 -              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");
 -
 -              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;
 -              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);
 -                      }
 +      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);
  
 -                      /* Update number of samples per layer. */
 -                      int samples = sync->get_layer_samples();
 -                      bool bound_samples = sync->get_layer_bound_samples();
 -                      int effective_layer_samples;
 +      session->params.use_denoising = use_denoising;
 +      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");
  
 -                      if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 -                              effective_layer_samples = samples;
 -                      else
 -                              effective_layer_samples = session_params.samples;
 +      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");
  
 -                      /* Update tile manager if we're doing resumable render. */
 -                      update_resumable_tile_manager(effective_layer_samples);
 +      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 session itself. */
 -                      session->reset(buffer_params, 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();
  
 -                      /* render */
 -                      session->start();
 -                      session->wait();
 +              /* set the current view */
 +              b_engine.active_view_set(b_rview_name.c_str());
  
 -                      if(session->progress.get_cancel())
 -                              break;
 +              /* 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);
                }
  
 -              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.
 -                       */
 -              }
 +              int effective_layer_samples = session_params.samples;
 +
 +              /* TODO: Update number of samples per layer. */
 +#if 0
 +              if(samples != 0 && (!bound_samples || (samples < session_params.samples)))
 +                      effective_layer_samples = samples;
 +#endif
  
 -              /* free result without merging */
 -              end_render_result(b_engine, b_rr, true, true, false);
 +              /* Update tile manager if we're doing resumable render. */
 +              update_resumable_tile_manager(effective_layer_samples);
 +
 +              /* Update session itself. */
 +              session->reset(buffer_params, effective_layer_samples);
 +
 +              /* render */
 +              session->start();
 +              session->wait();
  
                if(!b_engine.is_preview() && background && print_render_stats) {
                        RenderStats stats;
index 4989746ae6afb79a0abb3c5096f62e175eb862de,076734d105f481262dab9deefa95b3390506770c..424894387807b29ac0afda7f55067508a4a9b622
@@@ -479,11 -554,11 +486,11 @@@ int BlenderSync::get_denoising_pass(BL:
        return -1;
  }
  
- array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
-                                             BL::ViewLayer& b_view_layer,
-                                             const SessionParams &session_params)
+ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
 -                                             BL::SceneRenderLayer& b_srlay,
++                                             BL::ViewLayer& b_view_layer,
+                                              const SessionParams &session_params)
  {
-       array<Pass> passes;
+       vector<Pass> passes;
        Pass::add(PASS_COMBINED, passes);
  
        if(!session_params.device.advanced_shading) {
        }
  
        scene->film->denoising_flags = 0;
 -      PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
 -      if(get_boolean(crp, "use_denoising"))
 -      {
 +      PointerRNA crp = RNA_pointer_get(&b_view_layer.ptr, "cycles");
-       if(get_boolean(crp, "denoising_store_passes") &&
-          get_boolean(crp, "use_denoising"))
-       {
-               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",           3, "RGB", b_view_layer.name().c_str());
-               b_engine.add_pass("Denoising Image Variance",  3, "RGB", b_view_layer.name().c_str());
++      if(get_boolean(crp, "use_denoising")) {
  #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_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_view_layer.name().c_str());
 -              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_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__
                Pass::add(PASS_VOLUME_INDIRECT, passes);
        }
  
 -                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_srlay.name().c_str());
+       /* Cryptomatte stores two ID/weight pairs per RGBA layer.
+        * User facing paramter is the number of pairs. */
+       int crypto_depth = min(16, get_int(crp, "pass_crypto_depth")) / 2;
+       scene->film->cryptomatte_depth = crypto_depth;
+       scene->film->cryptomatte_passes = CRYPT_NONE;
+       if(get_boolean(crp, "use_pass_crypto_object")) {
+               for(int i = 0; i < crypto_depth; ++i) {
+                       string passname = cryptomatte_prefix + string_printf("Object%02d", i);
 -                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_srlay.name().c_str());
++                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
+                       Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
+               }
+               scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_OBJECT);
+       }
+       if(get_boolean(crp, "use_pass_crypto_material")) {
+               for(int i = 0; i < crypto_depth; ++i) {
+                       string passname = cryptomatte_prefix + string_printf("Material%02d", i);
 -                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_srlay.name().c_str());
++                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
+                       Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
+               }
+               scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_MATERIAL);
+       }
+       if(get_boolean(crp, "use_pass_crypto_asset")) {
+               for(int i = 0; i < crypto_depth; ++i) {
+                       string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
++                      b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
+                       Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
+               }
+               scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_ASSET);
+       }
+       if(get_boolean(crp, "pass_crypto_accurate") && scene->film->cryptomatte_passes != CRYPT_NONE) {
+               scene->film->cryptomatte_passes = (CryptomatteType)(scene->film->cryptomatte_passes | CRYPT_ACCURATE);
+       }
        return passes;
  }
  
index e63ef9e5e47666eb0970df5867281dde86e6e748,eb84bedb1184e4c2e489e4791d03aa742de15b8e..d2b362be24d472c56750317876b3d2e7060c1485
@@@ -65,11 -63,12 +65,11 @@@ public
                       BL::SpaceView3D& b_v3d,
                       BL::Object& b_override,
                       int width, int height,
 -                     void **python_thread_state,
 -                     const char *layer = 0);
 -      void sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer);
 -      vector<Pass> sync_render_passes(BL::RenderLayer& b_rlay,
 -                                      BL::SceneRenderLayer& b_srlay,
 +                     void **python_thread_state);
 +      void sync_view_layer(BL::SpaceView3D& b_v3d, BL::ViewLayer& b_view_layer);
-       array<Pass> sync_render_passes(BL::RenderLayer& b_render_layer,
-                                      BL::ViewLayer& b_view_layer,
-                                      const SessionParams &session_params);
++      vector<Pass> sync_render_passes(BL::RenderLayer& b_render_layer,
++                                      BL::ViewLayer& b_view_layer,
+                                       const SessionParams &session_params);
        void sync_integrator();
        void sync_camera(BL::RenderSettings& b_render,
                         BL::Object& b_override,
Simple merge
Simple merge