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("Transparency:")
68 sub.prop(cscene, "transparent_max_bounces", text="Max")
69 sub.prop(cscene, "transparent_min_bounces", text="Min")
70 sub.prop(cscene, "use_transparent_shadows", text="Shadows")
71 sub.prop(cscene, "no_caustics")
75 sub = col.column(align=True)
76 sub.label(text="Bounces:")
77 sub.prop(cscene, "max_bounces", text="Max")
78 sub.prop(cscene, "min_bounces", text="Min")
80 sub = col.column(align=True)
81 sub.label(text="Light Paths:")
82 sub.prop(cscene, "diffuse_bounces", text="Diffuse")
83 sub.prop(cscene, "glossy_bounces", text="Glossy")
84 sub.prop(cscene, "transmission_bounces", text="Transmission")
87 #row.prop(cscene, "blur_caustics")
88 #row.active = not cscene.no_caustics
90 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
93 def draw(self, context):
99 split = layout.split()
101 col = split.column();
102 col.prop(cscene, "film_exposure")
103 col.prop(cscene, "film_transparent")
106 sub = col.column(align=True)
107 sub.prop(cscene, "filter_type", text="")
108 if cscene.filter_type != 'BOX':
109 sub.prop(cscene, "filter_width", text="Width")
111 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
112 bl_label = "Performance"
113 bl_options = {'DEFAULT_CLOSED'}
115 def draw(self, context):
118 scene = context.scene
120 cscene = scene.cycles
122 split = layout.split()
124 col = split.column(align=True)
126 col.label(text="Threads:")
127 col.row().prop(rd, "threads_mode", expand=True)
129 sub.enabled = rd.threads_mode == 'FIXED'
130 sub.prop(rd, "threads")
132 sub = col.column(align=True)
133 sub.label(text="Tiles:")
134 sub.prop(cscene, "debug_tile_size")
135 sub.prop(cscene, "debug_min_size")
139 sub = col.column(align=True)
140 sub.label(text="Acceleration structure:")
141 sub.prop(cscene, "debug_bvh_type", text="")
142 sub.prop(cscene, "debug_use_spatial_splits")
144 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
146 bl_options = {'DEFAULT_CLOSED'}
147 COMPAT_ENGINES = {'BLENDER_RENDER'}
149 def draw(self, context):
152 scene = context.scene
156 # row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
158 # col = row.column(align=True)
159 # col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
160 # col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
163 # rl = rd.layers.active
166 #row.prop(rd, "use_single_layer", text="", icon_only=True)
168 split = layout.split()
171 col.prop(scene, "layers", text="Scene")
174 col.prop(rl, "layers", text="Layer")
178 layout.prop(rl, "material_override", text="Material")
180 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
181 bl_label = "Post Processing"
182 bl_options = {'DEFAULT_CLOSED'}
184 def draw(self, context):
187 rd = context.scene.render
189 split = layout.split()
192 col.prop(rd, "use_compositing")
193 col.prop(rd, "use_sequencer")
196 col.prop(rd, "dither_intensity", text="Dither", slider=True)
198 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
199 bl_label = "Depth of Field"
203 def poll(cls, context):
204 return context.camera and CyclesButtonsPanel.poll(context)
206 def draw(self, context):
212 split = layout.split()
216 col.prop(cam, "dof_object", text="")
219 sub.active = cam.dof_object is None
220 sub.prop(cam, "dof_distance", text="Distance")
224 col.label("Aperture:")
225 col.prop(ccam, "aperture_size", text="Size")
227 sub = col.column(align=True)
228 sub.prop(ccam, "aperture_blades", text="Blades")
229 sub.prop(ccam, "aperture_rotation", text="Rotation")
231 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
233 bl_context = "material"
234 bl_options = {'HIDE_HEADER'}
237 def poll(cls, context):
238 return (context.material or context.object) and CyclesButtonsPanel.poll(context)
240 def draw(self, context):
243 mat = context.material
245 slot = context.material_slot
246 space = context.space_data
251 row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
253 col = row.column(align=True)
254 col.operator("object.material_slot_add", icon='ZOOMIN', text="")
255 col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
257 col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
259 if ob.mode == 'EDIT':
260 row = layout.row(align=True)
261 row.operator("object.material_slot_assign", text="Assign")
262 row.operator("object.material_slot_select", text="Select")
263 row.operator("object.material_slot_deselect", text="Deselect")
265 split = layout.split(percentage=0.65)
268 split.template_ID(ob, "active_material", new="material.new")
272 row.prop(slot, "link", text="")
276 split.template_ID(space, "pin_id")
279 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
280 bl_label = "Displacement"
284 def poll(cls, context):
285 return context.mesh or context.curve or context.meta_ball
287 def draw(self, context):
291 curve = context.curve
292 mball = context.meta_ball
301 layout.prop(cdata, "displacement_method", text="Method")
302 layout.prop(cdata, "use_subdivision");
303 layout.prop(cdata, "dicing_rate");
305 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
306 bl_label = "Ray Visibility"
307 bl_context = "object"
308 bl_options = {'DEFAULT_CLOSED'}
311 def poll(cls, context):
313 return ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
315 def draw(self, context):
319 visibility = ob.cycles_visibility
321 split = layout.split()
324 col.prop(visibility, "camera")
325 col.prop(visibility, "diffuse")
326 col.prop(visibility, "glossy")
329 col.prop(visibility, "transmission")
330 col.prop(visibility, "shadow")
332 def find_node(material, nodetype):
333 if material and material.node_tree:
334 ntree = material.node_tree
336 for node in ntree.nodes:
337 if hasattr(node, 'type') and node.type == nodetype:
342 def find_node_input(node, name):
343 for input in node.inputs:
344 if input.name == name:
349 def panel_node_draw(layout, id, output_type, input_name):
351 layout.prop(id, "use_nodes")
356 node = find_node(id, output_type)
358 layout.label(text="No output node.")
360 input = find_node_input(node, input_name)
361 layout.template_node_view(ntree, node, input);
363 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
366 bl_options = {'DEFAULT_CLOSED'}
369 def poll(cls, context):
370 return context.lamp and CyclesButtonsPanel.poll(context)
372 def draw(self, context):
378 layout.prop(lamp, "type", expand=True)
380 split = layout.split()
381 col = split.column(align=True)
383 if lamp.type in ('POINT', 'SUN', 'SPOT'):
384 col.prop(lamp, "shadow_soft_size", text="Size")
385 elif lamp.type == 'AREA':
386 col.prop(lamp, "shape", text="")
387 sub = col.column(align=True)
389 if lamp.shape == 'SQUARE':
390 sub.prop(lamp, "size")
391 elif lamp.shape == 'RECTANGLE':
392 sub.prop(lamp, "size", text="Size X")
393 sub.prop(lamp, "size_y", text="Size Y")
396 col.prop(clamp, "cast_shadow")
398 if lamp.type == 'SPOT':
399 layout.label(text="Not supported, interpreted as point lamp.")
400 elif lamp.type == 'HEMI':
401 layout.label(text="Not supported, interpreted as sun lamp.")
403 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
408 def poll(cls, context):
409 return context.lamp and CyclesButtonsPanel.poll(context)
411 def draw(self, context):
415 panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Surface')
417 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
422 def poll(cls, context):
423 return context.world and CyclesButtonsPanel.poll(context)
425 def draw(self, context):
429 panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Surface')
431 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
436 def poll(cls, context):
437 return context.world and CyclesButtonsPanel.poll(context)
439 def draw(self, context):
441 layout.active = False
443 world = context.world
444 panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
446 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
448 bl_context = "material"
451 def poll(cls, context):
452 return context.material and CyclesButtonsPanel.poll(context)
454 def draw(self, context):
457 mat = context.material
458 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface')
460 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
462 bl_context = "material"
465 def poll(cls, context):
466 return context.material and CyclesButtonsPanel.poll(context)
468 def draw(self, context):
470 layout.active = False
472 mat = context.material
475 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
477 layout.prop(cmat, "homogeneous_volume")
479 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
480 bl_label = "Displacement"
481 bl_context = "material"
484 def poll(cls, context):
485 return context.material and CyclesButtonsPanel.poll(context)
487 def draw(self, context):
490 mat = context.material
491 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
493 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
494 bl_label = "Settings"
495 bl_context = "material"
496 bl_options = {'DEFAULT_CLOSED'}
499 def poll(cls, context):
500 return context.material and CyclesButtonsPanel.poll(context)
502 def draw(self, context):
505 mat = context.material
508 split = layout.split()
511 col.prop(mat, "diffuse_color", text="Viewport Color")
514 col.prop(cmat, "sample_as_light")
516 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
518 bl_context = "texture"
519 bl_options = {'HIDE_HEADER'}
520 COMPAT_ENGINES = {'CYCLES'}
522 def draw(self, context):
525 tex = context.texture
526 space = context.space_data
527 pin_id = space.pin_id
528 use_pin_id = space.use_pin_id;
529 user = context.texture_user
530 node = context.texture_node
532 if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
536 layout.template_texture_user()
541 split = layout.split(percentage=0.65)
545 col.template_ID(space, "pin_id")
547 col.template_ID(user, "texture", new="texture.new")
551 row.prop(tex, "use_nodes", icon="NODETREE", text="")
554 if not tex.use_nodes:
555 split = layout.split(percentage=0.2)
556 split.label(text="Type:")
557 split.prop(tex, "type", text="")
559 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
561 bl_context = "texture"
564 def poll(cls, context):
565 tex = context.texture
566 return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
568 def draw(self, context):
571 tex = context.texture
572 panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
574 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
576 bl_context = "texture"
579 def poll(cls, context):
580 node = context.texture_node
581 return node and CyclesButtonsPanel.poll(context)
583 def draw(self, context):
586 node = context.texture_node
588 layout.template_node_view(ntree, node, None)
590 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
592 bl_context = "texture"
595 def poll(cls, context):
596 tex = context.texture
597 node = context.texture_node
598 return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
600 def draw(self, context):
602 layout.label("Texture coordinate mapping goes here.");
603 layout.label("Translate, rotate, scale, projection, XYZ.")
605 class CyclesTexture_PT_color(CyclesButtonsPanel, Panel):
607 bl_context = "texture"
610 def poll(cls, context):
611 tex = context.texture
612 node = context.texture_node
613 return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
615 def draw(self, context):
617 layout.label("Color modification options go here.");
618 layout.label("Ramp, brightness, contrast, saturation.")
620 def draw_device(self, context):
621 scene = context.scene
624 if scene.render.engine == "CYCLES":
625 cscene = scene.cycles
627 available_devices = engine.available_devices()
628 available_cuda = 'cuda' in available_devices
629 available_opencl = 'opencl' in available_devices
631 if available_cuda or available_opencl:
632 layout.prop(cscene, "device")
633 if cscene.device == 'GPU' and available_cuda and available_opencl:
634 layout.prop(cscene, "gpu_type")
635 if cscene.device == 'CPU' and engine.with_osl():
636 layout.prop(cscene, "shading_system")
638 def draw_pause(self, context):
640 scene = context.scene
642 if scene.render.engine == "CYCLES":
643 view = context.space_data
645 if view.viewport_shade == "RENDERED":
646 cscene = scene.cycles
647 layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
651 bpy.types.RENDER_PT_render,
652 bpy.types.RENDER_PT_output,
653 bpy.types.RENDER_PT_encoding,
654 bpy.types.RENDER_PT_dimensions,
655 bpy.types.RENDER_PT_stamp,
656 bpy.types.WORLD_PT_context_world,
657 bpy.types.DATA_PT_context_mesh,
658 bpy.types.DATA_PT_context_camera,
659 bpy.types.DATA_PT_context_lamp,
660 bpy.types.DATA_PT_texture_space,
661 bpy.types.DATA_PT_curve_texture_space,
662 bpy.types.DATA_PT_mball_texture_space,
663 bpy.types.DATA_PT_vertex_groups,
664 bpy.types.DATA_PT_shape_keys,
665 bpy.types.DATA_PT_uv_texture,
666 bpy.types.DATA_PT_vertex_colors,
667 bpy.types.DATA_PT_camera,
668 bpy.types.DATA_PT_camera_display,
669 bpy.types.DATA_PT_custom_props_mesh,
670 bpy.types.DATA_PT_custom_props_camera,
671 bpy.types.DATA_PT_custom_props_lamp,
672 bpy.types.TEXTURE_PT_clouds,
673 bpy.types.TEXTURE_PT_wood,
674 bpy.types.TEXTURE_PT_marble,
675 bpy.types.TEXTURE_PT_magic,
676 bpy.types.TEXTURE_PT_blend,
677 bpy.types.TEXTURE_PT_stucci,
678 bpy.types.TEXTURE_PT_image,
679 bpy.types.TEXTURE_PT_image_sampling,
680 bpy.types.TEXTURE_PT_image_mapping,
681 bpy.types.TEXTURE_PT_musgrave,
682 bpy.types.TEXTURE_PT_voronoi,
683 bpy.types.TEXTURE_PT_distortednoise,
684 bpy.types.TEXTURE_PT_voxeldata,
685 bpy.types.TEXTURE_PT_pointdensity,
686 bpy.types.TEXTURE_PT_pointdensity_turbulence]
689 bpy.types.RENDER_PT_render.append(draw_device)
690 bpy.types.VIEW3D_HT_header.append(draw_pause)
692 for panel in get_panels():
693 panel.COMPAT_ENGINES.add('CYCLES')
696 bpy.types.RENDER_PT_render.remove(draw_device)
697 bpy.types.VIEW3D_HT_header.remove(draw_pause)
699 for panel in get_panels():
700 panel.COMPAT_ENGINES.remove('CYCLES')