Cycles: fix AO pass not rendering with AO enabled for world, and make mask
[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         col.prop(rl, "use_zmask");
183
184         col = split.column()
185         col.prop(rl, "layers", text="Layer")
186         col.label(text="Mask Layers:")
187         col.prop(rl, "layers_zmask", text="")
188
189         split = layout.split()
190
191         col = split.column()
192         col.label(text="Passes:")
193         col.prop(rl, "use_pass_combined")
194         col.prop(rl, "use_pass_z")
195         col.prop(rl, "use_pass_normal")
196         col.prop(rl, "use_pass_object_index")
197         col.prop(rl, "use_pass_material_index")
198         col.prop(rl, "use_pass_emit")
199         col.prop(rl, "use_pass_environment")
200         col.prop(rl, "use_pass_ambient_occlusion")
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         col.prop(ccam, "aperture_size", text="Size")
268
269         sub = col.column(align=True)
270         sub.prop(ccam, "aperture_blades", text="Blades")
271         sub.prop(ccam, "aperture_rotation", text="Rotation")
272
273
274 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
275     bl_label = ""
276     bl_context = "material"
277     bl_options = {'HIDE_HEADER'}
278
279     @classmethod
280     def poll(cls, context):
281         return (context.material or context.object) and CyclesButtonsPanel.poll(context)
282
283     def draw(self, context):
284         layout = self.layout
285
286         mat = context.material
287         ob = context.object
288         slot = context.material_slot
289         space = context.space_data
290
291         if ob:
292             row = layout.row()
293
294             row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
295
296             col = row.column(align=True)
297             col.operator("object.material_slot_add", icon='ZOOMIN', text="")
298             col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
299
300             col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
301
302             if ob.mode == 'EDIT':
303                 row = layout.row(align=True)
304                 row.operator("object.material_slot_assign", text="Assign")
305                 row.operator("object.material_slot_select", text="Select")
306                 row.operator("object.material_slot_deselect", text="Deselect")
307
308         split = layout.split(percentage=0.65)
309
310         if ob:
311             split.template_ID(ob, "active_material", new="material.new")
312             row = split.row()
313
314             if slot:
315                 row.prop(slot, "link", text="")
316             else:
317                 row.label()
318         elif mat:
319             split.template_ID(space, "pin_id")
320             split.separator()
321
322
323 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
324     bl_label = "Displacement"
325     bl_context = "data"
326
327     @classmethod
328     def poll(cls, context):
329         if CyclesButtonsPanel.poll(context):
330             if context.mesh or context.curve or context.meta_ball:
331                 if context.scene.cycles.feature_set == 'EXPERIMENTAL':
332                     return True
333
334         return False
335
336     def draw(self, context):
337         layout = self.layout
338
339         mesh = context.mesh
340         curve = context.curve
341         mball = context.meta_ball
342
343         if mesh:
344             cdata = mesh.cycles
345         elif curve:
346             cdata = curve.cycles
347         elif mball:
348             cdata = mball.cycles
349
350         layout.prop(cdata, "displacement_method", text="Method")
351         layout.prop(cdata, "use_subdivision")
352         layout.prop(cdata, "dicing_rate")
353
354
355 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
356     bl_label = "Ray Visibility"
357     bl_context = "object"
358     bl_options = {'DEFAULT_CLOSED'}
359
360     @classmethod
361     def poll(cls, context):
362         ob = context.object
363         return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}  # todo: 'LAMP'
364
365     def draw(self, context):
366         layout = self.layout
367
368         ob = context.object
369         visibility = ob.cycles_visibility
370
371         flow = layout.column_flow()
372
373         flow.prop(visibility, "camera")
374         flow.prop(visibility, "diffuse")
375         flow.prop(visibility, "glossy")
376         flow.prop(visibility, "transmission")
377         flow.prop(visibility, "shadow")
378
379
380 def find_node(material, nodetype):
381     if material and material.node_tree:
382         ntree = material.node_tree
383
384         for node in ntree.nodes:
385             if getattr(node, "type", None) == nodetype:
386                 return node
387
388     return None
389
390
391 def find_node_input(node, name):
392     for input in node.inputs:
393         if input.name == name:
394             return input
395
396     return None
397
398
399 def panel_node_draw(layout, id_data, output_type, input_name):
400     if not id_data.node_tree:
401         layout.prop(id_data, "use_nodes", icon='NODETREE')
402         return False
403
404     ntree = id_data.node_tree
405
406     node = find_node(id_data, output_type)
407     if not node:
408         layout.label(text="No output node.")
409     else:
410         input = find_node_input(node, input_name)
411         layout.template_node_view(ntree, node, input)
412
413     return True
414
415
416 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
417     bl_label = "Lamp"
418     bl_context = "data"
419
420     @classmethod
421     def poll(cls, context):
422         return context.lamp and CyclesButtonsPanel.poll(context)
423
424     def draw(self, context):
425         layout = self.layout
426
427         lamp = context.lamp
428         clamp = lamp.cycles
429
430         layout.prop(lamp, "type", expand=True)
431
432         split = layout.split()
433         col = split.column(align=True)
434
435         if lamp.type in {'POINT', 'SUN', 'SPOT'}:
436             col.prop(lamp, "shadow_soft_size", text="Size")
437         elif lamp.type == 'AREA':
438             col.prop(lamp, "shape", text="")
439             sub = col.column(align=True)
440
441             if lamp.shape == 'SQUARE':
442                 sub.prop(lamp, "size")
443             elif lamp.shape == 'RECTANGLE':
444                 sub.prop(lamp, "size", text="Size X")
445                 sub.prop(lamp, "size_y", text="Size Y")
446
447         col = split.column()
448         col.prop(clamp, "cast_shadow")
449
450         if lamp.type == 'SPOT':
451             layout.label(text="Not supported, interpreted as point lamp.")
452         elif lamp.type == 'HEMI':
453             layout.label(text="Not supported, interpreted as sun lamp.")
454
455
456 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
457     bl_label = "Nodes"
458     bl_context = "data"
459
460     @classmethod
461     def poll(cls, context):
462         return context.lamp and CyclesButtonsPanel.poll(context)
463
464     def draw(self, context):
465         layout = self.layout
466
467         lamp = context.lamp
468         if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
469             layout.prop(lamp, "color")
470
471
472 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
473     bl_label = "Surface"
474     bl_context = "world"
475
476     @classmethod
477     def poll(cls, context):
478         return context.world and CyclesButtonsPanel.poll(context)
479
480     def draw(self, context):
481         layout = self.layout
482
483         world = context.world
484
485         if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
486             layout.prop(world, "horizon_color", text="Color")
487
488 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
489     bl_label = "Volume"
490     bl_context = "world"
491     bl_options = {'DEFAULT_CLOSED'}
492
493     @classmethod
494     def poll(cls, context):
495         # world = context.world
496         # world and world.node_tree and CyclesButtonsPanel.poll(context)
497         return False
498
499     def draw(self, context):
500         layout = self.layout
501         layout.active = False
502
503         world = context.world
504         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
505
506 class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
507     bl_label = "Ambient Occlusion"
508     bl_context = "world"
509
510     @classmethod
511     def poll(cls, context):
512         return context.world and CyclesButtonsPanel.poll(context)
513
514     def draw_header(self, context):
515         light = context.world.light_settings
516         self.layout.prop(light, "use_ambient_occlusion", text="")
517
518     def draw(self, context):
519         layout = self.layout
520         light = context.world.light_settings
521
522         layout.active = light.use_ambient_occlusion
523
524         split = layout.split()
525         split.prop(light, "ao_factor", text="Factor")
526         split.prop(light, "distance", text="Distance")
527
528 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
529     bl_label = "Settings"
530     bl_context = "world"
531     bl_options = {'DEFAULT_CLOSED'}
532
533     @classmethod
534     def poll(cls, context):
535         return context.world and CyclesButtonsPanel.poll(context)
536
537     def draw(self, context):
538         layout = self.layout
539
540         world = context.world
541         cworld = world.cycles
542
543         col = layout.column()
544
545         col.prop(cworld, "sample_as_light")
546         row = col.row()
547         row.active = cworld.sample_as_light
548         row.prop(cworld, "sample_map_resolution")
549
550 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
551     bl_label = "Surface"
552     bl_context = "material"
553
554     @classmethod
555     def poll(cls, context):
556         return context.material and CyclesButtonsPanel.poll(context)
557
558     def draw(self, context):
559         layout = self.layout
560
561         mat = context.material
562         if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
563             layout.prop(mat, "diffuse_color")
564
565
566 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
567     bl_label = "Volume"
568     bl_context = "material"
569     bl_options = {'DEFAULT_CLOSED'}
570
571     @classmethod
572     def poll(cls, context):
573         # mat = context.material
574         # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
575         return False
576
577     def draw(self, context):
578         layout = self.layout
579         layout.active = False
580
581         mat = context.material
582         cmat = mat.cycles
583
584         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
585
586         layout.prop(cmat, "homogeneous_volume")
587
588
589 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
590     bl_label = "Displacement"
591     bl_context = "material"
592
593     @classmethod
594     def poll(cls, context):
595         mat = context.material
596         return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
597
598     def draw(self, context):
599         layout = self.layout
600
601         mat = context.material
602         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
603
604
605 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
606     bl_label = "Settings"
607     bl_context = "material"
608     bl_options = {'DEFAULT_CLOSED'}
609
610     @classmethod
611     def poll(cls, context):
612         return context.material and CyclesButtonsPanel.poll(context)
613
614     def draw(self, context):
615         layout = self.layout
616
617         mat = context.material
618         cmat = mat.cycles
619
620         split = layout.split()
621
622         col = split.column()
623         col.prop(mat, "diffuse_color", text="Viewport Color")
624
625         col = split.column()
626         col.prop(cmat, "sample_as_light")
627         col.prop(mat, "pass_index")
628
629
630 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
631     bl_label = ""
632     bl_context = "texture"
633     bl_options = {'HIDE_HEADER'}
634     COMPAT_ENGINES = {'CYCLES'}
635
636     def draw(self, context):
637         layout = self.layout
638
639         tex = context.texture
640         space = context.space_data
641         pin_id = space.pin_id
642         use_pin_id = space.use_pin_id
643         user = context.texture_user
644         # node = context.texture_node
645
646         if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
647             pin_id = None
648
649         if not pin_id:
650             layout.template_texture_user()
651
652         if user:
653             layout.separator()
654
655             split = layout.split(percentage=0.65)
656             col = split.column()
657
658             if pin_id:
659                 col.template_ID(space, "pin_id")
660             elif user:
661                 col.template_ID(user, "texture", new="texture.new")
662
663             if tex:
664                 split = layout.split(percentage=0.2)
665                 split.label(text="Type:")
666                 split.prop(tex, "type", text="")
667
668
669 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
670     bl_label = "Nodes"
671     bl_context = "texture"
672
673     @classmethod
674     def poll(cls, context):
675         tex = context.texture
676         return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
677
678     def draw(self, context):
679         layout = self.layout
680
681         tex = context.texture
682         panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
683
684
685 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
686     bl_label = "Node"
687     bl_context = "texture"
688
689     @classmethod
690     def poll(cls, context):
691         node = context.texture_node
692         return node and CyclesButtonsPanel.poll(context)
693
694     def draw(self, context):
695         layout = self.layout
696
697         node = context.texture_node
698         ntree = node.id_data
699         layout.template_node_view(ntree, node, None)
700
701
702 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
703     bl_label = "Mapping"
704     bl_context = "texture"
705
706     @classmethod
707     def poll(cls, context):
708         tex = context.texture
709         node = context.texture_node
710         return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
711
712     def draw(self, context):
713         layout = self.layout
714
715         # tex = context.texture
716         node = context.texture_node
717
718         mapping = node.texture_mapping
719
720         row = layout.row()
721
722         row.column().prop(mapping, "location")
723         row.column().prop(mapping, "rotation")
724         row.column().prop(mapping, "scale")
725
726         layout.label(text="Projection:")
727
728         row = layout.row()
729         row.prop(mapping, "mapping_x", text="")
730         row.prop(mapping, "mapping_y", text="")
731         row.prop(mapping, "mapping_z", text="")
732
733
734 class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
735     bl_label = "Color"
736     bl_context = "texture"
737     bl_options = {'DEFAULT_CLOSED'}
738
739     @classmethod
740     def poll(cls, context):
741         # tex = context.texture
742         # node = context.texture_node
743         return False
744         #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
745
746     def draw(self, context):
747         layout = self.layout
748
749         # tex = context.texture
750         node = context.texture_node
751
752         mapping = node.color_mapping
753
754         split = layout.split()
755
756         col = split.column()
757         col.label(text="Blend:")
758         col.prop(mapping, "blend_type", text="")
759         col.prop(mapping, "blend_factor", text="Factor")
760         col.prop(mapping, "blend_color", text="")
761
762         col = split.column()
763         col.label(text="Adjust:")
764         col.prop(mapping, "brightness")
765         col.prop(mapping, "contrast")
766         col.prop(mapping, "saturation")
767
768         layout.separator()
769
770         layout.prop(mapping, "use_color_ramp", text="Ramp")
771         if mapping.use_color_ramp:
772             layout.template_color_ramp(mapping, "color_ramp", expand=True)
773
774
775 def draw_device(self, context):
776     scene = context.scene
777     layout = self.layout
778
779     if scene.render.engine == 'CYCLES':
780         cscene = scene.cycles
781
782         layout.prop(cscene, "feature_set")
783
784         device_type = context.user_preferences.system.compute_device_type
785         if device_type == 'CUDA':
786             layout.prop(cscene, "device")
787         elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
788             layout.prop(cscene, "device")
789
790
791 def draw_pause(self, context):
792     layout = self.layout
793     scene = context.scene
794
795     if scene.render.engine == "CYCLES":
796         view = context.space_data
797
798         if view.viewport_shade == 'RENDERED':
799             cscene = scene.cycles
800             layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
801
802
803 def get_panels():
804     return (
805         bpy.types.RENDER_PT_render,
806         bpy.types.RENDER_PT_output,
807         bpy.types.RENDER_PT_encoding,
808         bpy.types.RENDER_PT_dimensions,
809         bpy.types.RENDER_PT_stamp,
810         bpy.types.SCENE_PT_scene,
811         bpy.types.SCENE_PT_audio,
812         bpy.types.SCENE_PT_unit,
813         bpy.types.SCENE_PT_keying_sets,
814         bpy.types.SCENE_PT_keying_set_paths,
815         bpy.types.SCENE_PT_physics,
816         bpy.types.WORLD_PT_context_world,
817         bpy.types.DATA_PT_context_mesh,
818         bpy.types.DATA_PT_context_camera,
819         bpy.types.DATA_PT_context_lamp,
820         bpy.types.DATA_PT_texture_space,
821         bpy.types.DATA_PT_curve_texture_space,
822         bpy.types.DATA_PT_mball_texture_space,
823         bpy.types.DATA_PT_vertex_groups,
824         bpy.types.DATA_PT_shape_keys,
825         bpy.types.DATA_PT_uv_texture,
826         bpy.types.DATA_PT_vertex_colors,
827         bpy.types.DATA_PT_camera,
828         bpy.types.DATA_PT_camera_display,
829         bpy.types.DATA_PT_lens,
830         bpy.types.DATA_PT_custom_props_mesh,
831         bpy.types.DATA_PT_custom_props_camera,
832         bpy.types.DATA_PT_custom_props_lamp,
833         bpy.types.TEXTURE_PT_clouds,
834         bpy.types.TEXTURE_PT_wood,
835         bpy.types.TEXTURE_PT_marble,
836         bpy.types.TEXTURE_PT_magic,
837         bpy.types.TEXTURE_PT_blend,
838         bpy.types.TEXTURE_PT_stucci,
839         bpy.types.TEXTURE_PT_image,
840         bpy.types.TEXTURE_PT_image_sampling,
841         bpy.types.TEXTURE_PT_image_mapping,
842         bpy.types.TEXTURE_PT_musgrave,
843         bpy.types.TEXTURE_PT_voronoi,
844         bpy.types.TEXTURE_PT_distortednoise,
845         bpy.types.TEXTURE_PT_voxeldata,
846         bpy.types.TEXTURE_PT_pointdensity,
847         bpy.types.TEXTURE_PT_pointdensity_turbulence,
848         bpy.types.PARTICLE_PT_context_particles,
849         bpy.types.PARTICLE_PT_emission,
850         bpy.types.PARTICLE_PT_hair_dynamics,
851         bpy.types.PARTICLE_PT_cache,
852         bpy.types.PARTICLE_PT_velocity,
853         bpy.types.PARTICLE_PT_rotation,
854         bpy.types.PARTICLE_PT_physics,
855         bpy.types.PARTICLE_PT_boidbrain,
856         bpy.types.PARTICLE_PT_render,
857         bpy.types.PARTICLE_PT_draw,
858         bpy.types.PARTICLE_PT_children,
859         bpy.types.PARTICLE_PT_field_weights,
860         bpy.types.PARTICLE_PT_force_fields,
861         bpy.types.PARTICLE_PT_vertexgroups,
862         bpy.types.PARTICLE_PT_custom_props,
863         )
864
865
866 def register():
867     bpy.types.RENDER_PT_render.append(draw_device)
868     bpy.types.VIEW3D_HT_header.append(draw_pause)
869
870     for panel in get_panels():
871         panel.COMPAT_ENGINES.add('CYCLES')
872
873
874 def unregister():
875     bpy.types.RENDER_PT_render.remove(draw_device)
876     bpy.types.VIEW3D_HT_header.remove(draw_pause)
877
878     for panel in get_panels():
879         panel.COMPAT_ENGINES.remove('CYCLES')