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.
23 from bpy.types import Panel, Menu
25 from . import enums, engine
28 class CYCLES_MT_integrator_presets(Menu):
29 bl_label = "Integrator Presets"
30 preset_subdir = "cycles/integrator"
31 preset_operator = "script.execute_preset"
32 COMPAT_ENGINES = {'CYCLES'}
33 draw = Menu.draw_preset
36 class CyclesButtonsPanel():
37 bl_space_type = "PROPERTIES"
38 bl_region_type = "WINDOW"
42 def poll(cls, context):
43 rd = context.scene.render
44 return rd.engine == 'CYCLES'
47 class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
48 bl_label = "Integrator"
49 bl_options = {'DEFAULT_CLOSED'}
51 def draw(self, context):
57 row = layout.row(align=True)
58 row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
59 row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
60 row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
62 split = layout.split()
65 sub = col.column(align=True)
66 sub.label(text="Samples:")
67 sub.prop(cscene, "samples", text="Render")
68 sub.prop(cscene, "preview_samples", text="Preview")
69 sub.prop(cscene, "seed")
71 sub = col.column(align=True)
72 sub.label("Transparency:")
73 sub.prop(cscene, "transparent_max_bounces", text="Max")
74 sub.prop(cscene, "transparent_min_bounces", text="Min")
75 sub.prop(cscene, "use_transparent_shadows", text="Shadows")
79 sub = col.column(align=True)
80 sub.label(text="Bounces:")
81 sub.prop(cscene, "max_bounces", text="Max")
82 sub.prop(cscene, "min_bounces", text="Min")
84 sub = col.column(align=True)
85 sub.label(text="Light Paths:")
86 sub.prop(cscene, "diffuse_bounces", text="Diffuse")
87 sub.prop(cscene, "glossy_bounces", text="Glossy")
88 sub.prop(cscene, "transmission_bounces", text="Transmission")
89 sub.prop(cscene, "no_caustics")
92 #row.prop(cscene, "blur_caustics")
93 #row.active = not cscene.no_caustics
96 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
99 def draw(self, context):
102 scene = context.scene
103 cscene = scene.cycles
105 split = layout.split()
108 col.prop(cscene, "film_exposure")
109 col.prop(cscene, "film_transparent")
112 sub = col.column(align=True)
113 sub.prop(cscene, "filter_type", text="")
114 if cscene.filter_type != 'BOX':
115 sub.prop(cscene, "filter_width", text="Width")
118 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
119 bl_label = "Performance"
120 bl_options = {'DEFAULT_CLOSED'}
122 def draw(self, context):
125 scene = context.scene
127 cscene = scene.cycles
129 split = layout.split()
131 col = split.column(align=True)
133 col.label(text="Threads:")
134 col.row().prop(rd, "threads_mode", expand=True)
136 sub.enabled = rd.threads_mode == 'FIXED'
137 sub.prop(rd, "threads")
139 sub = col.column(align=True)
140 sub.label(text="Tiles:")
141 sub.prop(cscene, "debug_tile_size")
142 sub.prop(cscene, "debug_min_size")
146 sub = col.column(align=True)
147 sub.label(text="Acceleration structure:")
148 sub.prop(cscene, "debug_bvh_type", text="")
149 sub.prop(cscene, "debug_use_spatial_splits")
150 sub.prop(cscene, "use_cache")
153 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
155 bl_options = {'DEFAULT_CLOSED'}
156 COMPAT_ENGINES = {'BLENDER_RENDER'}
158 def draw(self, context):
161 scene = context.scene
165 row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
167 col = row.column(align=True)
168 col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
169 col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
172 rl = rd.layers.active
174 row.prop(rd, "use_single_layer", text="", icon_only=True)
176 split = layout.split()
179 col.prop(scene, "layers", text="Scene")
180 col.label(text="Material:")
181 col.prop(rl, "material_override", text="")
184 col.prop(rl, "layers", text="Layer")
185 col.label(text="Mask Layers:")
186 col.prop(rl, "layers_zmask", text="")
188 split = layout.split()
191 col.label(text="Passes:")
192 col.prop(rl, "use_pass_combined")
193 col.prop(rl, "use_pass_z")
194 col.prop(rl, "use_pass_normal")
195 col.prop(rl, "use_pass_object_index")
196 col.prop(rl, "use_pass_material_index")
197 col.prop(rl, "use_pass_emit")
198 col.prop(rl, "use_pass_environment")
202 col.label(text="Diffuse:")
203 row = col.row(align=True)
204 row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
205 row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
206 row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
207 col.label(text="Glossy:")
208 row = col.row(align=True)
209 row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
210 row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
211 row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
212 col.label(text="Transmission:")
213 row = col.row(align=True)
214 row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
215 row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
216 row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
219 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
220 bl_label = "Post Processing"
221 bl_options = {'DEFAULT_CLOSED'}
223 def draw(self, context):
226 rd = context.scene.render
228 split = layout.split()
231 col.prop(rd, "use_compositing")
232 col.prop(rd, "use_sequencer")
235 col.prop(rd, "dither_intensity", text="Dither", slider=True)
238 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
239 bl_label = "Depth of Field"
243 def poll(cls, context):
244 return context.camera and CyclesButtonsPanel.poll(context)
246 def draw(self, context):
252 split = layout.split()
256 col.prop(cam, "dof_object", text="")
259 sub.active = cam.dof_object is None
260 sub.prop(cam, "dof_distance", text="Distance")
264 col.label("Aperture:")
265 col.prop(ccam, "aperture_size", text="Size")
267 sub = col.column(align=True)
268 sub.prop(ccam, "aperture_blades", text="Blades")
269 sub.prop(ccam, "aperture_rotation", text="Rotation")
272 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
274 bl_context = "material"
275 bl_options = {'HIDE_HEADER'}
278 def poll(cls, context):
279 return (context.material or context.object) and CyclesButtonsPanel.poll(context)
281 def draw(self, context):
284 mat = context.material
286 slot = context.material_slot
287 space = context.space_data
292 row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
294 col = row.column(align=True)
295 col.operator("object.material_slot_add", icon='ZOOMIN', text="")
296 col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
298 col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
300 if ob.mode == 'EDIT':
301 row = layout.row(align=True)
302 row.operator("object.material_slot_assign", text="Assign")
303 row.operator("object.material_slot_select", text="Select")
304 row.operator("object.material_slot_deselect", text="Deselect")
306 split = layout.split(percentage=0.65)
309 split.template_ID(ob, "active_material", new="material.new")
313 row.prop(slot, "link", text="")
317 split.template_ID(space, "pin_id")
321 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
322 bl_label = "Displacement"
326 def poll(cls, context):
327 if CyclesButtonsPanel.poll(context):
328 if context.mesh or context.curve or context.meta_ball:
329 if context.scene.cycles.feature_set == 'EXPERIMENTAL':
334 def draw(self, context):
338 curve = context.curve
339 mball = context.meta_ball
348 layout.prop(cdata, "displacement_method", text="Method")
349 layout.prop(cdata, "use_subdivision")
350 layout.prop(cdata, "dicing_rate")
353 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
354 bl_label = "Ray Visibility"
355 bl_context = "object"
356 bl_options = {'DEFAULT_CLOSED'}
359 def poll(cls, context):
361 return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'} # todo: 'LAMP'
363 def draw(self, context):
367 visibility = ob.cycles_visibility
369 flow = layout.column_flow()
371 flow.prop(visibility, "camera")
372 flow.prop(visibility, "diffuse")
373 flow.prop(visibility, "glossy")
374 flow.prop(visibility, "transmission")
375 flow.prop(visibility, "shadow")
378 def find_node(material, nodetype):
379 if material and material.node_tree:
380 ntree = material.node_tree
382 for node in ntree.nodes:
383 if getattr(node, "type", None) == nodetype:
389 def find_node_input(node, name):
390 for input in node.inputs:
391 if input.name == name:
397 def panel_node_draw(layout, id_data, output_type, input_name):
398 if not id_data.node_tree:
399 layout.prop(id_data, "use_nodes", icon='NODETREE')
402 ntree = id_data.node_tree
404 node = find_node(id_data, output_type)
406 layout.label(text="No output node.")
408 input = find_node_input(node, input_name)
409 layout.template_node_view(ntree, node, input)
414 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
419 def poll(cls, context):
420 return context.lamp and CyclesButtonsPanel.poll(context)
422 def draw(self, context):
428 layout.prop(lamp, "type", expand=True)
430 split = layout.split()
431 col = split.column(align=True)
433 if lamp.type in {'POINT', 'SUN', 'SPOT'}:
434 col.prop(lamp, "shadow_soft_size", text="Size")
435 elif lamp.type == 'AREA':
436 col.prop(lamp, "shape", text="")
437 sub = col.column(align=True)
439 if lamp.shape == 'SQUARE':
440 sub.prop(lamp, "size")
441 elif lamp.shape == 'RECTANGLE':
442 sub.prop(lamp, "size", text="Size X")
443 sub.prop(lamp, "size_y", text="Size Y")
446 col.prop(clamp, "cast_shadow")
448 if lamp.type == 'SPOT':
449 layout.label(text="Not supported, interpreted as point lamp.")
450 elif lamp.type == 'HEMI':
451 layout.label(text="Not supported, interpreted as sun lamp.")
454 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
459 def poll(cls, context):
460 return context.lamp and CyclesButtonsPanel.poll(context)
462 def draw(self, context):
466 if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
467 layout.prop(lamp, "color")
470 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
475 def poll(cls, context):
476 return context.world and CyclesButtonsPanel.poll(context)
478 def draw(self, context):
481 world = context.world
483 if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
484 layout.prop(world, "horizon_color", text="Color")
487 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
488 bl_label = "Settings"
490 bl_options = {'DEFAULT_CLOSED'}
493 def poll(cls, context):
494 return context.world and CyclesButtonsPanel.poll(context)
496 def draw(self, context):
499 world = context.world
500 cworld = world.cycles
502 col = layout.column()
504 col.prop(cworld, "sample_as_light")
506 row.active = cworld.sample_as_light
507 row.prop(cworld, "sample_map_resolution")
510 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
513 bl_options = {'DEFAULT_CLOSED'}
516 def poll(cls, context):
517 # world = context.world
518 # world and world.node_tree and CyclesButtonsPanel.poll(context)
521 def draw(self, context):
523 layout.active = False
525 world = context.world
526 panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
529 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
531 bl_context = "material"
534 def poll(cls, context):
535 return context.material and CyclesButtonsPanel.poll(context)
537 def draw(self, context):
540 mat = context.material
541 if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
542 layout.prop(mat, "diffuse_color")
545 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
547 bl_context = "material"
548 bl_options = {'DEFAULT_CLOSED'}
551 def poll(cls, context):
552 # mat = context.material
553 # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
556 def draw(self, context):
558 layout.active = False
560 mat = context.material
563 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
565 layout.prop(cmat, "homogeneous_volume")
568 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
569 bl_label = "Displacement"
570 bl_context = "material"
573 def poll(cls, context):
574 mat = context.material
575 return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
577 def draw(self, context):
580 mat = context.material
581 panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
584 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
585 bl_label = "Settings"
586 bl_context = "material"
587 bl_options = {'DEFAULT_CLOSED'}
590 def poll(cls, context):
591 return context.material and CyclesButtonsPanel.poll(context)
593 def draw(self, context):
596 mat = context.material
599 split = layout.split()
602 col.prop(mat, "diffuse_color", text="Viewport Color")
605 col.prop(cmat, "sample_as_light")
606 col.prop(mat, "pass_index")
609 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
611 bl_context = "texture"
612 bl_options = {'HIDE_HEADER'}
613 COMPAT_ENGINES = {'CYCLES'}
615 def draw(self, context):
618 tex = context.texture
619 space = context.space_data
620 pin_id = space.pin_id
621 use_pin_id = space.use_pin_id
622 user = context.texture_user
623 # node = context.texture_node
625 if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
629 layout.template_texture_user()
634 split = layout.split(percentage=0.65)
638 col.template_ID(space, "pin_id")
640 col.template_ID(user, "texture", new="texture.new")
643 split = layout.split(percentage=0.2)
644 split.label(text="Type:")
645 split.prop(tex, "type", text="")
648 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
650 bl_context = "texture"
653 def poll(cls, context):
654 tex = context.texture
655 return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
657 def draw(self, context):
660 tex = context.texture
661 panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
664 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
666 bl_context = "texture"
669 def poll(cls, context):
670 node = context.texture_node
671 return node and CyclesButtonsPanel.poll(context)
673 def draw(self, context):
676 node = context.texture_node
678 layout.template_node_view(ntree, node, None)
681 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
683 bl_context = "texture"
686 def poll(cls, context):
687 tex = context.texture
688 node = context.texture_node
689 return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
691 def draw(self, context):
694 # tex = context.texture
695 node = context.texture_node
697 mapping = node.texture_mapping
701 row.column().prop(mapping, "location")
702 row.column().prop(mapping, "rotation")
703 row.column().prop(mapping, "scale")
705 layout.label(text="Projection:")
708 row.prop(mapping, "mapping_x", text="")
709 row.prop(mapping, "mapping_y", text="")
710 row.prop(mapping, "mapping_z", text="")
713 class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
715 bl_context = "texture"
716 bl_options = {'DEFAULT_CLOSED'}
719 def poll(cls, context):
720 # tex = context.texture
721 # node = context.texture_node
723 #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
725 def draw(self, context):
728 # tex = context.texture
729 node = context.texture_node
731 mapping = node.color_mapping
733 split = layout.split()
736 col.label(text="Blend:")
737 col.prop(mapping, "blend_type", text="")
738 col.prop(mapping, "blend_factor", text="Factor")
739 col.prop(mapping, "blend_color", text="")
742 col.label(text="Adjust:")
743 col.prop(mapping, "brightness")
744 col.prop(mapping, "contrast")
745 col.prop(mapping, "saturation")
749 layout.prop(mapping, "use_color_ramp", text="Ramp")
750 if mapping.use_color_ramp:
751 layout.template_color_ramp(mapping, "color_ramp", expand=True)
754 def draw_device(self, context):
755 scene = context.scene
758 if scene.render.engine == 'CYCLES':
759 cscene = scene.cycles
761 layout.prop(cscene, "feature_set")
763 device_type = context.user_preferences.system.compute_device_type
764 if device_type == 'CUDA':
765 layout.prop(cscene, "device")
766 elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
767 layout.prop(cscene, "device")
770 def draw_pause(self, context):
772 scene = context.scene
774 if scene.render.engine == "CYCLES":
775 view = context.space_data
777 if view.viewport_shade == 'RENDERED':
778 cscene = scene.cycles
779 layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
784 bpy.types.RENDER_PT_render,
785 bpy.types.RENDER_PT_output,
786 bpy.types.RENDER_PT_encoding,
787 bpy.types.RENDER_PT_dimensions,
788 bpy.types.RENDER_PT_stamp,
789 bpy.types.SCENE_PT_scene,
790 bpy.types.SCENE_PT_audio,
791 bpy.types.SCENE_PT_unit,
792 bpy.types.SCENE_PT_keying_sets,
793 bpy.types.SCENE_PT_keying_set_paths,
794 bpy.types.SCENE_PT_physics,
795 bpy.types.WORLD_PT_context_world,
796 bpy.types.DATA_PT_context_mesh,
797 bpy.types.DATA_PT_context_camera,
798 bpy.types.DATA_PT_context_lamp,
799 bpy.types.DATA_PT_texture_space,
800 bpy.types.DATA_PT_curve_texture_space,
801 bpy.types.DATA_PT_mball_texture_space,
802 bpy.types.DATA_PT_vertex_groups,
803 bpy.types.DATA_PT_shape_keys,
804 bpy.types.DATA_PT_uv_texture,
805 bpy.types.DATA_PT_vertex_colors,
806 bpy.types.DATA_PT_camera,
807 bpy.types.DATA_PT_camera_display,
808 bpy.types.DATA_PT_lens,
809 bpy.types.DATA_PT_custom_props_mesh,
810 bpy.types.DATA_PT_custom_props_camera,
811 bpy.types.DATA_PT_custom_props_lamp,
812 bpy.types.TEXTURE_PT_clouds,
813 bpy.types.TEXTURE_PT_wood,
814 bpy.types.TEXTURE_PT_marble,
815 bpy.types.TEXTURE_PT_magic,
816 bpy.types.TEXTURE_PT_blend,
817 bpy.types.TEXTURE_PT_stucci,
818 bpy.types.TEXTURE_PT_image,
819 bpy.types.TEXTURE_PT_image_sampling,
820 bpy.types.TEXTURE_PT_image_mapping,
821 bpy.types.TEXTURE_PT_musgrave,
822 bpy.types.TEXTURE_PT_voronoi,
823 bpy.types.TEXTURE_PT_distortednoise,
824 bpy.types.TEXTURE_PT_voxeldata,
825 bpy.types.TEXTURE_PT_pointdensity,
826 bpy.types.TEXTURE_PT_pointdensity_turbulence,
827 bpy.types.PARTICLE_PT_context_particles,
828 bpy.types.PARTICLE_PT_emission,
829 bpy.types.PARTICLE_PT_hair_dynamics,
830 bpy.types.PARTICLE_PT_cache,
831 bpy.types.PARTICLE_PT_velocity,
832 bpy.types.PARTICLE_PT_rotation,
833 bpy.types.PARTICLE_PT_physics,
834 bpy.types.PARTICLE_PT_boidbrain,
835 bpy.types.PARTICLE_PT_render,
836 bpy.types.PARTICLE_PT_draw,
837 bpy.types.PARTICLE_PT_children,
838 bpy.types.PARTICLE_PT_field_weights,
839 bpy.types.PARTICLE_PT_force_fields,
840 bpy.types.PARTICLE_PT_vertexgroups,
841 bpy.types.PARTICLE_PT_custom_props,
846 bpy.types.RENDER_PT_render.append(draw_device)
847 bpy.types.VIEW3D_HT_header.append(draw_pause)
849 for panel in get_panels():
850 panel.COMPAT_ENGINES.add('CYCLES')
854 bpy.types.RENDER_PT_render.remove(draw_device)
855 bpy.types.VIEW3D_HT_header.remove(draw_pause)
857 for panel in get_panels():
858 panel.COMPAT_ENGINES.remove('CYCLES')