Cycles: shadow pass support. Note that this only takes into account lamps,
[blender.git] / intern / cycles / blender / addon / ui.py
1 #
2 # Copyright 2011, Blender Foundation.
3 #
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.
8 #
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.
13 #
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.
17 #
18
19 # <pep8 compliant>
20
21 import bpy
22
23 from bpy.types import Panel, Menu
24
25 from . import enums, engine
26
27
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
34
35
36 class CyclesButtonsPanel():
37     bl_space_type = "PROPERTIES"
38     bl_region_type = "WINDOW"
39     bl_context = "render"
40
41     @classmethod
42     def poll(cls, context):
43         rd = context.scene.render
44         return rd.engine == 'CYCLES'
45
46
47 class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
48     bl_label = "Integrator"
49     bl_options = {'DEFAULT_CLOSED'}
50
51     def draw(self, context):
52         layout = self.layout
53
54         scene = context.scene
55         cscene = scene.cycles
56
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
61
62         split = layout.split()
63
64         col = split.column()
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")
70
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")
76
77         col = split.column()
78
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")
83
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")
90
91         #row = col.row()
92         #row.prop(cscene, "blur_caustics")
93         #row.active = not cscene.no_caustics
94
95
96 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
97     bl_label = "Film"
98
99     def draw(self, context):
100         layout = self.layout
101
102         scene = context.scene
103         cscene = scene.cycles
104
105         split = layout.split()
106
107         col = split.column()
108         col.prop(cscene, "film_exposure")
109         col.prop(cscene, "film_transparent")
110
111         col = split.column()
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")
116
117
118 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
119     bl_label = "Performance"
120     bl_options = {'DEFAULT_CLOSED'}
121
122     def draw(self, context):
123         layout = self.layout
124
125         scene = context.scene
126         rd = scene.render
127         cscene = scene.cycles
128
129         split = layout.split()
130
131         col = split.column(align=True)
132
133         col.label(text="Threads:")
134         col.row().prop(rd, "threads_mode", expand=True)
135         sub = col.column()
136         sub.enabled = rd.threads_mode == 'FIXED'
137         sub.prop(rd, "threads")
138
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")
143
144         col = split.column()
145
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")
151
152
153 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
154     bl_label = "Layers"
155     bl_options = {'DEFAULT_CLOSED'}
156     COMPAT_ENGINES = {'BLENDER_RENDER'}
157
158     def draw(self, context):
159         layout = self.layout
160
161         scene = context.scene
162         rd = scene.render
163
164         row = layout.row()
165         row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
166
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="")
170
171         row = layout.row()
172         rl = rd.layers.active
173         row.prop(rl, "name")
174         row.prop(rd, "use_single_layer", text="", icon_only=True)
175
176         split = layout.split()
177
178         col = split.column()
179         col.prop(scene, "layers", text="Scene")
180         col.label(text="Material:")
181         col.prop(rl, "material_override", text="")
182
183         col = split.column()
184         col.prop(rl, "layers", text="Layer")
185         col.label(text="Mask Layers:")
186         col.prop(rl, "layers_zmask", text="")
187
188         split = layout.split()
189
190         col = split.column()
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")
199         col.prop(rl, "use_pass_ambient_occlusion")
200         col.prop(rl, "use_pass_shadow")
201
202         col = split.column()
203         col.label()
204         col.label(text="Diffuse:")
205         row = col.row(align=True)
206         row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
207         row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
208         row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
209         col.label(text="Glossy:")
210         row = col.row(align=True)
211         row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
212         row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
213         row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
214         col.label(text="Transmission:")
215         row = col.row(align=True)
216         row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
217         row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
218         row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
219
220
221 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
222     bl_label = "Post Processing"
223     bl_options = {'DEFAULT_CLOSED'}
224
225     def draw(self, context):
226         layout = self.layout
227
228         rd = context.scene.render
229
230         split = layout.split()
231
232         col = split.column()
233         col.prop(rd, "use_compositing")
234         col.prop(rd, "use_sequencer")
235
236         col = split.column()
237         col.prop(rd, "dither_intensity", text="Dither", slider=True)
238
239
240 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
241     bl_label = "Depth of Field"
242     bl_context = "data"
243
244     @classmethod
245     def poll(cls, context):
246         return context.camera and CyclesButtonsPanel.poll(context)
247
248     def draw(self, context):
249         layout = self.layout
250
251         cam = context.camera
252         ccam = cam.cycles
253
254         split = layout.split()
255
256         col = split.column()
257         col.label("Focus:")
258         col.prop(cam, "dof_object", text="")
259
260         sub = col.row()
261         sub.active = cam.dof_object is None
262         sub.prop(cam, "dof_distance", text="Distance")
263
264         col = split.column()
265
266         col.label("Aperture:")
267         sub = col.column(align=True)
268         sub.prop(ccam, "aperture_type", text="")
269         if ccam.aperture_type == 'RADIUS':
270             sub.prop(ccam, "aperture_size", text="Size")
271         elif ccam.aperture_type == 'FSTOP':
272             sub.prop(ccam, "aperture_fstop", text="Number")
273
274         sub = col.column(align=True)
275         sub.prop(ccam, "aperture_blades", text="Blades")
276         sub.prop(ccam, "aperture_rotation", text="Rotation")
277
278
279 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
280     bl_label = ""
281     bl_context = "material"
282     bl_options = {'HIDE_HEADER'}
283
284     @classmethod
285     def poll(cls, context):
286         return (context.material or context.object) and CyclesButtonsPanel.poll(context)
287
288     def draw(self, context):
289         layout = self.layout
290
291         mat = context.material
292         ob = context.object
293         slot = context.material_slot
294         space = context.space_data
295
296         if ob:
297             row = layout.row()
298
299             row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
300
301             col = row.column(align=True)
302             col.operator("object.material_slot_add", icon='ZOOMIN', text="")
303             col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
304
305             col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
306
307             if ob.mode == 'EDIT':
308                 row = layout.row(align=True)
309                 row.operator("object.material_slot_assign", text="Assign")
310                 row.operator("object.material_slot_select", text="Select")
311                 row.operator("object.material_slot_deselect", text="Deselect")
312
313         split = layout.split(percentage=0.65)
314
315         if ob:
316             split.template_ID(ob, "active_material", new="material.new")
317             row = split.row()
318
319             if slot:
320                 row.prop(slot, "link", text="")
321             else:
322                 row.label()
323         elif mat:
324             split.template_ID(space, "pin_id")
325             split.separator()
326
327
328 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
329     bl_label = "Displacement"
330     bl_context = "data"
331
332     @classmethod
333     def poll(cls, context):
334         if CyclesButtonsPanel.poll(context):
335             if context.mesh or context.curve or context.meta_ball:
336                 if context.scene.cycles.feature_set == 'EXPERIMENTAL':
337                     return True
338
339         return False
340
341     def draw(self, context):
342         layout = self.layout
343
344         mesh = context.mesh
345         curve = context.curve
346         mball = context.meta_ball
347
348         if mesh:
349             cdata = mesh.cycles
350         elif curve:
351             cdata = curve.cycles
352         elif mball:
353             cdata = mball.cycles
354
355         layout.prop(cdata, "displacement_method", text="Method")
356         layout.prop(cdata, "use_subdivision")
357         layout.prop(cdata, "dicing_rate")
358
359
360 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
361     bl_label = "Ray Visibility"
362     bl_context = "object"
363     bl_options = {'DEFAULT_CLOSED'}
364
365     @classmethod
366     def poll(cls, context):
367         ob = context.object
368         return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}  # todo: 'LAMP'
369
370     def draw(self, context):
371         layout = self.layout
372
373         ob = context.object
374         visibility = ob.cycles_visibility
375
376         flow = layout.column_flow()
377
378         flow.prop(visibility, "camera")
379         flow.prop(visibility, "diffuse")
380         flow.prop(visibility, "glossy")
381         flow.prop(visibility, "transmission")
382         flow.prop(visibility, "shadow")
383
384
385 def find_node(material, nodetype):
386     if material and material.node_tree:
387         ntree = material.node_tree
388
389         for node in ntree.nodes:
390             if getattr(node, "type", None) == nodetype:
391                 return node
392
393     return None
394
395
396 def find_node_input(node, name):
397     for input in node.inputs:
398         if input.name == name:
399             return input
400
401     return None
402
403
404 def panel_node_draw(layout, id_data, output_type, input_name):
405     if not id_data.use_nodes:
406         layout.prop(id_data, "use_nodes", icon='NODETREE')
407         return False
408
409     ntree = id_data.node_tree
410
411     node = find_node(id_data, output_type)
412     if not node:
413         layout.label(text="No output node.")
414     else:
415         input = find_node_input(node, input_name)
416         layout.template_node_view(ntree, node, input)
417
418     return True
419
420
421 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
422     bl_label = "Lamp"
423     bl_context = "data"
424
425     @classmethod
426     def poll(cls, context):
427         return context.lamp and CyclesButtonsPanel.poll(context)
428
429     def draw(self, context):
430         layout = self.layout
431
432         lamp = context.lamp
433         clamp = lamp.cycles
434
435         layout.prop(lamp, "type", expand=True)
436
437         split = layout.split()
438         col = split.column(align=True)
439
440         if lamp.type in {'POINT', 'SUN', 'SPOT'}:
441             col.prop(lamp, "shadow_soft_size", text="Size")
442         elif lamp.type == 'AREA':
443             col.prop(lamp, "shape", text="")
444             sub = col.column(align=True)
445
446             if lamp.shape == 'SQUARE':
447                 sub.prop(lamp, "size")
448             elif lamp.shape == 'RECTANGLE':
449                 sub.prop(lamp, "size", text="Size X")
450                 sub.prop(lamp, "size_y", text="Size Y")
451
452         col = split.column()
453         col.prop(clamp, "cast_shadow")
454
455         if lamp.type == 'SPOT':
456             layout.label(text="Not supported, interpreted as point lamp.")
457         elif lamp.type == 'HEMI':
458             layout.label(text="Not supported, interpreted as sun lamp.")
459
460
461 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
462     bl_label = "Nodes"
463     bl_context = "data"
464
465     @classmethod
466     def poll(cls, context):
467         return context.lamp and CyclesButtonsPanel.poll(context)
468
469     def draw(self, context):
470         layout = self.layout
471
472         lamp = context.lamp
473         if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
474             layout.prop(lamp, "color")
475
476
477 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
478     bl_label = "Surface"
479     bl_context = "world"
480
481     @classmethod
482     def poll(cls, context):
483         return context.world and CyclesButtonsPanel.poll(context)
484
485     def draw(self, context):
486         layout = self.layout
487
488         world = context.world
489
490         if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
491             layout.prop(world, "horizon_color", text="Color")
492
493
494 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
495     bl_label = "Volume"
496     bl_context = "world"
497     bl_options = {'DEFAULT_CLOSED'}
498
499     @classmethod
500     def poll(cls, context):
501         # world = context.world
502         # world and world.node_tree and CyclesButtonsPanel.poll(context)
503         return False
504
505     def draw(self, context):
506         layout = self.layout
507         layout.active = False
508
509         world = context.world
510         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
511
512
513 class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
514     bl_label = "Ambient Occlusion"
515     bl_context = "world"
516
517     @classmethod
518     def poll(cls, context):
519         return context.world and CyclesButtonsPanel.poll(context)
520
521     def draw_header(self, context):
522         light = context.world.light_settings
523         self.layout.prop(light, "use_ambient_occlusion", text="")
524
525     def draw(self, context):
526         layout = self.layout
527         light = context.world.light_settings
528
529         layout.active = light.use_ambient_occlusion
530
531         row = layout.row()
532         row.prop(light, "ao_factor", text="Factor")
533         row.prop(light, "distance", text="Distance")
534
535
536 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
537     bl_label = "Settings"
538     bl_context = "world"
539     bl_options = {'DEFAULT_CLOSED'}
540
541     @classmethod
542     def poll(cls, context):
543         return context.world and CyclesButtonsPanel.poll(context)
544
545     def draw(self, context):
546         layout = self.layout
547
548         world = context.world
549         cworld = world.cycles
550
551         col = layout.column()
552
553         col.prop(cworld, "sample_as_light")
554         row = col.row()
555         row.active = cworld.sample_as_light
556         row.prop(cworld, "sample_map_resolution")
557
558
559 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
560     bl_label = "Surface"
561     bl_context = "material"
562
563     @classmethod
564     def poll(cls, context):
565         return context.material and CyclesButtonsPanel.poll(context)
566
567     def draw(self, context):
568         layout = self.layout
569
570         mat = context.material
571         if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
572             layout.prop(mat, "diffuse_color")
573
574
575 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
576     bl_label = "Volume"
577     bl_context = "material"
578     bl_options = {'DEFAULT_CLOSED'}
579
580     @classmethod
581     def poll(cls, context):
582         # mat = context.material
583         # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
584         return False
585
586     def draw(self, context):
587         layout = self.layout
588         layout.active = False
589
590         mat = context.material
591         cmat = mat.cycles
592
593         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
594
595         layout.prop(cmat, "homogeneous_volume")
596
597
598 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
599     bl_label = "Displacement"
600     bl_context = "material"
601
602     @classmethod
603     def poll(cls, context):
604         mat = context.material
605         return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
606
607     def draw(self, context):
608         layout = self.layout
609
610         mat = context.material
611         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
612
613
614 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
615     bl_label = "Settings"
616     bl_context = "material"
617     bl_options = {'DEFAULT_CLOSED'}
618
619     @classmethod
620     def poll(cls, context):
621         return context.material and CyclesButtonsPanel.poll(context)
622
623     def draw(self, context):
624         layout = self.layout
625
626         mat = context.material
627         cmat = mat.cycles
628
629         split = layout.split()
630
631         col = split.column()
632         col.prop(mat, "diffuse_color", text="Viewport Color")
633
634         col = split.column()
635         col.prop(cmat, "sample_as_light")
636         col.prop(mat, "pass_index")
637
638
639 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
640     bl_label = ""
641     bl_context = "texture"
642     bl_options = {'HIDE_HEADER'}
643     COMPAT_ENGINES = {'CYCLES'}
644
645     def draw(self, context):
646         layout = self.layout
647
648         tex = context.texture
649         space = context.space_data
650         pin_id = space.pin_id
651         use_pin_id = space.use_pin_id
652         user = context.texture_user
653
654         if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
655             pin_id = None
656
657         if not pin_id:
658             layout.template_texture_user()
659
660         if user:
661             layout.separator()
662
663             split = layout.split(percentage=0.65)
664             col = split.column()
665
666             if pin_id:
667                 col.template_ID(space, "pin_id")
668             elif user:
669                 col.template_ID(user, "texture", new="texture.new")
670
671             if tex:
672                 split = layout.split(percentage=0.2)
673                 split.label(text="Type:")
674                 split.prop(tex, "type", text="")
675
676
677 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
678     bl_label = "Nodes"
679     bl_context = "texture"
680
681     @classmethod
682     def poll(cls, context):
683         tex = context.texture
684         return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
685
686     def draw(self, context):
687         layout = self.layout
688
689         tex = context.texture
690         panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
691
692
693 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
694     bl_label = "Node"
695     bl_context = "texture"
696
697     @classmethod
698     def poll(cls, context):
699         node = context.texture_node
700         return node and CyclesButtonsPanel.poll(context)
701
702     def draw(self, context):
703         layout = self.layout
704
705         node = context.texture_node
706         ntree = node.id_data
707         layout.template_node_view(ntree, node, None)
708
709
710 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
711     bl_label = "Mapping"
712     bl_context = "texture"
713
714     @classmethod
715     def poll(cls, context):
716         tex = context.texture
717         node = context.texture_node
718         return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
719
720     def draw(self, context):
721         layout = self.layout
722
723         # tex = context.texture
724         node = context.texture_node
725
726         mapping = node.texture_mapping
727
728         row = layout.row()
729
730         row.column().prop(mapping, "location")
731         row.column().prop(mapping, "rotation")
732         row.column().prop(mapping, "scale")
733
734         layout.label(text="Projection:")
735
736         row = layout.row()
737         row.prop(mapping, "mapping_x", text="")
738         row.prop(mapping, "mapping_y", text="")
739         row.prop(mapping, "mapping_z", text="")
740
741
742 class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
743     bl_label = "Color"
744     bl_context = "texture"
745     bl_options = {'DEFAULT_CLOSED'}
746
747     @classmethod
748     def poll(cls, context):
749         # tex = context.texture
750         # node = context.texture_node
751         return False
752         #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
753
754     def draw(self, context):
755         layout = self.layout
756
757         # tex = context.texture
758         node = context.texture_node
759
760         mapping = node.color_mapping
761
762         split = layout.split()
763
764         col = split.column()
765         col.label(text="Blend:")
766         col.prop(mapping, "blend_type", text="")
767         col.prop(mapping, "blend_factor", text="Factor")
768         col.prop(mapping, "blend_color", text="")
769
770         col = split.column()
771         col.label(text="Adjust:")
772         col.prop(mapping, "brightness")
773         col.prop(mapping, "contrast")
774         col.prop(mapping, "saturation")
775
776         layout.separator()
777
778         layout.prop(mapping, "use_color_ramp", text="Ramp")
779         if mapping.use_color_ramp:
780             layout.template_color_ramp(mapping, "color_ramp", expand=True)
781
782
783 def draw_device(self, context):
784     scene = context.scene
785     layout = self.layout
786
787     if scene.render.engine == 'CYCLES':
788         cscene = scene.cycles
789
790         layout.prop(cscene, "feature_set")
791
792         device_type = context.user_preferences.system.compute_device_type
793         if device_type == 'CUDA':
794             layout.prop(cscene, "device")
795         elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
796             layout.prop(cscene, "device")
797
798
799 def draw_pause(self, context):
800     layout = self.layout
801     scene = context.scene
802
803     if scene.render.engine == "CYCLES":
804         view = context.space_data
805
806         if view.viewport_shade == 'RENDERED':
807             cscene = scene.cycles
808             layername = scene.render.layers.active.name
809             layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
810             layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
811
812
813 def get_panels():
814     return (
815         bpy.types.RENDER_PT_render,
816         bpy.types.RENDER_PT_output,
817         bpy.types.RENDER_PT_encoding,
818         bpy.types.RENDER_PT_dimensions,
819         bpy.types.RENDER_PT_stamp,
820         bpy.types.SCENE_PT_scene,
821         bpy.types.SCENE_PT_audio,
822         bpy.types.SCENE_PT_unit,
823         bpy.types.SCENE_PT_keying_sets,
824         bpy.types.SCENE_PT_keying_set_paths,
825         bpy.types.SCENE_PT_physics,
826         bpy.types.WORLD_PT_context_world,
827         bpy.types.DATA_PT_context_mesh,
828         bpy.types.DATA_PT_context_camera,
829         bpy.types.DATA_PT_context_lamp,
830         bpy.types.DATA_PT_texture_space,
831         bpy.types.DATA_PT_curve_texture_space,
832         bpy.types.DATA_PT_mball_texture_space,
833         bpy.types.DATA_PT_vertex_groups,
834         bpy.types.DATA_PT_shape_keys,
835         bpy.types.DATA_PT_uv_texture,
836         bpy.types.DATA_PT_vertex_colors,
837         bpy.types.DATA_PT_camera,
838         bpy.types.DATA_PT_camera_display,
839         bpy.types.DATA_PT_lens,
840         bpy.types.DATA_PT_custom_props_mesh,
841         bpy.types.DATA_PT_custom_props_camera,
842         bpy.types.DATA_PT_custom_props_lamp,
843         bpy.types.TEXTURE_PT_clouds,
844         bpy.types.TEXTURE_PT_wood,
845         bpy.types.TEXTURE_PT_marble,
846         bpy.types.TEXTURE_PT_magic,
847         bpy.types.TEXTURE_PT_blend,
848         bpy.types.TEXTURE_PT_stucci,
849         bpy.types.TEXTURE_PT_image,
850         bpy.types.TEXTURE_PT_image_sampling,
851         bpy.types.TEXTURE_PT_image_mapping,
852         bpy.types.TEXTURE_PT_musgrave,
853         bpy.types.TEXTURE_PT_voronoi,
854         bpy.types.TEXTURE_PT_distortednoise,
855         bpy.types.TEXTURE_PT_voxeldata,
856         bpy.types.TEXTURE_PT_pointdensity,
857         bpy.types.TEXTURE_PT_pointdensity_turbulence,
858         bpy.types.PARTICLE_PT_context_particles,
859         bpy.types.PARTICLE_PT_emission,
860         bpy.types.PARTICLE_PT_hair_dynamics,
861         bpy.types.PARTICLE_PT_cache,
862         bpy.types.PARTICLE_PT_velocity,
863         bpy.types.PARTICLE_PT_rotation,
864         bpy.types.PARTICLE_PT_physics,
865         bpy.types.PARTICLE_PT_boidbrain,
866         bpy.types.PARTICLE_PT_render,
867         bpy.types.PARTICLE_PT_draw,
868         bpy.types.PARTICLE_PT_children,
869         bpy.types.PARTICLE_PT_field_weights,
870         bpy.types.PARTICLE_PT_force_fields,
871         bpy.types.PARTICLE_PT_vertexgroups,
872         bpy.types.PARTICLE_PT_custom_props,
873         )
874
875
876 def register():
877     bpy.types.RENDER_PT_render.append(draw_device)
878     bpy.types.VIEW3D_HT_header.append(draw_pause)
879
880     for panel in get_panels():
881         panel.COMPAT_ENGINES.add('CYCLES')
882
883
884 def unregister():
885     bpy.types.RENDER_PT_render.remove(draw_device)
886     bpy.types.VIEW3D_HT_header.remove(draw_pause)
887
888     for panel in get_panels():
889         panel.COMPAT_ENGINES.remove('CYCLES')