fix for cycles/python script error in normal panel
[blender.git] / intern / cycles / blender / addon / ui.py
index d3c06084ad3ee1cb2df667b240aff331ebf996b5..0080ff75ddde248418da513e6cc3ee9f24b43bd6 100644 (file)
@@ -44,8 +44,51 @@ class CyclesButtonsPanel():
         return rd.engine == 'CYCLES'
 
 
-class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
-    bl_label = "Integrator"
+class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
+    bl_label = "Sampling"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        scene = context.scene
+        cscene = scene.cycles
+        device_type = context.user_preferences.system.compute_device_type
+
+        split = layout.split()
+
+        col = split.column()
+        sub = col.column()
+        sub.enabled = (device_type == 'NONE' or cscene.device == 'CPU')
+        sub.prop(cscene, "progressive")
+
+        sub = col.column(align=True)
+        sub.prop(cscene, "seed")
+        sub.prop(cscene, "sample_clamp")
+
+        if cscene.progressive or (device_type != 'NONE' and cscene.device == 'GPU'):
+            col = split.column()
+            col.label(text="Samples:")
+            sub = col.column(align=True)
+            sub.prop(cscene, "samples", text="Render")
+            sub.prop(cscene, "preview_samples", text="Preview")
+        else:
+            sub.label(text="AA Samples:")
+            sub.prop(cscene, "aa_samples", text="Render")
+            sub.prop(cscene, "preview_aa_samples", text="Preview")
+
+            col = split.column()
+            col.label(text="Samples:")
+            sub = col.column(align=True)
+            sub.prop(cscene, "diffuse_samples", text="Diffuse")
+            sub.prop(cscene, "glossy_samples", text="Glossy")
+            sub.prop(cscene, "transmission_samples", text="Transmission")
+            sub.prop(cscene, "ao_samples", text="AO")
+            sub.prop(cscene, "mesh_light_samples", text="Mesh Light")
+
+
+class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
+    bl_label = "Light Paths"
     bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
@@ -62,11 +105,6 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         split = layout.split()
 
         col = split.column()
-        sub = col.column(align=True)
-        sub.label(text="Samples:")
-        sub.prop(cscene, "samples", text="Render")
-        sub.prop(cscene, "preview_samples", text="Preview")
-        sub.prop(cscene, "seed")
 
         sub = col.column(align=True)
         sub.label("Transparency:")
@@ -74,6 +112,11 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "transparent_min_bounces", text="Min")
         sub.prop(cscene, "use_transparent_shadows", text="Shadows")
 
+        col.separator()
+
+        col.prop(cscene, "no_caustics")
+        col.prop(cscene, "blur_glossy")
+
         col = split.column()
 
         sub = col.column(align=True)
@@ -82,15 +125,32 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "min_bounces", text="Min")
 
         sub = col.column(align=True)
-        sub.label(text="Light Paths:")
         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
         sub.prop(cscene, "glossy_bounces", text="Glossy")
         sub.prop(cscene, "transmission_bounces", text="Transmission")
-        sub.prop(cscene, "no_caustics")
 
-        #row = col.row()
-        #row.prop(cscene, "blur_caustics")
-        #row.active = not cscene.no_caustics
+
+class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
+    bl_label = "Motion Blur"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return False
+
+    def draw_header(self, context):
+        rd = context.scene.render
+
+        self.layout.prop(rd, "use_motion_blur", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+        layout.active = rd.use_motion_blur
+
+        row = layout.row()
+        row.prop(rd, "motion_blur_shutter")
 
 
 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
@@ -138,8 +198,13 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
 
         sub = col.column(align=True)
         sub.label(text="Tiles:")
-        sub.prop(cscene, "debug_tile_size")
-        sub.prop(cscene, "debug_min_size")
+
+        sub.prop(rd, "parts_x", text="X")
+        sub.prop(rd, "parts_y", text="Y")
+
+        subsub = sub.column()
+        subsub.enabled = not rd.use_border
+        subsub.prop(rd, "use_save_buffers")
 
         col = split.column()
 
@@ -149,6 +214,11 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "debug_use_spatial_splits")
         sub.prop(cscene, "use_cache")
 
+        sub = col.column(align=True)
+        sub.label(text="Viewport:")
+        sub.prop(cscene, "preview_start_resolution")
+
+
 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
     bl_label = "Layers"
     bl_options = {'DEFAULT_CLOSED'}
@@ -176,14 +246,57 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
 
         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.label(text="Mask Layers:")
+        col.prop(rl, "layers_zmask", text="")
 
-        layout.separator()
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Material:")
+        col.prop(rl, "material_override", text="")
+
+        col = split.column()
+        col.prop(rl, "samples")
+        col.prop(rl, "use_sky", "Use Environment")
 
-        rl = rd.layers[0]
-        layout.prop(rl, "material_override", text="Material")
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Passes:")
+        col.prop(rl, "use_pass_combined")
+        col.prop(rl, "use_pass_z")
+        col.prop(rl, "use_pass_normal")
+        col.prop(rl, "use_pass_vector")
+        col.prop(rl, "use_pass_uv")
+        col.prop(rl, "use_pass_object_index")
+        col.prop(rl, "use_pass_material_index")
+        col.prop(rl, "use_pass_ambient_occlusion")
+        col.prop(rl, "use_pass_shadow")
+
+        col = split.column()
+        col.label()
+        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)
+        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)
+        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)
+
+        col.prop(rl, "use_pass_emit", text="Emission")
+        col.prop(rl, "use_pass_environment")
 
 
 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
@@ -232,7 +345,12 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
         col = split.column()
 
         col.label("Aperture:")
-        col.prop(ccam, "aperture_size", text="Size")
+        sub = col.column(align=True)
+        sub.prop(ccam, "aperture_type", text="")
+        if ccam.aperture_type == 'RADIUS':
+            sub.prop(ccam, "aperture_size", text="Size")
+        elif ccam.aperture_type == 'FSTOP':
+            sub.prop(ccam, "aperture_fstop", text="Number")
 
         sub = col.column(align=True)
         sub.prop(ccam, "aperture_blades", text="Blades")
@@ -240,7 +358,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
 
 
 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
-    bl_label = "Surface"
+    bl_label = ""
     bl_context = "material"
     bl_options = {'HIDE_HEADER'}
 
@@ -319,6 +437,27 @@ class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
         layout.prop(cdata, "use_subdivision")
         layout.prop(cdata, "dicing_rate")
 
+class Cycles_PT_mesh_normals(CyclesButtonsPanel, Panel):
+    bl_label = "Normals"
+    bl_context = "data"
+
+    @classmethod
+    def poll(cls, context):
+        return CyclesButtonsPanel.poll(context) and context.mesh
+
+    def draw(self, context):
+        layout = self.layout
+
+        mesh = context.mesh
+
+        split = layout.split()
+
+        col = split.column()
+        col.prop(mesh, "show_double_sided")
+
+        col = split.column()
+        col.label()
+
 
 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
     bl_label = "Ray Visibility"
@@ -336,16 +475,13 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
         ob = context.object
         visibility = ob.cycles_visibility
 
-        split = layout.split()
+        flow = layout.column_flow()
 
-        col = split.column()
-        col.prop(visibility, "camera")
-        col.prop(visibility, "diffuse")
-        col.prop(visibility, "glossy")
-
-        col = split.column()
-        col.prop(visibility, "transmission")
-        col.prop(visibility, "shadow")
+        flow.prop(visibility, "camera")
+        flow.prop(visibility, "diffuse")
+        flow.prop(visibility, "glossy")
+        flow.prop(visibility, "transmission")
+        flow.prop(visibility, "shadow")
 
 
 def find_node(material, nodetype):
@@ -368,7 +504,7 @@ def find_node_input(node, name):
 
 
 def panel_node_draw(layout, id_data, output_type, input_name):
-    if not id_data.node_tree:
+    if not id_data.use_nodes:
         layout.prop(id_data, "use_nodes", icon='NODETREE')
         return False
 
@@ -397,6 +533,8 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
 
         lamp = context.lamp
         clamp = lamp.cycles
+        cscene = context.scene.cycles
+        device_type = context.user_preferences.system.compute_device_type
 
         layout.prop(lamp, "type", expand=True)
 
@@ -415,12 +553,13 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
                 sub.prop(lamp, "size", text="Size X")
                 sub.prop(lamp, "size_y", text="Size Y")
 
+        if not cscene.progressive and (device_type == 'NONE' or cscene.device == 'CPU'):
+            col.prop(clamp, "samples")
+
         col = split.column()
         col.prop(clamp, "cast_shadow")
 
-        if lamp.type == 'SPOT':
-            layout.label(text="Not supported, interpreted as point lamp.")
-        elif lamp.type == 'HEMI':
+        if lamp.type == 'HEMI':
             layout.label(text="Not supported, interpreted as sun lamp.")
 
 
@@ -440,6 +579,31 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
             layout.prop(lamp, "color")
 
 
+class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel):
+    bl_label = "Spot Shape"
+    bl_context = "data"
+
+    @classmethod
+    def poll(cls, context):
+        lamp = context.lamp
+        return (lamp and lamp.type == 'SPOT') and CyclesButtonsPanel.poll(context)
+
+    def draw(self, context):
+        layout = self.layout
+
+        lamp = context.lamp
+
+        split = layout.split()
+
+        col = split.column()
+        sub = col.column()
+        sub.prop(lamp, "spot_size", text="Size")
+        sub.prop(lamp, "spot_blend", text="Blend", slider=True)
+
+        col = split.column()
+        col.prop(lamp, "show_cone")
+
+
 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
     bl_label = "Surface"
     bl_context = "world"
@@ -452,6 +616,7 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
         layout = self.layout
 
         world = context.world
+
         if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
             layout.prop(world, "horizon_color", text="Color")
 
@@ -475,6 +640,56 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
 
 
+class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
+    bl_label = "Ambient Occlusion"
+    bl_context = "world"
+
+    @classmethod
+    def poll(cls, context):
+        return context.world and CyclesButtonsPanel.poll(context)
+
+    def draw_header(self, context):
+        light = context.world.light_settings
+        self.layout.prop(light, "use_ambient_occlusion", text="")
+
+    def draw(self, context):
+        layout = self.layout
+        light = context.world.light_settings
+
+        layout.active = light.use_ambient_occlusion
+
+        row = layout.row()
+        row.prop(light, "ao_factor", text="Factor")
+        row.prop(light, "distance", text="Distance")
+
+
+class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
+    bl_label = "Settings"
+    bl_context = "world"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.world and CyclesButtonsPanel.poll(context)
+
+    def draw(self, context):
+        layout = self.layout
+
+        world = context.world
+        cworld = world.cycles
+        cscene = context.scene.cycles
+        device_type = context.user_preferences.system.compute_device_type
+
+        col = layout.column()
+
+        col.prop(cworld, "sample_as_light")
+        sub = col.row(align=True)
+        sub.active = cworld.sample_as_light
+        sub.prop(cworld, "sample_map_resolution")
+        if not cscene.progressive and (device_type == 'NONE' or cscene.device == 'CPU'):
+            sub.prop(cworld, "samples")
+
+
 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
     bl_label = "Surface"
     bl_context = "material"
@@ -552,6 +767,7 @@ class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
 
         col = split.column()
         col.prop(cmat, "sample_as_light")
+        col.prop(mat, "pass_index")
 
 
 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
@@ -568,7 +784,6 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
         pin_id = space.pin_id
         use_pin_id = space.use_pin_id
         user = context.texture_user
-        # node = context.texture_node
 
         if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
             pin_id = None
@@ -588,14 +803,9 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
                 col.template_ID(user, "texture", new="texture.new")
 
             if tex:
-                row = split.row()
-                row.prop(tex, "use_nodes", icon="NODETREE", text="")
-                row.label()
-
-                if not tex.use_nodes:
-                    split = layout.split(percentage=0.2)
-                    split.label(text="Type:")
-                    split.prop(tex, "type", text="")
+                split = layout.split(percentage=0.2)
+                split.label(text="Type:")
+                split.prop(tex, "type", text="")
 
 
 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
@@ -651,7 +861,7 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
 
         row = layout.row()
 
-        row.column().prop(mapping, "location")
+        row.column().prop(mapping, "translation")
         row.column().prop(mapping, "rotation")
         row.column().prop(mapping, "scale")
 
@@ -704,11 +914,36 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
             layout.template_color_ramp(mapping, "color_ramp", expand=True)
 
 
+class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
+    bl_label = "Simplify"
+    bl_context = "scene"
+    COMPAT_ENGINES = {'CYCLES'}
+
+    def draw_header(self, context):
+        rd = context.scene.render
+        self.layout.prop(rd, "use_simplify", text="")
+
+    def draw(self, context):
+        layout = self.layout
+
+        rd = context.scene.render
+
+        layout.active = rd.use_simplify
+
+        split = layout.split()
+
+        col = split.column()
+        col.prop(rd, "simplify_subdivision", text="Subdivision")
+
+        col = split.column()
+        col.prop(rd, "simplify_child_particles", text="Child Particles")
+
+
 def draw_device(self, context):
     scene = context.scene
     layout = self.layout
 
-    if scene.render.engine == "CYCLES":
+    if scene.render.engine == 'CYCLES':
         cscene = scene.cycles
 
         layout.prop(cscene, "feature_set")
@@ -718,6 +953,10 @@ def draw_device(self, context):
             layout.prop(cscene, "device")
         elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
             layout.prop(cscene, "device")
+            
+        if cscene.feature_set == 'EXPERIMENTAL' and cscene.device == 'CPU' and engine.with_osl():
+            layout.prop(cscene, "shading_system")
+
 
 def draw_pause(self, context):
     layout = self.layout
@@ -726,9 +965,11 @@ def draw_pause(self, context):
     if scene.render.engine == "CYCLES":
         view = context.space_data
 
-        if view.viewport_shade == "RENDERED":
+        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)
 
 
 def get_panels():
@@ -758,6 +999,7 @@ def get_panels():
         bpy.types.DATA_PT_camera,
         bpy.types.DATA_PT_camera_display,
         bpy.types.DATA_PT_lens,
+        bpy.types.DATA_PT_customdata,
         bpy.types.DATA_PT_custom_props_mesh,
         bpy.types.DATA_PT_custom_props_camera,
         bpy.types.DATA_PT_custom_props_lamp,