Kaying node from tomato branch
[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_sampling(CyclesButtonsPanel, Panel):
48     bl_label = "Sampling"
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         split = layout.split()
58
59         col = split.column()
60         sub = col.column()
61         sub.active = cscene.device == 'CPU'
62         sub.prop(cscene, "progressive")
63
64         sub = col.column(align=True)
65         sub.prop(cscene, "seed")
66         sub.prop(cscene, "sample_clamp")
67
68         if cscene.progressive or cscene.device != 'CPU':
69             col = split.column()
70             col.label(text="Samples:")
71             sub = col.column(align=True)
72             sub.prop(cscene, "samples", text="Render")
73             sub.prop(cscene, "preview_samples", text="Preview")
74         else:
75             sub.label(text="AA Samples:")
76             sub.prop(cscene, "aa_samples", text="Render")
77             sub.prop(cscene, "preview_aa_samples", text="Preview")
78
79             col = split.column()
80             col.label(text="Samples:")
81             sub = col.column(align=True)
82             sub.prop(cscene, "diffuse_samples", text="Diffuse")
83             sub.prop(cscene, "glossy_samples", text="Glossy")
84             sub.prop(cscene, "transmission_samples", text="Transmission")
85             sub.prop(cscene, "ao_samples", text="AO")
86             sub.prop(cscene, "mesh_light_samples", text="Mesh Light")
87
88 class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
89     bl_label = "Light Paths"
90     bl_options = {'DEFAULT_CLOSED'}
91
92     def draw(self, context):
93         layout = self.layout
94
95         scene = context.scene
96         cscene = scene.cycles
97
98         row = layout.row(align=True)
99         row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
100         row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
101         row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
102
103         split = layout.split()
104
105         col = split.column()
106
107         sub = col.column(align=True)
108         sub.label("Transparency:")
109         sub.prop(cscene, "transparent_max_bounces", text="Max")
110         sub.prop(cscene, "transparent_min_bounces", text="Min")
111         sub.prop(cscene, "use_transparent_shadows", text="Shadows")
112
113         col.separator()
114
115         col.prop(cscene, "no_caustics")
116         col.prop(cscene, "blur_glossy")
117
118         col = split.column()
119
120         sub = col.column(align=True)
121         sub.label(text="Bounces:")
122         sub.prop(cscene, "max_bounces", text="Max")
123         sub.prop(cscene, "min_bounces", text="Min")
124
125         sub = col.column(align=True)
126         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
127         sub.prop(cscene, "glossy_bounces", text="Glossy")
128         sub.prop(cscene, "transmission_bounces", text="Transmission")
129
130
131 class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
132     bl_label = "Motion Blur"
133     bl_options = {'DEFAULT_CLOSED'}
134
135     @classmethod
136     def poll(cls, context):
137         return False
138
139     def draw_header(self, context):
140         rd = context.scene.render
141
142         self.layout.prop(rd, "use_motion_blur", text="")
143
144     def draw(self, context):
145         layout = self.layout
146
147         rd = context.scene.render
148         layout.active = rd.use_motion_blur
149
150         row = layout.row()
151         row.prop(rd, "motion_blur_shutter")
152
153
154 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
155     bl_label = "Film"
156
157     def draw(self, context):
158         layout = self.layout
159
160         scene = context.scene
161         cscene = scene.cycles
162
163         split = layout.split()
164
165         col = split.column()
166         col.prop(cscene, "film_exposure")
167         col.prop(cscene, "film_transparent")
168
169         col = split.column()
170         sub = col.column(align=True)
171         sub.prop(cscene, "filter_type", text="")
172         if cscene.filter_type != 'BOX':
173             sub.prop(cscene, "filter_width", text="Width")
174
175
176 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
177     bl_label = "Performance"
178     bl_options = {'DEFAULT_CLOSED'}
179
180     def draw(self, context):
181         layout = self.layout
182
183         scene = context.scene
184         rd = scene.render
185         cscene = scene.cycles
186
187         split = layout.split()
188
189         col = split.column(align=True)
190
191         col.label(text="Threads:")
192         col.row().prop(rd, "threads_mode", expand=True)
193         sub = col.column()
194         sub.enabled = rd.threads_mode == 'FIXED'
195         sub.prop(rd, "threads")
196
197         sub = col.column(align=True)
198         sub.label(text="Tiles:")
199         sub.prop(cscene, "debug_tile_size")
200         sub.prop(cscene, "debug_min_size")
201
202         col = split.column()
203
204         sub = col.column(align=True)
205         sub.label(text="Acceleration structure:")
206         sub.prop(cscene, "debug_bvh_type", text="")
207         sub.prop(cscene, "debug_use_spatial_splits")
208         sub.prop(cscene, "use_cache")
209
210
211 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
212     bl_label = "Layers"
213     bl_options = {'DEFAULT_CLOSED'}
214     COMPAT_ENGINES = {'BLENDER_RENDER'}
215
216     def draw(self, context):
217         layout = self.layout
218
219         scene = context.scene
220         rd = scene.render
221
222         row = layout.row()
223         row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
224
225         col = row.column(align=True)
226         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
227         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
228
229         row = layout.row()
230         rl = rd.layers.active
231         row.prop(rl, "name")
232         row.prop(rd, "use_single_layer", text="", icon_only=True)
233
234         split = layout.split()
235
236         col = split.column()
237         col.prop(scene, "layers", text="Scene")
238         col.prop(rl, "layers_exclude", text="Exclude")
239
240         col = split.column()
241         col.prop(rl, "layers", text="Layer")
242         col.label(text="Mask Layers:")
243         col.prop(rl, "layers_zmask", text="")
244
245         split = layout.split()
246
247         col = split.column()
248         col.label(text="Material:")
249         col.prop(rl, "material_override", text="")
250
251         col = split.column()
252         col.prop(rl, "samples")
253         col.prop(rl, "use_sky", "Use Environment")
254
255         split = layout.split()
256
257         col = split.column()
258         col.label(text="Passes:")
259         col.prop(rl, "use_pass_combined")
260         col.prop(rl, "use_pass_z")
261         col.prop(rl, "use_pass_normal")
262         col.prop(rl, "use_pass_vector")
263         col.prop(rl, "use_pass_uv")
264         col.prop(rl, "use_pass_object_index")
265         col.prop(rl, "use_pass_material_index")
266         col.prop(rl, "use_pass_ambient_occlusion")
267         col.prop(rl, "use_pass_shadow")
268
269         col = split.column()
270         col.label()
271         col.label(text="Diffuse:")
272         row = col.row(align=True)
273         row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
274         row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
275         row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
276         col.label(text="Glossy:")
277         row = col.row(align=True)
278         row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
279         row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
280         row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
281         col.label(text="Transmission:")
282         row = col.row(align=True)
283         row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
284         row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
285         row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
286
287         col.prop(rl, "use_pass_emit", text="Emission")
288         col.prop(rl, "use_pass_environment")
289
290
291 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
292     bl_label = "Post Processing"
293     bl_options = {'DEFAULT_CLOSED'}
294
295     def draw(self, context):
296         layout = self.layout
297
298         rd = context.scene.render
299
300         split = layout.split()
301
302         col = split.column()
303         col.prop(rd, "use_compositing")
304         col.prop(rd, "use_sequencer")
305
306         col = split.column()
307         col.prop(rd, "dither_intensity", text="Dither", slider=True)
308
309
310 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
311     bl_label = "Depth of Field"
312     bl_context = "data"
313
314     @classmethod
315     def poll(cls, context):
316         return context.camera and CyclesButtonsPanel.poll(context)
317
318     def draw(self, context):
319         layout = self.layout
320
321         cam = context.camera
322         ccam = cam.cycles
323
324         split = layout.split()
325
326         col = split.column()
327         col.label("Focus:")
328         col.prop(cam, "dof_object", text="")
329
330         sub = col.row()
331         sub.active = cam.dof_object is None
332         sub.prop(cam, "dof_distance", text="Distance")
333
334         col = split.column()
335
336         col.label("Aperture:")
337         sub = col.column(align=True)
338         sub.prop(ccam, "aperture_type", text="")
339         if ccam.aperture_type == 'RADIUS':
340             sub.prop(ccam, "aperture_size", text="Size")
341         elif ccam.aperture_type == 'FSTOP':
342             sub.prop(ccam, "aperture_fstop", text="Number")
343
344         sub = col.column(align=True)
345         sub.prop(ccam, "aperture_blades", text="Blades")
346         sub.prop(ccam, "aperture_rotation", text="Rotation")
347
348
349 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
350     bl_label = ""
351     bl_context = "material"
352     bl_options = {'HIDE_HEADER'}
353
354     @classmethod
355     def poll(cls, context):
356         return (context.material or context.object) and CyclesButtonsPanel.poll(context)
357
358     def draw(self, context):
359         layout = self.layout
360
361         mat = context.material
362         ob = context.object
363         slot = context.material_slot
364         space = context.space_data
365
366         if ob:
367             row = layout.row()
368
369             row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
370
371             col = row.column(align=True)
372             col.operator("object.material_slot_add", icon='ZOOMIN', text="")
373             col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
374
375             col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
376
377             if ob.mode == 'EDIT':
378                 row = layout.row(align=True)
379                 row.operator("object.material_slot_assign", text="Assign")
380                 row.operator("object.material_slot_select", text="Select")
381                 row.operator("object.material_slot_deselect", text="Deselect")
382
383         split = layout.split(percentage=0.65)
384
385         if ob:
386             split.template_ID(ob, "active_material", new="material.new")
387             row = split.row()
388
389             if slot:
390                 row.prop(slot, "link", text="")
391             else:
392                 row.label()
393         elif mat:
394             split.template_ID(space, "pin_id")
395             split.separator()
396
397
398 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
399     bl_label = "Displacement"
400     bl_context = "data"
401
402     @classmethod
403     def poll(cls, context):
404         if CyclesButtonsPanel.poll(context):
405             if context.mesh or context.curve or context.meta_ball:
406                 if context.scene.cycles.feature_set == 'EXPERIMENTAL':
407                     return True
408
409         return False
410
411     def draw(self, context):
412         layout = self.layout
413
414         mesh = context.mesh
415         curve = context.curve
416         mball = context.meta_ball
417
418         if mesh:
419             cdata = mesh.cycles
420         elif curve:
421             cdata = curve.cycles
422         elif mball:
423             cdata = mball.cycles
424
425         layout.prop(cdata, "displacement_method", text="Method")
426         layout.prop(cdata, "use_subdivision")
427         layout.prop(cdata, "dicing_rate")
428
429
430 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
431     bl_label = "Ray Visibility"
432     bl_context = "object"
433     bl_options = {'DEFAULT_CLOSED'}
434
435     @classmethod
436     def poll(cls, context):
437         ob = context.object
438         return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}  # todo: 'LAMP'
439
440     def draw(self, context):
441         layout = self.layout
442
443         ob = context.object
444         visibility = ob.cycles_visibility
445
446         flow = layout.column_flow()
447
448         flow.prop(visibility, "camera")
449         flow.prop(visibility, "diffuse")
450         flow.prop(visibility, "glossy")
451         flow.prop(visibility, "transmission")
452         flow.prop(visibility, "shadow")
453
454
455 def find_node(material, nodetype):
456     if material and material.node_tree:
457         ntree = material.node_tree
458
459         for node in ntree.nodes:
460             if getattr(node, "type", None) == nodetype:
461                 return node
462
463     return None
464
465
466 def find_node_input(node, name):
467     for input in node.inputs:
468         if input.name == name:
469             return input
470
471     return None
472
473
474 def panel_node_draw(layout, id_data, output_type, input_name):
475     if not id_data.use_nodes:
476         layout.prop(id_data, "use_nodes", icon='NODETREE')
477         return False
478
479     ntree = id_data.node_tree
480
481     node = find_node(id_data, output_type)
482     if not node:
483         layout.label(text="No output node.")
484     else:
485         input = find_node_input(node, input_name)
486         layout.template_node_view(ntree, node, input)
487
488     return True
489
490
491 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
492     bl_label = "Lamp"
493     bl_context = "data"
494
495     @classmethod
496     def poll(cls, context):
497         return context.lamp and CyclesButtonsPanel.poll(context)
498
499     def draw(self, context):
500         layout = self.layout
501
502         lamp = context.lamp
503         clamp = lamp.cycles
504         cscene = context.scene.cycles
505
506         layout.prop(lamp, "type", expand=True)
507
508         split = layout.split()
509         col = split.column(align=True)
510
511         if lamp.type in {'POINT', 'SUN', 'SPOT'}:
512             col.prop(lamp, "shadow_soft_size", text="Size")
513         elif lamp.type == 'AREA':
514             col.prop(lamp, "shape", text="")
515             sub = col.column(align=True)
516
517             if lamp.shape == 'SQUARE':
518                 sub.prop(lamp, "size")
519             elif lamp.shape == 'RECTANGLE':
520                 sub.prop(lamp, "size", text="Size X")
521                 sub.prop(lamp, "size_y", text="Size Y")
522
523         if not cscene.progressive and cscene.device == 'CPU':
524             col.prop(clamp, "samples")
525
526         col = split.column()
527         col.prop(clamp, "cast_shadow")
528
529         if lamp.type == 'HEMI':
530             layout.label(text="Not supported, interpreted as sun lamp.")
531
532
533 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
534     bl_label = "Nodes"
535     bl_context = "data"
536
537     @classmethod
538     def poll(cls, context):
539         return context.lamp and CyclesButtonsPanel.poll(context)
540
541     def draw(self, context):
542         layout = self.layout
543
544         lamp = context.lamp
545         if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
546             layout.prop(lamp, "color")
547
548 class CyclesLamp_PT_spot(CyclesButtonsPanel, Panel):
549     bl_label = "Spot Shape"
550     bl_context = "data"
551
552     @classmethod
553     def poll(cls, context):
554         lamp = context.lamp
555         return (lamp and lamp.type == 'SPOT') and CyclesButtonsPanel.poll(context)
556
557     def draw(self, context):
558         layout = self.layout
559
560         lamp = context.lamp
561
562         split = layout.split()
563
564         col = split.column()
565         sub = col.column()
566         sub.prop(lamp, "spot_size", text="Size")
567         sub.prop(lamp, "spot_blend", text="Blend", slider=True)
568
569         col = split.column()
570         col.prop(lamp, "show_cone")
571
572 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
573     bl_label = "Surface"
574     bl_context = "world"
575
576     @classmethod
577     def poll(cls, context):
578         return context.world and CyclesButtonsPanel.poll(context)
579
580     def draw(self, context):
581         layout = self.layout
582
583         world = context.world
584
585         if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
586             layout.prop(world, "horizon_color", text="Color")
587
588
589 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
590     bl_label = "Volume"
591     bl_context = "world"
592     bl_options = {'DEFAULT_CLOSED'}
593
594     @classmethod
595     def poll(cls, context):
596         # world = context.world
597         # world and world.node_tree and CyclesButtonsPanel.poll(context)
598         return False
599
600     def draw(self, context):
601         layout = self.layout
602         layout.active = False
603
604         world = context.world
605         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
606
607
608 class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
609     bl_label = "Ambient Occlusion"
610     bl_context = "world"
611
612     @classmethod
613     def poll(cls, context):
614         return context.world and CyclesButtonsPanel.poll(context)
615
616     def draw_header(self, context):
617         light = context.world.light_settings
618         self.layout.prop(light, "use_ambient_occlusion", text="")
619
620     def draw(self, context):
621         layout = self.layout
622         light = context.world.light_settings
623
624         layout.active = light.use_ambient_occlusion
625
626         row = layout.row()
627         row.prop(light, "ao_factor", text="Factor")
628         row.prop(light, "distance", text="Distance")
629
630
631 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
632     bl_label = "Settings"
633     bl_context = "world"
634     bl_options = {'DEFAULT_CLOSED'}
635
636     @classmethod
637     def poll(cls, context):
638         return context.world and CyclesButtonsPanel.poll(context)
639
640     def draw(self, context):
641         layout = self.layout
642
643         world = context.world
644         cworld = world.cycles
645         cscene = context.scene.cycles
646
647         col = layout.column()
648
649         col.prop(cworld, "sample_as_light")
650         sub = col.row(align=True)
651         sub.active = cworld.sample_as_light
652         sub.prop(cworld, "sample_map_resolution")
653         if not cscene.progressive and cscene.device == 'CPU':
654             sub.prop(cworld, "samples")
655
656
657 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
658     bl_label = "Surface"
659     bl_context = "material"
660
661     @classmethod
662     def poll(cls, context):
663         return context.material and CyclesButtonsPanel.poll(context)
664
665     def draw(self, context):
666         layout = self.layout
667
668         mat = context.material
669         if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
670             layout.prop(mat, "diffuse_color")
671
672
673 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
674     bl_label = "Volume"
675     bl_context = "material"
676     bl_options = {'DEFAULT_CLOSED'}
677
678     @classmethod
679     def poll(cls, context):
680         # mat = context.material
681         # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
682         return False
683
684     def draw(self, context):
685         layout = self.layout
686         layout.active = False
687
688         mat = context.material
689         cmat = mat.cycles
690
691         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
692
693         layout.prop(cmat, "homogeneous_volume")
694
695
696 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
697     bl_label = "Displacement"
698     bl_context = "material"
699
700     @classmethod
701     def poll(cls, context):
702         mat = context.material
703         return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
704
705     def draw(self, context):
706         layout = self.layout
707
708         mat = context.material
709         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
710
711
712 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
713     bl_label = "Settings"
714     bl_context = "material"
715     bl_options = {'DEFAULT_CLOSED'}
716
717     @classmethod
718     def poll(cls, context):
719         return context.material and CyclesButtonsPanel.poll(context)
720
721     def draw(self, context):
722         layout = self.layout
723
724         mat = context.material
725         cmat = mat.cycles
726
727         split = layout.split()
728
729         col = split.column()
730         col.prop(mat, "diffuse_color", text="Viewport Color")
731
732         col = split.column()
733         col.prop(cmat, "sample_as_light")
734         col.prop(mat, "pass_index")
735
736
737 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
738     bl_label = ""
739     bl_context = "texture"
740     bl_options = {'HIDE_HEADER'}
741     COMPAT_ENGINES = {'CYCLES'}
742
743     def draw(self, context):
744         layout = self.layout
745
746         tex = context.texture
747         space = context.space_data
748         pin_id = space.pin_id
749         use_pin_id = space.use_pin_id
750         user = context.texture_user
751
752         if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
753             pin_id = None
754
755         if not pin_id:
756             layout.template_texture_user()
757
758         if user:
759             layout.separator()
760
761             split = layout.split(percentage=0.65)
762             col = split.column()
763
764             if pin_id:
765                 col.template_ID(space, "pin_id")
766             elif user:
767                 col.template_ID(user, "texture", new="texture.new")
768
769             if tex:
770                 split = layout.split(percentage=0.2)
771                 split.label(text="Type:")
772                 split.prop(tex, "type", text="")
773
774
775 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
776     bl_label = "Nodes"
777     bl_context = "texture"
778
779     @classmethod
780     def poll(cls, context):
781         tex = context.texture
782         return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
783
784     def draw(self, context):
785         layout = self.layout
786
787         tex = context.texture
788         panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
789
790
791 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
792     bl_label = "Node"
793     bl_context = "texture"
794
795     @classmethod
796     def poll(cls, context):
797         node = context.texture_node
798         return node and CyclesButtonsPanel.poll(context)
799
800     def draw(self, context):
801         layout = self.layout
802
803         node = context.texture_node
804         ntree = node.id_data
805         layout.template_node_view(ntree, node, None)
806
807
808 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
809     bl_label = "Mapping"
810     bl_context = "texture"
811
812     @classmethod
813     def poll(cls, context):
814         tex = context.texture
815         node = context.texture_node
816         return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
817
818     def draw(self, context):
819         layout = self.layout
820
821         # tex = context.texture
822         node = context.texture_node
823
824         mapping = node.texture_mapping
825
826         row = layout.row()
827
828         row.column().prop(mapping, "translation")
829         row.column().prop(mapping, "rotation")
830         row.column().prop(mapping, "scale")
831
832         layout.label(text="Projection:")
833
834         row = layout.row()
835         row.prop(mapping, "mapping_x", text="")
836         row.prop(mapping, "mapping_y", text="")
837         row.prop(mapping, "mapping_z", text="")
838
839
840 class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
841     bl_label = "Color"
842     bl_context = "texture"
843     bl_options = {'DEFAULT_CLOSED'}
844
845     @classmethod
846     def poll(cls, context):
847         # tex = context.texture
848         # node = context.texture_node
849         return False
850         #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
851
852     def draw(self, context):
853         layout = self.layout
854
855         # tex = context.texture
856         node = context.texture_node
857
858         mapping = node.color_mapping
859
860         split = layout.split()
861
862         col = split.column()
863         col.label(text="Blend:")
864         col.prop(mapping, "blend_type", text="")
865         col.prop(mapping, "blend_factor", text="Factor")
866         col.prop(mapping, "blend_color", text="")
867
868         col = split.column()
869         col.label(text="Adjust:")
870         col.prop(mapping, "brightness")
871         col.prop(mapping, "contrast")
872         col.prop(mapping, "saturation")
873
874         layout.separator()
875
876         layout.prop(mapping, "use_color_ramp", text="Ramp")
877         if mapping.use_color_ramp:
878             layout.template_color_ramp(mapping, "color_ramp", expand=True)
879
880
881 class CyclesScene_PT_simplify(CyclesButtonsPanel, Panel):
882     bl_label = "Simplify"
883     bl_context = "scene"
884     COMPAT_ENGINES = {'CYCLES'}
885
886     def draw_header(self, context):
887         rd = context.scene.render
888         self.layout.prop(rd, "use_simplify", text="")
889
890     def draw(self, context):
891         layout = self.layout
892
893         rd = context.scene.render
894
895         layout.active = rd.use_simplify
896
897         split = layout.split()
898
899         col = split.column()
900         col.prop(rd, "simplify_subdivision", text="Subdivision")
901
902         col = split.column()
903         col.prop(rd, "simplify_child_particles", text="Child Particles")
904
905
906 def draw_device(self, context):
907     scene = context.scene
908     layout = self.layout
909
910     if scene.render.engine == 'CYCLES':
911         cscene = scene.cycles
912
913         layout.prop(cscene, "feature_set")
914
915         device_type = context.user_preferences.system.compute_device_type
916         if device_type == 'CUDA':
917             layout.prop(cscene, "device")
918         elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
919             layout.prop(cscene, "device")
920
921
922 def draw_pause(self, context):
923     layout = self.layout
924     scene = context.scene
925
926     if scene.render.engine == "CYCLES":
927         view = context.space_data
928
929         if view.viewport_shade == 'RENDERED':
930             cscene = scene.cycles
931             layername = scene.render.layers.active.name
932             layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
933             layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
934
935
936 def get_panels():
937     return (
938         bpy.types.RENDER_PT_render,
939         bpy.types.RENDER_PT_output,
940         bpy.types.RENDER_PT_encoding,
941         bpy.types.RENDER_PT_dimensions,
942         bpy.types.RENDER_PT_stamp,
943         bpy.types.SCENE_PT_scene,
944         bpy.types.SCENE_PT_audio,
945         bpy.types.SCENE_PT_unit,
946         bpy.types.SCENE_PT_keying_sets,
947         bpy.types.SCENE_PT_keying_set_paths,
948         bpy.types.SCENE_PT_physics,
949         bpy.types.WORLD_PT_context_world,
950         bpy.types.DATA_PT_context_mesh,
951         bpy.types.DATA_PT_context_camera,
952         bpy.types.DATA_PT_context_lamp,
953         bpy.types.DATA_PT_texture_space,
954         bpy.types.DATA_PT_curve_texture_space,
955         bpy.types.DATA_PT_mball_texture_space,
956         bpy.types.DATA_PT_vertex_groups,
957         bpy.types.DATA_PT_shape_keys,
958         bpy.types.DATA_PT_uv_texture,
959         bpy.types.DATA_PT_vertex_colors,
960         bpy.types.DATA_PT_camera,
961         bpy.types.DATA_PT_camera_display,
962         bpy.types.DATA_PT_lens,
963         bpy.types.DATA_PT_custom_props_mesh,
964         bpy.types.DATA_PT_custom_props_camera,
965         bpy.types.DATA_PT_custom_props_lamp,
966         bpy.types.TEXTURE_PT_clouds,
967         bpy.types.TEXTURE_PT_wood,
968         bpy.types.TEXTURE_PT_marble,
969         bpy.types.TEXTURE_PT_magic,
970         bpy.types.TEXTURE_PT_blend,
971         bpy.types.TEXTURE_PT_stucci,
972         bpy.types.TEXTURE_PT_image,
973         bpy.types.TEXTURE_PT_image_sampling,
974         bpy.types.TEXTURE_PT_image_mapping,
975         bpy.types.TEXTURE_PT_musgrave,
976         bpy.types.TEXTURE_PT_voronoi,
977         bpy.types.TEXTURE_PT_distortednoise,
978         bpy.types.TEXTURE_PT_voxeldata,
979         bpy.types.TEXTURE_PT_pointdensity,
980         bpy.types.TEXTURE_PT_pointdensity_turbulence,
981         bpy.types.PARTICLE_PT_context_particles,
982         bpy.types.PARTICLE_PT_emission,
983         bpy.types.PARTICLE_PT_hair_dynamics,
984         bpy.types.PARTICLE_PT_cache,
985         bpy.types.PARTICLE_PT_velocity,
986         bpy.types.PARTICLE_PT_rotation,
987         bpy.types.PARTICLE_PT_physics,
988         bpy.types.PARTICLE_PT_boidbrain,
989         bpy.types.PARTICLE_PT_render,
990         bpy.types.PARTICLE_PT_draw,
991         bpy.types.PARTICLE_PT_children,
992         bpy.types.PARTICLE_PT_field_weights,
993         bpy.types.PARTICLE_PT_force_fields,
994         bpy.types.PARTICLE_PT_vertexgroups,
995         bpy.types.PARTICLE_PT_custom_props,
996         )
997
998
999 def register():
1000     bpy.types.RENDER_PT_render.append(draw_device)
1001     bpy.types.VIEW3D_HT_header.append(draw_pause)
1002
1003     for panel in get_panels():
1004         panel.COMPAT_ENGINES.add('CYCLES')
1005
1006
1007 def unregister():
1008     bpy.types.RENDER_PT_render.remove(draw_device)
1009     bpy.types.VIEW3D_HT_header.remove(draw_pause)
1010
1011     for panel in get_panels():
1012         panel.COMPAT_ENGINES.remove('CYCLES')