Merge branch 'master' into blender2.8
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Thu, 8 Feb 2018 18:00:20 +0000 (03:00 +0900)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Thu, 8 Feb 2018 18:00:20 +0000 (03:00 +0900)
Conflicts:
intern/cycles/blender/addon/ui.py

1  2 
intern/cycles/blender/addon/ui.py
tests/python/CMakeLists.txt

index 13bb00949824509464932dadbdd606d3570de94c,e3076a8ec2ce4b0ebcdc5b8a832f1a85d3b44e49..d5f72654c723ccbc7476a3a24f935f90c9a23534
@@@ -17,7 -17,6 +17,7 @@@
  # <pep8 compliant>
  
  import bpy
 +from bpy_extras.node_utils import find_node_input, find_output_node
  
  from bpy.types import (
          Panel,
@@@ -50,7 -49,8 +50,7 @@@ class CyclesButtonsPanel
  
      @classmethod
      def poll(cls, context):
 -        rd = context.scene.render
 -        return rd.engine in cls.COMPAT_ENGINES
 +        return context.scene.view_render.engine in cls.COMPAT_ENGINES
  
  
  def get_device_type(context):
@@@ -204,6 -204,13 +204,6 @@@ class CYCLES_RENDER_PT_sampling(CyclesB
              col.prop(cscene, "sample_all_lights_indirect")
  
          layout.row().prop(cscene, "sampling_pattern", text="Pattern")
 -
 -        for rl in scene.render.layers:
 -            if rl.samples > 0:
 -                layout.separator()
 -                layout.row().prop(cscene, "use_layer_samples")
 -                break
 -
          draw_samples_info(layout, context)
  
  
@@@ -408,8 -415,8 +408,8 @@@ class CYCLES_RENDER_PT_performance(Cycl
  
          subsub = sub.column()
          subsub.active = not rd.use_save_buffers
 -        for rl in rd.layers:
 -            if rl.cycles.use_denoising:
 +        for view_layer in scene.view_layers:
 +            if view_layer.cycles.use_denoising:
                  subsub.active = False
          subsub.prop(cscene, "use_progressive_refine")
  
  
  class CYCLES_RENDER_PT_layer_options(CyclesButtonsPanel, Panel):
      bl_label = "Layer"
 -    bl_context = "render_layer"
 +    bl_context = "view_layer"
  
      def draw(self, context):
          layout = self.layout
+         with_freestyle = bpy.app.build_options.freestyle
  
          scene = context.scene
 -        rl = rd.layers.active
 -
 -        split = layout.split()
 -
 -        col = split.column()
 -        col.prop(scene, "layers", text="Scene")
 -        col.prop(rl, "layers_exclude", text="Exclude")
 -
 -        col = split.column()
 -        col.prop(rl, "layers", text="Layer")
 -        col.prop(rl, "layers_zmask", text="Mask Layer")
+         rd = scene.render
 +        view_layer = scene.view_layers.active
  
 -        split = layout.split()
 -
 -        col = split.column()
 -        col.label(text="Material:")
 -        col.prop(rl, "material_override", text="")
 -        col.separator()
 -        col.prop(rl, "samples")
 -
 -        col = split.column()
 -        col.prop(rl, "use_sky", "Use Environment")
 -        col.prop(rl, "use_ao", "Use AO")
 -        col.prop(rl, "use_solid", "Use Surfaces")
 -        col.prop(rl, "use_strand", "Use Hair")
 +        col = layout.column()
 +        col.prop(view_layer, "use_sky", "Use Environment")
 +        col.prop(view_layer, "use_ao", "Use AO")
 +        col.prop(view_layer, "use_solid", "Use Surfaces")
 +        col.prop(view_layer, "use_strand", "Use Hair")
+         if with_freestyle:
+             row = col.row()
 -            row.prop(rl, "use_freestyle", "Use Freestyle")
++            row.prop(view_layer, "use_freestyle", "Use Freestyle")
+             row.active = rd.use_freestyle
  
  
  class CYCLES_RENDER_PT_layer_passes(CyclesButtonsPanel, Panel):
      bl_label = "Passes"
 -    bl_context = "render_layer"
 +    bl_context = "view_layer"
      bl_options = {'DEFAULT_CLOSED'}
  
      def draw(self, context):
  
          scene = context.scene
          rd = scene.render
 -        rl = rd.layers.active
 -        crl = rl.cycles
 +        view_layer = scene.view_layers.active
 +        cycles_view_layer = view_layer.cycles
  
          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")
          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 = 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")
  
  
  class CYCLES_RENDER_PT_views(CyclesButtonsPanel, Panel):
      bl_label = "Views"
 -    bl_context = "render_layer"
 +    bl_context = "view_layer"
      bl_options = {'DEFAULT_CLOSED'}
  
      def draw_header(self, context):
  
          if basic_stereo:
              row = layout.row()
 -            row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
 +            row.template_list("VIEWLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
  
              row = layout.row()
              row.label(text="File Suffix:")
  
          else:
              row = layout.row()
 -            row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
 +            row.template_list("VIEWLAYER_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="")
  
  class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel):
      bl_label = "Denoising"
 -    bl_context = "render_layer"
 +    bl_context = "view_layer"
      bl_options = {'DEFAULT_CLOSED'}
  
      def draw_header(self, context):
 -        rd = context.scene.render
 -        rl = rd.layers.active
 -        crl = rl.cycles
 -        cscene = context.scene.cycles
 +        scene = context.scene
 +        view_layer = scene.view_layers.active
 +        cycles_view_layer = view_layer.cycles
 +        cscene = scene.cycles
          layout = self.layout
  
 -        layout.prop(crl, "use_denoising", text="")
 +        layout.prop(cycles_view_layer, "use_denoising", text="")
  
      def draw(self, context):
          layout = self.layout
  
          scene = context.scene
          cscene = scene.cycles
 -        rd = scene.render
 -        rl = rd.layers.active
 -        crl = rl.cycles
 +        view_layer = scene.view_layers.active
 +        cycles_view_layer = view_layer.cycles
  
 -        layout.active = crl.use_denoising
 +        layout.active = cycles_view_layer.use_denoising
  
          split = layout.split()
  
          col = split.column()
          sub = col.column(align=True)
 -        sub.prop(crl, "denoising_radius", text="Radius")
 -        sub.prop(crl, "denoising_strength", slider=True, text="Strength")
 +        sub.prop(cycles_view_layer, "denoising_radius", text="Radius")
 +        sub.prop(cycles_view_layer, "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")
 +        sub.prop(cycles_view_layer, "denoising_feature_strength", slider=True, text="Feature Strength")
 +        sub.prop(cycles_view_layer, "denoising_relative_pca")
  
          layout.separator()
  
          row = layout.row()
          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)
 +        sub.prop(cycles_view_layer, "denoising_diffuse_direct", text="Direct", toggle=True)
 +        sub.prop(cycles_view_layer, "denoising_diffuse_indirect", text="Indirect", toggle=True)
  
          row = layout.row()
          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)
 +        sub.prop(cycles_view_layer, "denoising_glossy_direct", text="Direct", toggle=True)
 +        sub.prop(cycles_view_layer, "denoising_glossy_indirect", text="Indirect", toggle=True)
  
          row = layout.row()
          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)
 +        sub.prop(cycles_view_layer, "denoising_transmission_direct", text="Direct", toggle=True)
 +        sub.prop(cycles_view_layer, "denoising_transmission_indirect", text="Indirect", toggle=True)
  
          row = layout.row()
          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)
 +        sub.prop(cycles_view_layer, "denoising_subsurface_direct", text="Direct", toggle=True)
 +        sub.prop(cycles_view_layer, "denoising_subsurface_indirect", text="Indirect", toggle=True)
  
  
  class CYCLES_PT_post_processing(CyclesButtonsPanel, Panel):
@@@ -886,22 -918,43 +892,22 @@@ class CYCLES_OT_use_shading_nodes(Opera
          return {'FINISHED'}
  
  
 -def find_node(material, nodetype):
 -    if material and material.node_tree:
 -        ntree = material.node_tree
 -
 -        active_output_node = None
 -        for node in ntree.nodes:
 -            if getattr(node, "type", None) == nodetype:
 -                if getattr(node, "is_active_output", True):
 -                    return node
 -                if not active_output_node:
 -                    active_output_node = node
 -        return active_output_node
 -
 -    return None
 -
 -
 -def find_node_input(node, name):
 -    for input in node.inputs:
 -        if input.name == name:
 -            return input
 -
 -    return None
 -
 -
 -def panel_node_draw(layout, id_data, output_type, input_name):
 +def panel_node_draw(layout, id_data, output_types, input_name):
      if not id_data.use_nodes:
          layout.operator("cycles.use_shading_nodes", icon='NODETREE')
          return False
  
      ntree = id_data.node_tree
  
 -    node = find_node(id_data, output_type)
 -    if not node:
 -        layout.label(text="No output node")
 -    else:
 +    node = find_output_node(ntree, output_types)
 +    if node:
          input = find_node_input(node, input_name)
 -        layout.template_node_view(ntree, node, input)
 +        if input:
 +            layout.template_node_view(ntree, node, input)
 +        else:
 +            layout.label(text="Incompatible output node")
 +    else:
 +        layout.label(text="No output node")
  
      return True
  
@@@ -990,7 -1043,7 +996,7 @@@ class CYCLES_LAMP_PT_nodes(CyclesButton
          layout = self.layout
  
          lamp = context.lamp
 -        if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
 +        if not panel_node_draw(layout, lamp, ('OUTPUT_LAMP',), 'Surface'):
              layout.prop(lamp, "color")
  
  
@@@ -1045,7 -1098,7 +1051,7 @@@ class CYCLES_WORLD_PT_surface(CyclesBut
  
          world = context.world
  
 -        if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
 +        if not panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Surface'):
              layout.prop(world, "horizon_color", text="Color")
  
  
@@@ -1063,7 -1116,7 +1069,7 @@@ class CYCLES_WORLD_PT_volume(CyclesButt
          layout = self.layout
  
          world = context.world
 -        panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
 +        panel_node_draw(layout, world, ('OUTPUT_WORLD',), 'Volume')
  
  
  class CYCLES_WORLD_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
@@@ -1100,8 -1153,8 +1106,8 @@@ class CYCLES_WORLD_PT_mist(CyclesButton
      def poll(cls, context):
          if CyclesButtonsPanel.poll(context):
              if context.world:
 -                for rl in context.scene.render.layers:
 -                    if rl.use_pass_mist:
 +                for view_layer in context.scene.view_layers:
 +                    if view_layer.use_pass_mist:
                          return True
  
          return False
@@@ -1208,7 -1261,7 +1214,7 @@@ class CYCLES_MATERIAL_PT_surface(Cycles
          layout = self.layout
  
          mat = context.material
 -        if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
 +        if not panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Surface'):
              layout.prop(mat, "diffuse_color")
  
  
@@@ -1228,7 -1281,7 +1234,7 @@@ class CYCLES_MATERIAL_PT_volume(CyclesB
          mat = context.material
          # cmat = mat.cycles
  
 -        panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
 +        panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Volume')
  
  
  class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel):
          layout = self.layout
  
          mat = context.material
 -        panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
 +        panel_node_draw(layout, mat, ('OUTPUT_MATERIAL', 'OUTPUT_EEVEE_MATERIAL'), 'Displacement')
  
  
  class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel):
@@@ -1653,7 -1706,6 +1659,7 @@@ class CYCLES_SCENE_PT_simplify(CyclesBu
          row.prop(rd, "simplify_subdivision", text="Viewport")
          row.prop(rd, "simplify_subdivision_render", text="Render")
  
 +
          col = layout.column(align=True)
          col.label(text="Child Particles")
          row = col.row(align=True)
@@@ -1693,7 -1745,7 +1699,7 @@@ def draw_device(self, context)
      scene = context.scene
      layout = self.layout
  
 -    if scene.render.engine == 'CYCLES':
 +    if context.engine == 'CYCLES':
          from . import engine
          cscene = scene.cycles
  
@@@ -1713,11 -1765,14 +1719,11 @@@ def draw_pause(self, context)
      layout = self.layout
      scene = context.scene
  
 -    if scene.render.engine == "CYCLES":
 +    if context.engine == "CYCLES":
          view = context.space_data
  
 -        if view.viewport_shade == 'RENDERED':
 -            cscene = scene.cycles
 -            layername = scene.render.layers.active.name
 -            layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
 -            layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
 +        cscene = scene.cycles
 +        layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
  
  
  def get_panels():
          'MATERIAL_PT_volume_options',
          'MATERIAL_PT_volume_shading',
          'MATERIAL_PT_volume_transp',
 -        'RENDERLAYER_PT_layer_options',
 -        'RENDERLAYER_PT_layer_passes',
 -        'RENDERLAYER_PT_views',
 +        'VIEWLAYER_PT_layer_options',
 +        'VIEWLAYER_PT_layer_passes',
 +        'VIEWLAYER_PT_views',
          'RENDER_PT_antialiasing',
          'RENDER_PT_bake',
          'RENDER_PT_motion_blur',
index 9f1de64c2e9187fb5b543d1f78cb356d7881cab2,63709aae74fbf7be50f5f0353b33666e81c572cb..537a3e3a07e70818ea095d8e30f53462079c954f
@@@ -547,6 -547,7 +547,7 @@@ if(WITH_CYCLES
                add_cycles_render_test(shader)
                add_cycles_render_test(shader_tangent)
                add_cycles_render_test(shadow_catcher)
+               add_cycles_render_test(sss)
                add_cycles_render_test(texture_space)
                add_cycles_render_test(volume)
        else()
@@@ -592,5 -593,3 +593,5 @@@ if(WITH_ALEMBIC
                --with-legacy-depsgraph=${WITH_LEGACY_DEPSGRAPH}
        )
  endif()
 +
 +add_subdirectory(view_layer)