Merged changes in the trunk up to revision 28536.
[blender.git] / release / scripts / ui / properties_render.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22 narrowui = 180
23
24
25 class RENDER_MT_presets(bpy.types.Menu):
26     bl_label = "Render Presets"
27     preset_subdir = "render"
28     preset_operator = "script.execute_preset"
29     draw = bpy.types.Menu.draw_preset
30
31
32 class RENDER_MT_ffmpeg_presets(bpy.types.Menu):
33     bl_label = "FFMPEG Presets"
34     preset_subdir = "ffmpeg"
35     preset_operator = "script.python_file_run"
36     draw = bpy.types.Menu.draw_preset
37
38
39 class RenderButtonsPanel(bpy.types.Panel):
40     bl_space_type = 'PROPERTIES'
41     bl_region_type = 'WINDOW'
42     bl_context = "render"
43     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
44
45     def poll(self, context):
46         rd = context.scene.render
47         return (context.scene and rd.use_game_engine is False) and (rd.engine in self.COMPAT_ENGINES)
48
49
50 class RENDER_PT_render(RenderButtonsPanel):
51     bl_label = "Render"
52     COMPAT_ENGINES = {'BLENDER_RENDER'}
53
54     def draw(self, context):
55         layout = self.layout
56
57         rd = context.scene.render
58         wide_ui = context.region.width > narrowui
59
60         split = layout.split()
61
62         col = split.column()
63         col.operator("render.render", text="Image", icon='RENDER_STILL')
64
65         if wide_ui:
66             col = split.column()
67         col.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
68
69         layout.prop(rd, "display_mode", text="Display")
70
71
72 class RENDER_PT_layers(RenderButtonsPanel):
73     bl_label = "Layers"
74     bl_default_closed = True
75     COMPAT_ENGINES = {'BLENDER_RENDER'}
76
77     def draw(self, context):
78         layout = self.layout
79
80         scene = context.scene
81         rd = scene.render
82         wide_ui = context.region.width > narrowui
83
84         row = layout.row()
85         row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
86
87         col = row.column(align=True)
88         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
89         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
90
91         rl = rd.layers[rd.active_layer_index]
92
93         if rl:
94             layout.prop(rl, "name")
95
96         split = layout.split()
97
98         col = split.column()
99         col.prop(scene, "layers", text="Scene")
100         col.label(text="")
101         col.prop(rl, "light_override", text="Light")
102         col.prop(rl, "material_override", text="Material")
103         if wide_ui:
104             col = split.column()
105         col.prop(rl, "visible_layers", text="Layer")
106         col.label(text="Mask Layers:")
107         col.prop(rl, "zmask_layers", text="")
108
109         
110
111         layout.separator()
112         layout.label(text="Include:")
113
114         split = layout.split()
115
116         col = split.column()
117         col.prop(rl, "zmask")
118         row = col.row()
119         row.prop(rl, "zmask_negate", text="Negate")
120         row.active = rl.zmask
121         col.prop(rl, "all_z")
122
123         col = split.column()
124         col.prop(rl, "solid")
125         col.prop(rl, "halo")
126         col.prop(rl, "ztransp")
127         col.prop(rl, "sky")
128                 
129         col = split.column()
130         col.prop(rl, "edge")
131         col.prop(rl, "strand")
132         col.prop(rl, "freestyle")
133
134         layout.separator()
135
136         split = layout.split()
137
138         col = split.column()
139         col.label(text="Passes:")
140         col.prop(rl, "pass_combined")
141         col.prop(rl, "pass_z")
142         col.prop(rl, "pass_vector")
143         col.prop(rl, "pass_normal")
144         col.prop(rl, "pass_uv")
145         col.prop(rl, "pass_mist")
146         col.prop(rl, "pass_object_index")
147         col.prop(rl, "pass_color")
148
149         if wide_ui:
150             col = split.column()
151         col.label()
152         col.prop(rl, "pass_diffuse")
153         row = col.row()
154         row.prop(rl, "pass_specular")
155         row.prop(rl, "pass_specular_exclude", text="")
156         row = col.row()
157         row.prop(rl, "pass_shadow")
158         row.prop(rl, "pass_shadow_exclude", text="")
159         row = col.row()
160         row.prop(rl, "pass_emit")
161         row.prop(rl, "pass_emit_exclude", text="")
162         row = col.row()
163         row.prop(rl, "pass_ao")
164         row.prop(rl, "pass_ao_exclude", text="")
165         row = col.row()
166         row.prop(rl, "pass_environment")
167         row.prop(rl, "pass_environment_exclude", text="")
168         row = col.row()
169         row.prop(rl, "pass_indirect")
170         row.prop(rl, "pass_indirect_exclude", text="")
171         row = col.row()
172         row.prop(rl, "pass_reflection")
173         row.prop(rl, "pass_reflection_exclude", text="")
174         row = col.row()
175         row.prop(rl, "pass_refraction")
176         row.prop(rl, "pass_refraction_exclude", text="")
177
178         if rl.freestyle:
179             layout.separator()
180
181             split = layout.split()
182
183             col = split.column()
184             col.label(text="Freestyle:")
185             freestyle = rl.freestyle_settings
186             col.prop(freestyle, "sphere_radius", text="Sphere Radius")
187             col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
188             col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
189             col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
190
191             col.operator("scene.freestyle_module_add", text="Add Style Module")
192
193             for i, module in enumerate(freestyle.modules):
194                     box = layout.box()
195                     box.set_context_pointer("freestyle_module", module)
196                     row = box.row(align=True)
197                     row.prop(module, "is_displayed", text="")
198                     row.prop(module, "module_path", text="")
199                     row.operator("scene.freestyle_module_remove", icon='X', text="")
200                     props = row.operator("scene.freestyle_module_move_up", icon='MOVE_UP_VEC', text="")
201                     props.active = (i > 0)
202                     props = row.operator("scene.freestyle_module_move_down", icon='MOVE_DOWN_VEC', text="")
203                     props.active = (i < len(freestyle.modules) - 1)
204
205
206 class RENDER_PT_shading(RenderButtonsPanel):
207     bl_label = "Shading"
208     COMPAT_ENGINES = {'BLENDER_RENDER'}
209
210     def draw(self, context):
211         layout = self.layout
212
213         rd = context.scene.render
214         wide_ui = context.region.width > narrowui
215
216         split = layout.split()
217
218         col = split.column()
219         col.prop(rd, "render_textures", text="Textures")
220         col.prop(rd, "render_shadows", text="Shadows")
221         col.prop(rd, "render_sss", text="Subsurface Scattering")
222         col.prop(rd, "render_envmaps", text="Environment Map")
223
224         if wide_ui:
225             col = split.column()
226         col.prop(rd, "render_raytracing", text="Ray Tracing")
227         col.prop(rd, "color_management")
228         col.prop(rd, "alpha_mode", text="Alpha")
229
230
231 class RENDER_PT_performance(RenderButtonsPanel):
232     bl_label = "Performance"
233     bl_default_closed = True
234     COMPAT_ENGINES = {'BLENDER_RENDER'}
235
236     def draw(self, context):
237         layout = self.layout
238
239         rd = context.scene.render
240         wide_ui = context.region.width > narrowui
241
242         split = layout.split()
243
244         col = split.column()
245         col.label(text="Threads:")
246         col.row().prop(rd, "threads_mode", expand=True)
247         sub = col.column()
248         sub.enabled = rd.threads_mode == 'FIXED'
249         sub.prop(rd, "threads")
250         sub = col.column(align=True)
251         sub.label(text="Tiles:")
252         sub.prop(rd, "parts_x", text="X")
253         sub.prop(rd, "parts_y", text="Y")
254
255         if wide_ui:
256             col = split.column()
257         col.label(text="Memory:")
258         sub = col.column()
259         sub.enabled = not (rd.use_border or rd.full_sample)
260         sub.prop(rd, "save_buffers")
261         sub = col.column()
262         sub.active = rd.use_compositing
263         sub.prop(rd, "free_image_textures")
264         sub = col.column()
265         sub.active = rd.render_raytracing
266         sub.label(text="Acceleration structure:")
267         sub.prop(rd, "raytrace_structure", text="")
268         if rd.raytrace_structure == 'OCTREE':
269             sub.prop(rd, "octree_resolution", text="Resolution")
270         else:
271             sub.prop(rd, "use_instances", text="Instances")
272         sub.prop(rd, "use_local_coords", text="Local Coordinates")
273
274
275 class RENDER_PT_post_processing(RenderButtonsPanel):
276     bl_label = "Post Processing"
277     bl_default_closed = True
278     COMPAT_ENGINES = {'BLENDER_RENDER'}
279
280     def draw(self, context):
281         layout = self.layout
282
283         rd = context.scene.render
284         wide_ui = context.region.width > narrowui
285
286         split = layout.split()
287
288         col = split.column()
289         col.prop(rd, "use_compositing")
290         col.prop(rd, "use_sequencer")
291
292         if wide_ui:
293             col = split.column()
294         col.prop(rd, "dither_intensity", text="Dither", slider=True)
295
296         layout.separator()
297
298         split = layout.split()
299
300         col = split.column()
301         col.prop(rd, "fields", text="Fields")
302         sub = col.column()
303         sub.active = rd.fields
304         sub.row().prop(rd, "field_order", expand=True)
305         sub.prop(rd, "fields_still", text="Still")
306
307
308         if wide_ui:
309             col = split.column()
310         else:
311             col.separator()
312         col.prop(rd, "edge")
313         sub = col.column()
314         sub.active = rd.edge
315         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
316         sub.prop(rd, "edge_color", text="")
317
318         layout.separator()
319
320         split = layout.split()
321         col = split.column()
322         col.prop(rd, "freestyle", text="Freestyle")
323
324
325 class RENDER_PT_output(RenderButtonsPanel):
326     bl_label = "Output"
327     COMPAT_ENGINES = {'BLENDER_RENDER'}
328
329     def draw(self, context):
330         layout = self.layout
331
332         rd = context.scene.render
333         wide_ui = context.region.width > narrowui
334
335         layout.prop(rd, "output_path", text="")
336
337         split = layout.split()
338         col = split.column()
339         col.prop(rd, "file_format", text="")
340         col.row().prop(rd, "color_mode", text="Color", expand=True)
341
342         if wide_ui:
343             col = split.column()
344         col.prop(rd, "use_file_extension")
345         col.prop(rd, "use_overwrite")
346         col.prop(rd, "use_placeholder")
347
348         if rd.file_format in ('AVI_JPEG', 'JPEG'):
349             split = layout.split()
350             split.prop(rd, "file_quality", slider=True)
351
352         elif rd.file_format == 'OPEN_EXR':
353             split = layout.split()
354
355             col = split.column()
356             col.label(text="Codec:")
357             col.prop(rd, "exr_codec", text="")
358
359             if wide_ui:
360                 subsplit = split.split()
361                 col = subsplit.column()
362             col.prop(rd, "exr_half")
363             col.prop(rd, "exr_zbuf")
364
365             if wide_ui:
366                 col = subsplit.column()
367             col.prop(rd, "exr_preview")
368
369         elif rd.file_format == 'JPEG2000':
370             split = layout.split()
371             col = split.column()
372             col.label(text="Depth:")
373             col.row().prop(rd, "jpeg2k_depth", expand=True)
374
375             if wide_ui:
376                 col = split.column()
377             col.prop(rd, "jpeg2k_preset", text="")
378             col.prop(rd, "jpeg2k_ycc")
379
380         elif rd.file_format in ('CINEON', 'DPX'):
381             split = layout.split()
382             col = split.column()
383             col.prop(rd, "cineon_log", text="Convert to Log")
384
385             if wide_ui:
386                 col = split.column(align=True)
387             col.active = rd.cineon_log
388             col.prop(rd, "cineon_black", text="Black")
389             col.prop(rd, "cineon_white", text="White")
390             col.prop(rd, "cineon_gamma", text="Gamma")
391
392         elif rd.file_format == 'TIFF':
393             split = layout.split()
394             split.prop(rd, "tiff_bit")
395
396         elif rd.file_format == 'QUICKTIME_CARBON':
397             split = layout.split()
398             split.operator("scene.render_data_set_quicktime_codec")
399
400         elif rd.file_format == 'QUICKTIME_QTKIT':
401             split = layout.split()
402             col = split.column()
403             col.prop(rd, "quicktime_codec_type", text="Video Codec")
404             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
405
406             # Audio
407             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
408             if rd.quicktime_audiocodec_type != 'No audio':
409                 split = layout.split()
410                 col = split.column()
411                 if rd.quicktime_audiocodec_type == 'LPCM':
412                     col.prop(rd, "quicktime_audio_bitdepth", text="")
413                 if wide_ui:
414                     col = split.column()
415                 col.prop(rd, "quicktime_audio_samplerate", text="")
416
417                 split = layout.split()
418                 col = split.column()
419                 if rd.quicktime_audiocodec_type == 'AAC':
420                     col.prop(rd, "quicktime_audio_bitrate")
421                 if wide_ui:
422                     subsplit = split.split()
423                     col = subsplit.column()
424                 if rd.quicktime_audiocodec_type == 'AAC':
425                     col.prop(rd, "quicktime_audio_codec_isvbr")
426                 if wide_ui:
427                     col = subsplit.column()
428                 col.prop(rd, "quicktime_audio_resampling_hq")
429
430
431 class RENDER_PT_encoding(RenderButtonsPanel):
432     bl_label = "Encoding"
433     bl_default_closed = True
434     COMPAT_ENGINES = {'BLENDER_RENDER'}
435
436     def poll(self, context):
437         rd = context.scene.render
438         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
439
440     def draw(self, context):
441         layout = self.layout
442
443         rd = context.scene.render
444         wide_ui = context.region.width > narrowui
445
446         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
447
448         split = layout.split()
449
450         col = split.column()
451         col.prop(rd, "ffmpeg_format")
452         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
453             if wide_ui:
454                 col = split.column()
455             col.prop(rd, "ffmpeg_codec")
456         else:
457             if wide_ui:
458                 split.label()
459
460         split = layout.split()
461
462         col = split.column()
463         col.prop(rd, "ffmpeg_video_bitrate")
464         if wide_ui:
465             col = split.column()
466         col.prop(rd, "ffmpeg_gopsize")
467
468         split = layout.split()
469
470         col = split.column()
471         col.label(text="Rate:")
472         col.prop(rd, "ffmpeg_minrate", text="Minimum")
473         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
474         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
475
476         if wide_ui:
477             col = split.column()
478
479         col.prop(rd, "ffmpeg_autosplit")
480         col.label(text="Mux:")
481         col.prop(rd, "ffmpeg_muxrate", text="Rate")
482         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
483
484         # Audio:
485         sub = layout.column()
486
487         if rd.ffmpeg_format not in ('MP3'):
488             sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
489
490         sub.separator()
491
492         split = sub.split()
493
494         col = split.column()
495         col.prop(rd, "ffmpeg_audio_bitrate")
496         col.prop(rd, "ffmpeg_audio_mixrate")
497
498         if wide_ui:
499             col = split.column()
500         col.prop(rd, "ffmpeg_audio_volume", slider=True)
501
502
503 class RENDER_PT_antialiasing(RenderButtonsPanel):
504     bl_label = "Anti-Aliasing"
505     COMPAT_ENGINES = {'BLENDER_RENDER'}
506
507     def draw_header(self, context):
508         rd = context.scene.render
509
510         self.layout.prop(rd, "antialiasing", text="")
511
512     def draw(self, context):
513         layout = self.layout
514
515         rd = context.scene.render
516         wide_ui = context.region.width > narrowui
517         layout.active = rd.antialiasing
518
519         split = layout.split()
520
521         col = split.column()
522         col.row().prop(rd, "antialiasing_samples", expand=True)
523         sub = col.row()
524         sub.enabled = not rd.use_border
525         sub.prop(rd, "full_sample")
526
527         if wide_ui:
528             col = split.column()
529         col.prop(rd, "pixel_filter", text="")
530         col.prop(rd, "filter_size", text="Size")
531
532
533 class RENDER_PT_motion_blur(RenderButtonsPanel):
534     bl_label = "Full Sample Motion Blur"
535     bl_default_closed = True
536     COMPAT_ENGINES = {'BLENDER_RENDER'}
537
538     def draw_header(self, context):
539         rd = context.scene.render
540
541         self.layout.prop(rd, "motion_blur", text="")
542
543     def draw(self, context):
544         layout = self.layout
545
546         rd = context.scene.render
547         layout.active = rd.motion_blur
548
549         row = layout.row()
550         row.prop(rd, "motion_blur_samples")
551
552
553 class RENDER_PT_dimensions(RenderButtonsPanel):
554     bl_label = "Dimensions"
555     COMPAT_ENGINES = {'BLENDER_RENDER'}
556
557     def draw(self, context):
558         layout = self.layout
559
560         scene = context.scene
561         rd = scene.render
562         wide_ui = context.region.width > narrowui
563
564         row = layout.row().split()
565         sub = row.row(align=True).split(percentage=0.75)
566         sub.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
567         sub.operator("render.preset_add", text="", icon="ZOOMIN")
568
569         split = layout.split()
570
571         col = split.column()
572         sub = col.column(align=True)
573         sub.label(text="Resolution:")
574         sub.prop(rd, "resolution_x", text="X")
575         sub.prop(rd, "resolution_y", text="Y")
576         sub.prop(rd, "resolution_percentage", text="")
577
578         sub.label(text="Aspect Ratio:")
579         sub.prop(rd, "pixel_aspect_x", text="X")
580         sub.prop(rd, "pixel_aspect_y", text="Y")
581
582         row = col.row()
583         row.prop(rd, "use_border", text="Border")
584         sub = row.row()
585         sub.active = rd.use_border
586         sub.prop(rd, "crop_to_border", text="Crop")
587
588         if wide_ui:
589             col = split.column()
590         sub = col.column(align=True)
591         sub.label(text="Frame Range:")
592         sub.prop(scene, "frame_start", text="Start")
593         sub.prop(scene, "frame_end", text="End")
594         sub.prop(scene, "frame_step", text="Step")
595
596         sub.label(text="Frame Rate:")
597         sub.prop(rd, "fps")
598         sub.prop(rd, "fps_base", text="/")
599
600
601 class RENDER_PT_stamp(RenderButtonsPanel):
602     bl_label = "Stamp"
603     bl_default_closed = True
604     COMPAT_ENGINES = {'BLENDER_RENDER'}
605
606     def draw_header(self, context):
607         rd = context.scene.render
608
609         self.layout.prop(rd, "render_stamp", text="")
610
611     def draw(self, context):
612         layout = self.layout
613
614         rd = context.scene.render
615         wide_ui = context.region.width > narrowui
616
617         layout.active = rd.render_stamp
618
619         split = layout.split()
620
621         col = split.column()
622         col.prop(rd, "stamp_time", text="Time")
623         col.prop(rd, "stamp_date", text="Date")
624         col.prop(rd, "stamp_render_time", text="RenderTime")
625         col.prop(rd, "stamp_frame", text="Frame")
626         col.prop(rd, "stamp_scene", text="Scene")
627         col.prop(rd, "stamp_camera", text="Camera")
628         col.prop(rd, "stamp_filename", text="Filename")
629         col.prop(rd, "stamp_marker", text="Marker")
630         col.prop(rd, "stamp_sequencer_strip", text="Seq. Strip")
631
632         if wide_ui:
633             col = split.column()
634         col.active = rd.render_stamp
635         col.prop(rd, "stamp_foreground", slider=True)
636         col.prop(rd, "stamp_background", slider=True)
637         col.separator()
638         col.prop(rd, "stamp_font_size", text="Font Size")
639
640         row = layout.split(percentage=0.2)
641         row.prop(rd, "stamp_note", text="Note")
642         sub = row.row()
643         sub.active = rd.stamp_note
644         sub.prop(rd, "stamp_note_text", text="")
645
646
647 class RENDER_PT_bake(RenderButtonsPanel):
648     bl_label = "Bake"
649     bl_default_closed = True
650     COMPAT_ENGINES = {'BLENDER_RENDER'}
651
652     def draw(self, context):
653         layout = self.layout
654
655         rd = context.scene.render
656         wide_ui = context.region.width > narrowui
657
658         layout.operator("object.bake_image", icon='RENDER_STILL')
659         
660         if wide_ui:
661             layout.prop(rd, "bake_type")
662         else:
663             layout.prop(rd, "bake_type", text="")
664         
665         if rd.bake_type == 'NORMALS':
666             if wide_ui:
667                 layout.prop(rd, "bake_normal_space")
668             else:
669                 layout.prop(rd, "bake_normal_space", text="")
670         elif rd.bake_type in ('DISPLACEMENT', 'AO'):
671             layout.prop(rd, "bake_normalized")
672         
673         # col.prop(rd, "bake_aa_mode")
674         # col.prop(rd, "bake_enable_aa")
675         
676         layout.separator()
677         
678         split = layout.split()
679
680         col = split.column()
681         col.prop(rd, "bake_clear")
682         col.prop(rd, "bake_margin")
683         col.prop(rd, "bake_quad_split", text="Split")
684         
685         if wide_ui:
686             col = split.column()
687         col.prop(rd, "bake_active")
688         sub = col.column()
689         sub.active = rd.bake_active
690         sub.prop(rd, "bake_distance")
691         sub.prop(rd, "bake_bias")
692
693         
694 classes = [
695     RENDER_MT_presets,
696     RENDER_MT_ffmpeg_presets,
697     RENDER_PT_render,
698     RENDER_PT_layers,
699     RENDER_PT_dimensions,
700     RENDER_PT_antialiasing,
701     RENDER_PT_motion_blur,
702     RENDER_PT_shading,
703     RENDER_PT_output,
704     RENDER_PT_encoding,
705     RENDER_PT_performance,
706     RENDER_PT_post_processing,
707     RENDER_PT_stamp,
708     RENDER_PT_bake]
709
710
711 def register():
712     register = bpy.types.register
713     for cls in classes:
714         register(cls)
715
716
717 def unregister():
718     unregister = bpy.types.unregister
719     for cls in classes:
720         unregister(cls)
721
722 if __name__ == "__main__":
723     register()