2 # Copyright 2011, Blender Foundation.
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 from bpy.types import Panel, Menu
23 from cycles import enums
24 from cycles import engine
26 class CYCLES_MT_integrator_presets(Menu):
27 bl_label = "Integrator Presets"
28 preset_subdir = "cycles/integrator"
29 preset_operator = "script.execute_preset"
30 COMPAT_ENGINES = {'CYCLES'}
31 draw = Menu.draw_preset
33 class CyclesButtonsPanel():
34 bl_space_type = "PROPERTIES"
35 bl_region_type = "WINDOW"
39 def poll(cls, context):
40 rd = context.scene.render
41 return rd.engine == 'CYCLES'
43 class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
44 bl_label = "Integrator"
45 bl_options = {'DEFAULT_CLOSED'}
47 def draw(self, context):
53 row = layout.row(align=True)
54 row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
55 row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
56 row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
58 split = layout.split()
61 sub = col.column(align=True)
62 sub.label(text="Samples:")
63 sub.prop(cscene, "samples", text="Render")
64 sub.prop(cscene, "preview_samples", text="Preview")
66 sub = col.column(align=True)
67 sub.label("Tranparency:")
68 sub.prop(cscene, "transparent_max_bounces", text="Max")
69 sub.prop(cscene, "transparent_min_bounces", text="Min")
70 sub.prop(cscene, "no_caustics")
74 sub = col.column(align=True)
75 sub.label(text="Bounces:")
76 sub.prop(cscene, "max_bounces", text="Max")
77 sub.prop(cscene, "min_bounces", text="Min")
79 sub = col.column(align=True)
80 sub.label(text="Light Paths:")
81 sub.prop(cscene, "diffuse_bounces", text="Diffuse")
82 sub.prop(cscene, "glossy_bounces", text="Glossy")
83 sub.prop(cscene, "transmission_bounces", text="Transmission")
86 #row.prop(cscene, "blur_caustics")
87 #row.active = not cscene.no_caustics
89 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
92 def draw(self, context):
98 split = layout.split()
100 col = split.column();
101 col.prop(cscene, "film_exposure")
102 col.prop(cscene, "film_transparent")
105 sub = col.column(align=True)
106 sub.prop(cscene, "filter_type", text="")
107 if cscene.filter_type != 'BOX':
108 sub.prop(cscene, "filter_width", text="Width")
110 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
111 bl_label = "Performance"
112 bl_options = {'DEFAULT_CLOSED'}
114 def draw(self, context):
117 scene = context.scene
119 cscene = scene.cycles
121 split = layout.split()
123 col = split.column(align=True)
125 col.label(text="Threads:")
126 col.row().prop(rd, "threads_mode", expand=True)
128 sub.enabled = rd.threads_mode == 'FIXED'
129 sub.prop(rd, "threads")
131 sub = col.column(align=True)
132 sub.label(text="Tiles:")
133 sub.prop(cscene, "debug_tile_size")
134 sub.prop(cscene, "debug_min_size")
138 sub = col.column(align=True)
139 sub.label(text="Acceleration structure:")
140 sub.prop(cscene, "debug_bvh_type", text="")
141 sub.prop(cscene, "debug_use_spatial_splits")
143 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
145 bl_options = {'DEFAULT_CLOSED'}
146 COMPAT_ENGINES = {'BLENDER_RENDER'}
148 def draw(self, context):
151 scene = context.scene
155 # row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
157 # col = row.column(align=True)
158 # col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
159 # col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
162 # rl = rd.layers.active
165 #row.prop(rd, "use_single_layer", text="", icon_only=True)
167 split = layout.split()
170 col.prop(scene, "layers", text="Scene")
173 col.prop(rl, "layers", text="Layer")
177 layout.prop(rl, "material_override", text="Material")
179 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
180 bl_label = "Post Processing"
181 bl_options = {'DEFAULT_CLOSED'}
183 def draw(self, context):
186 rd = context.scene.render
188 split = layout.split()
191 col.prop(rd, "use_compositing")
192 col.prop(rd, "use_sequencer")
195 col.prop(rd, "dither_intensity", text="Dither", slider=True)
197 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
198 bl_label = "Depth of Field"
202 def poll(cls, context):
203 return context.camera and CyclesButtonsPanel.poll(context)
205 def draw(self, context):
211 split = layout.split()
215 col.prop(cam, "dof_object", text="")
218 sub.active = cam.dof_object is None
219 sub.prop(cam, "dof_distance", text="Distance")
223 col.label("Aperture:")
224 col.prop(ccam, "aperture_size", text="Size")
226 sub = col.column(align=True)
227 sub.prop(ccam, "aperture_blades", text="Blades")
228 sub.prop(ccam, "aperture_rotation", text="Rotation")
230 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
232 bl_context = "material"
233 bl_options = {'HIDE_HEADER'}
236 def poll(cls, context):
237 return (context.material or context.object) and CyclesButtonsPanel.poll(context)
239 def draw(self, context):
242 mat = context.material
244 slot = context.material_slot
245 space = context.space_data
250 row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
252 col = row.column(align=True)
253 col.operator("object.material_slot_add", icon='ZOOMIN', text="")
254 col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
256 col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
258 if ob.mode == 'EDIT':
259 row = layout.row(align=True)
260 row.operator("object.material_slot_assign", text="Assign")
261 row.operator("object.material_slot_select", text="Select")
262 row.operator("object.material_slot_deselect", text="Deselect")
264 split = layout.split(percentage=0.65)
267 split.template_ID(ob, "active_material", new="material.new")
271 row.prop(slot, "link", text="")
275 split.template_ID(space, "pin_id")
278 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
279 bl_label = "Displacement"
283 def poll(cls, context):
284 return context.mesh or context.curve or context.meta_ball
286 def draw(self, context):
290 curve = context.curve
291 mball = context.meta_ball
300 layout.prop(cdata, "displacement_method", text="Method")
301 layout.prop(cdata, "use_subdivision");
302 layout.prop(cdata, "dicing_rate");
304 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
305 bl_label = "Ray Visibility"
306 bl_context = "object"
307 bl_options = {'DEFAULT_CLOSED'}
310 def poll(cls, context):
312 return ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
314 def draw(self, context):
318 visibility = ob.cycles_visibility
320 split = layout.split()
323 col.prop(visibility, "camera")
324 col.prop(visibility, "diffuse")
325 col.prop(visibility, "glossy")
328 col.prop(visibility, "transmission")
329 col.prop(visibility, "shadow")
331 def find_node(material, nodetype):
332 if material and material.node_tree:
333 ntree = material.node_tree
335 for node in ntree.nodes:
336 if hasattr(node, 'type') and node.type == nodetype:
341 def find_node_input(node, name):
342 for input in node.inputs:
343 if input.name == name:
348 def panel_node_draw(layout, id, output_type, input_name):
350 layout.prop(id, "use_nodes")
355 node = find_node(id, output_type)
357 layout.label(text="No output node.")
359 input = find_node_input(node, input_name)
360 layout.template_node_view(ntree, node, input);
362 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
367 def poll(cls, context):
368 return context.lamp and CyclesButtonsPanel.poll(context)
370 def draw(self, context):
374 panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Surface')
376 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
381 def poll(cls, context):
382 return context.world and CyclesButtonsPanel.poll(context)
384 def draw(self, context):
388 panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Surface')
390 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
395 def poll(cls, context):
396 return context.world and CyclesButtonsPanel.poll(context)
398 def draw(self, context):
400 layout.active = False
403 panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Volume')
405 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
407 bl_context = "material"
410 def poll(cls, context):
411 return context.material and CyclesButtonsPanel.poll(context)
413 def draw(self, context):
416 mat = context.material
417 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface')
419 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
421 bl_context = "material"
424 def poll(cls, context):
425 return context.material and CyclesButtonsPanel.poll(context)
427 def draw(self, context):
429 layout.active = False
431 mat = context.material
432 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
434 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
435 bl_label = "Displacement"
436 bl_context = "material"
439 def poll(cls, context):
440 return context.material and CyclesButtonsPanel.poll(context)
442 def draw(self, context):
445 mat = context.material
446 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
448 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
449 bl_label = "Settings"
450 bl_context = "material"
451 bl_options = {'DEFAULT_CLOSED'}
454 def poll(cls, context):
455 # return context.material and CyclesButtonsPanel.poll(context)
458 def draw(self, context):
461 mat = context.material
464 row.label(text="Light Group:")
465 row.prop(mat, "light_group", text="")
467 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
469 bl_context = "texture"
470 bl_options = {'HIDE_HEADER'}
471 COMPAT_ENGINES = {'CYCLES'}
473 def draw(self, context):
476 tex = context.texture
477 space = context.space_data
478 pin_id = space.pin_id
479 use_pin_id = space.use_pin_id;
480 user = context.texture_user
481 node = context.texture_node
483 if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
487 layout.template_texture_user()
492 split = layout.split(percentage=0.65)
496 col.template_ID(space, "pin_id")
498 col.template_ID(user, "texture", new="texture.new")
502 row.prop(tex, "use_nodes", icon="NODETREE", text="")
505 if not tex.use_nodes:
506 split = layout.split(percentage=0.2)
507 split.label(text="Type:")
508 split.prop(tex, "type", text="")
510 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
512 bl_context = "texture"
515 def poll(cls, context):
516 tex = context.texture
517 return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
519 def draw(self, context):
522 tex = context.texture
523 panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
525 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
527 bl_context = "texture"
530 def poll(cls, context):
531 node = context.texture_node
532 return node and CyclesButtonsPanel.poll(context)
534 def draw(self, context):
537 node = context.texture_node
539 layout.template_node_view(ntree, node, None)
541 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
543 bl_context = "texture"
546 def poll(cls, context):
547 tex = context.texture
548 node = context.texture_node
549 return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
551 def draw(self, context):
553 layout.label("Texture coordinate mapping goes here.");
554 layout.label("Translate, rotate, scale, projection, XYZ.")
556 class CyclesTexture_PT_color(CyclesButtonsPanel, Panel):
558 bl_context = "texture"
561 def poll(cls, context):
562 tex = context.texture
563 node = context.texture_node
564 return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
566 def draw(self, context):
568 layout.label("Color modification options go here.");
569 layout.label("Ramp, brightness, contrast, saturation.")
571 def draw_device(self, context):
572 scene = context.scene
575 if scene.render.engine == "CYCLES":
576 cscene = scene.cycles
578 available_devices = engine.available_devices()
579 available_cuda = 'cuda' in available_devices
580 available_opencl = 'opencl' in available_devices
582 if available_cuda or available_opencl:
583 layout.prop(cscene, "device")
584 if cscene.device == 'GPU' and available_cuda and available_opencl:
585 layout.prop(cscene, "gpu_type")
586 if cscene.device == 'CPU' and engine.with_osl():
587 layout.prop(cscene, "shading_system")
589 def draw_pause(self, context):
591 scene = context.scene
593 if scene.render.engine == "CYCLES":
594 view = context.space_data
596 if view.viewport_shade == "RENDERED":
597 cscene = scene.cycles
598 layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
602 bpy.types.RENDER_PT_render,
603 bpy.types.RENDER_PT_output,
604 bpy.types.RENDER_PT_encoding,
605 bpy.types.RENDER_PT_dimensions,
606 bpy.types.RENDER_PT_stamp,
607 bpy.types.WORLD_PT_context_world,
608 bpy.types.DATA_PT_context_mesh,
609 bpy.types.DATA_PT_context_camera,
610 bpy.types.DATA_PT_context_lamp,
611 bpy.types.DATA_PT_texture_space,
612 bpy.types.DATA_PT_curve_texture_space,
613 bpy.types.DATA_PT_mball_texture_space,
614 bpy.types.DATA_PT_vertex_groups,
615 bpy.types.DATA_PT_shape_keys,
616 bpy.types.DATA_PT_uv_texture,
617 bpy.types.DATA_PT_vertex_colors,
618 bpy.types.DATA_PT_camera,
619 bpy.types.DATA_PT_camera_display,
620 bpy.types.DATA_PT_custom_props_mesh,
621 bpy.types.DATA_PT_custom_props_camera,
622 bpy.types.DATA_PT_custom_props_lamp,
623 bpy.types.TEXTURE_PT_clouds,
624 bpy.types.TEXTURE_PT_wood,
625 bpy.types.TEXTURE_PT_marble,
626 bpy.types.TEXTURE_PT_magic,
627 bpy.types.TEXTURE_PT_blend,
628 bpy.types.TEXTURE_PT_stucci,
629 bpy.types.TEXTURE_PT_image,
630 bpy.types.TEXTURE_PT_image_sampling,
631 bpy.types.TEXTURE_PT_image_mapping,
632 bpy.types.TEXTURE_PT_musgrave,
633 bpy.types.TEXTURE_PT_voronoi,
634 bpy.types.TEXTURE_PT_distortednoise,
635 bpy.types.TEXTURE_PT_voxeldata,
636 bpy.types.TEXTURE_PT_pointdensity,
637 bpy.types.TEXTURE_PT_pointdensity_turbulence]
640 bpy.types.RENDER_PT_render.append(draw_device)
641 bpy.types.VIEW3D_HT_header.append(draw_pause)
643 for panel in get_panels():
644 panel.COMPAT_ENGINES.add('CYCLES')
647 bpy.types.RENDER_PT_render.remove(draw_device)
648 bpy.types.VIEW3D_HT_header.remove(draw_pause)
650 for panel in get_panels():
651 panel.COMPAT_ENGINES.remove('CYCLES')