QTKit (OSX 64bit): Add audio export to Quicktime
[blender-staging.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.python_file_run"
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, "visible_layers", text="Scene")
100         if wide_ui:
101             col = split.column()
102         col.prop(rl, "visible_layers", text="Layer")
103
104         layout.prop(rl, "light_override", text="Light")
105         layout.prop(rl, "material_override", text="Material")
106
107         layout.separator()
108         layout.label(text="Include:")
109
110         split = layout.split()
111
112         col = split.column()
113         col.prop(rl, "zmask")
114         row = col.row()
115         row.prop(rl, "zmask_negate", text="Negate")
116         row.active = rl.zmask
117         col.prop(rl, "all_z")
118
119         col = split.column()
120         col.prop(rl, "solid")
121         col.prop(rl, "halo")
122         col.prop(rl, "ztransp")
123
124         col = split.column()
125         col.prop(rl, "sky")
126         col.prop(rl, "edge")
127         col.prop(rl, "strand")
128
129         if rl.zmask:
130             split = layout.split()
131             split.label(text="Zmask Layers:")
132             split.column().prop(rl, "zmask_layers", text="")
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="", icon='X')
156         row = col.row()
157         row.prop(rl, "pass_shadow")
158         row.prop(rl, "pass_shadow_exclude", text="", icon='X')
159         row = col.row()
160         row.prop(rl, "pass_emit")
161         row.prop(rl, "pass_emit_exclude", text="", icon='X')
162         row = col.row()
163         row.prop(rl, "pass_ao")
164         row.prop(rl, "pass_ao_exclude", text="", icon='X')
165         row = col.row()
166         row.prop(rl, "pass_environment")
167         row.prop(rl, "pass_environment_exclude", text="", icon='X')
168         row = col.row()
169         row.prop(rl, "pass_indirect")
170         row.prop(rl, "pass_indirect_exclude", text="", icon='X')
171         row = col.row()
172         row.prop(rl, "pass_reflection")
173         row.prop(rl, "pass_reflection_exclude", text="", icon='X')
174         row = col.row()
175         row.prop(rl, "pass_refraction")
176         row.prop(rl, "pass_refraction_exclude", text="", icon='X')
177
178
179 class RENDER_PT_shading(RenderButtonsPanel):
180     bl_label = "Shading"
181     COMPAT_ENGINES = {'BLENDER_RENDER'}
182
183     def draw(self, context):
184         layout = self.layout
185
186         rd = context.scene.render
187         wide_ui = context.region.width > narrowui
188
189         split = layout.split()
190
191         col = split.column()
192         col.prop(rd, "render_textures", text="Textures")
193         col.prop(rd, "render_shadows", text="Shadows")
194         col.prop(rd, "render_sss", text="Subsurface Scattering")
195         col.prop(rd, "render_envmaps", text="Environment Map")
196
197         if wide_ui:
198             col = split.column()
199         col.prop(rd, "render_raytracing", text="Ray Tracing")
200         col.prop(rd, "color_management")
201         col.prop(rd, "alpha_mode", text="Alpha")
202
203
204 class RENDER_PT_performance(RenderButtonsPanel):
205     bl_label = "Performance"
206     bl_default_closed = True
207     COMPAT_ENGINES = {'BLENDER_RENDER'}
208
209     def draw(self, context):
210         layout = self.layout
211
212         rd = context.scene.render
213         wide_ui = context.region.width > narrowui
214
215         split = layout.split()
216
217         col = split.column()
218         col.label(text="Threads:")
219         col.row().prop(rd, "threads_mode", expand=True)
220         sub = col.column()
221         sub.enabled = rd.threads_mode == 'FIXED'
222         sub.prop(rd, "threads")
223         sub = col.column(align=True)
224         sub.label(text="Tiles:")
225         sub.prop(rd, "parts_x", text="X")
226         sub.prop(rd, "parts_y", text="Y")
227
228         if wide_ui:
229             col = split.column()
230         col.label(text="Memory:")
231         sub = col.column()
232         sub.enabled = not (rd.use_border or rd.full_sample)
233         sub.prop(rd, "save_buffers")
234         sub = col.column()
235         sub.active = rd.use_compositing
236         sub.prop(rd, "free_image_textures")
237         sub = col.column()
238         sub.active = rd.render_raytracing
239         sub.label(text="Acceleration structure:")
240         sub.prop(rd, "raytrace_structure", text="")
241         if rd.raytrace_structure == 'OCTREE':
242             sub.prop(rd, "octree_resolution", text="Resolution")
243         else:
244             sub.prop(rd, "use_instances", text="Instances")
245         sub.prop(rd, "use_local_coords", text="Local Coordinates")
246
247
248 class RENDER_PT_post_processing(RenderButtonsPanel):
249     bl_label = "Post Processing"
250     bl_default_closed = True
251     COMPAT_ENGINES = {'BLENDER_RENDER'}
252
253     def draw(self, context):
254         layout = self.layout
255
256         rd = context.scene.render
257         wide_ui = context.region.width > narrowui
258
259         split = layout.split()
260
261         col = split.column()
262         col.prop(rd, "use_compositing")
263         col.prop(rd, "use_sequencer")
264
265         if wide_ui:
266             col = split.column()
267         col.prop(rd, "dither_intensity", text="Dither", slider=True)
268
269         layout.separator()
270
271         split = layout.split()
272
273         col = split.column()
274         col.prop(rd, "fields", text="Fields")
275         sub = col.column()
276         sub.active = rd.fields
277         sub.row().prop(rd, "field_order", expand=True)
278         sub.prop(rd, "fields_still", text="Still")
279
280
281         if wide_ui:
282             col = split.column()
283         else:
284             col.separator()
285         col.prop(rd, "edge")
286         sub = col.column()
287         sub.active = rd.edge
288         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
289         sub.prop(rd, "edge_color", text="")
290
291
292 class RENDER_PT_output(RenderButtonsPanel):
293     bl_label = "Output"
294     COMPAT_ENGINES = {'BLENDER_RENDER'}
295
296     def draw(self, context):
297         layout = self.layout
298
299         rd = context.scene.render
300         wide_ui = context.region.width > narrowui
301
302         layout.prop(rd, "output_path", text="")
303
304         split = layout.split()
305         col = split.column()
306         col.prop(rd, "file_format", text="")
307         col.row().prop(rd, "color_mode", text="Color", expand=True)
308
309         if wide_ui:
310             col = split.column()
311         col.prop(rd, "use_file_extension")
312         col.prop(rd, "use_overwrite")
313         col.prop(rd, "use_placeholder")
314
315         if rd.file_format in ('AVI_JPEG', 'JPEG'):
316             split = layout.split()
317             split.prop(rd, "file_quality", slider=True)
318
319         elif rd.file_format == 'OPEN_EXR':
320             split = layout.split()
321
322             col = split.column()
323             col.label(text="Codec:")
324             col.prop(rd, "exr_codec", text="")
325
326             if wide_ui:
327                 subsplit = split.split()
328                 col = subsplit.column()
329             col.prop(rd, "exr_half")
330             col.prop(rd, "exr_zbuf")
331
332             if wide_ui:
333                 col = subsplit.column()
334             col.prop(rd, "exr_preview")
335
336         elif rd.file_format == 'JPEG2000':
337             split = layout.split()
338             col = split.column()
339             col.label(text="Depth:")
340             col.row().prop(rd, "jpeg2k_depth", expand=True)
341
342             if wide_ui:
343                 col = split.column()
344             col.prop(rd, "jpeg2k_preset", text="")
345             col.prop(rd, "jpeg2k_ycc")
346
347         elif rd.file_format in ('CINEON', 'DPX'):
348             split = layout.split()
349             col = split.column()
350             col.prop(rd, "cineon_log", text="Convert to Log")
351
352             if wide_ui:
353                 col = split.column(align=True)
354             col.active = rd.cineon_log
355             col.prop(rd, "cineon_black", text="Black")
356             col.prop(rd, "cineon_white", text="White")
357             col.prop(rd, "cineon_gamma", text="Gamma")
358
359         elif rd.file_format == 'TIFF':
360             split = layout.split()
361             split.prop(rd, "tiff_bit")
362
363         elif rd.file_format == 'QUICKTIME_CARBON':
364             split = layout.split()
365             split.operator("scene.render_data_set_quicktime_codec")
366
367         elif rd.file_format == 'QUICKTIME_QTKIT':
368             split = layout.split()
369             col = split.column()
370             col.prop(rd, "quicktime_codec_type", text="Video Codec")
371             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
372             
373             #Audio
374             col.prop(rd,"quicktime_audiocodec_type", text="Audio Codec")
375             if rd.quicktime_audiocodec_type != 'No audio':
376                 split = layout.split()
377                 col = split.column()
378                 if rd.quicktime_audiocodec_type == 'LPCM':
379                     col.prop(rd,"quicktime_audio_bitdepth", text="")
380                 if wide_ui:
381                     col = split.column()
382                 col.prop(rd,"quicktime_audio_samplerate", text="")
383
384                 split = layout.split()
385                 col = split.column()
386                 if rd.quicktime_audiocodec_type == 'AAC':
387                     col.prop(rd,"quicktime_audio_bitrate")
388                 if wide_ui:
389                     subsplit = split.split()
390                     col = subsplit.column()
391                 if rd.quicktime_audiocodec_type == 'AAC':
392                     col.prop(rd,"quicktime_audio_codec_isvbr")
393                 if wide_ui:
394                     col = subsplit.column()
395                 col.prop(rd,"quicktime_audio_resampling_hq")
396
397
398 class RENDER_PT_encoding(RenderButtonsPanel):
399     bl_label = "Encoding"
400     bl_default_closed = True
401     COMPAT_ENGINES = {'BLENDER_RENDER'}
402
403     def poll(self, context):
404         rd = context.scene.render
405         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
406
407     def draw(self, context):
408         layout = self.layout
409
410         rd = context.scene.render
411         wide_ui = context.region.width > narrowui
412
413         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
414
415         split = layout.split()
416
417         col = split.column()
418         col.prop(rd, "ffmpeg_format")
419         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
420             if wide_ui:
421                 col = split.column()
422             col.prop(rd, "ffmpeg_codec")
423         else:
424             if wide_ui:
425                 split.label()
426
427         split = layout.split()
428
429         col = split.column()
430         col.prop(rd, "ffmpeg_video_bitrate")
431         if wide_ui:
432             col = split.column()
433         col.prop(rd, "ffmpeg_gopsize")
434
435         split = layout.split()
436
437         col = split.column()
438         col.label(text="Rate:")
439         col.prop(rd, "ffmpeg_minrate", text="Minimum")
440         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
441         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
442
443         if wide_ui:
444             col = split.column()
445
446         col.prop(rd, "ffmpeg_autosplit")
447         col.label(text="Mux:")
448         col.prop(rd, "ffmpeg_muxrate", text="Rate")
449         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
450
451         # Audio:
452         sub = layout.column()
453
454         if rd.ffmpeg_format not in ('MP3'):
455             sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
456
457         sub.separator()
458
459         split = sub.split()
460
461         col = split.column()
462         col.prop(rd, "ffmpeg_audio_bitrate")
463         col.prop(rd, "ffmpeg_audio_mixrate")
464
465         if wide_ui:
466             col = split.column()
467         col.prop(rd, "ffmpeg_audio_volume", slider=True)
468
469
470 class RENDER_PT_antialiasing(RenderButtonsPanel):
471     bl_label = "Anti-Aliasing"
472     COMPAT_ENGINES = {'BLENDER_RENDER'}
473
474     def draw_header(self, context):
475         rd = context.scene.render
476
477         self.layout.prop(rd, "antialiasing", text="")
478
479     def draw(self, context):
480         layout = self.layout
481
482         rd = context.scene.render
483         wide_ui = context.region.width > narrowui
484         layout.active = rd.antialiasing
485
486         split = layout.split()
487
488         col = split.column()
489         col.row().prop(rd, "antialiasing_samples", expand=True)
490         sub = col.row()
491         sub.enabled = not rd.use_border
492         sub.prop(rd, "full_sample")
493
494         if wide_ui:
495             col = split.column()
496         col.prop(rd, "pixel_filter", text="")
497         col.prop(rd, "filter_size", text="Size")
498
499
500 class RENDER_PT_motion_blur(RenderButtonsPanel):
501     bl_label = "Full Sample Motion Blur"
502     bl_default_closed = True
503     COMPAT_ENGINES = {'BLENDER_RENDER'}
504
505     def draw_header(self, context):
506         rd = context.scene.render
507
508         self.layout.prop(rd, "motion_blur", text="")
509
510     def draw(self, context):
511         layout = self.layout
512
513         rd = context.scene.render
514         layout.active = rd.motion_blur
515
516         row = layout.row()
517         row.prop(rd, "motion_blur_samples")
518
519
520 class RENDER_PT_dimensions(RenderButtonsPanel):
521     bl_label = "Dimensions"
522     COMPAT_ENGINES = {'BLENDER_RENDER'}
523
524     def draw(self, context):
525         layout = self.layout
526
527         scene = context.scene
528         rd = scene.render
529         wide_ui = context.region.width > narrowui
530
531         row = layout.row().split()
532         sub = row.row(align=True).split(percentage=0.75)
533         sub.menu("RENDER_MT_presets", text="Presets")
534         sub.operator("render.preset_add", text="Add")
535
536         split = layout.split()
537
538         col = split.column()
539         sub = col.column(align=True)
540         sub.label(text="Resolution:")
541         sub.prop(rd, "resolution_x", text="X")
542         sub.prop(rd, "resolution_y", text="Y")
543         sub.prop(rd, "resolution_percentage", text="")
544
545         sub.label(text="Aspect Ratio:")
546         sub.prop(rd, "pixel_aspect_x", text="X")
547         sub.prop(rd, "pixel_aspect_y", text="Y")
548
549         row = col.row()
550         row.prop(rd, "use_border", text="Border")
551         sub = row.row()
552         sub.active = rd.use_border
553         sub.prop(rd, "crop_to_border", text="Crop")
554
555         if wide_ui:
556             col = split.column()
557         sub = col.column(align=True)
558         sub.label(text="Frame Range:")
559         sub.prop(scene, "frame_start", text="Start")
560         sub.prop(scene, "frame_end", text="End")
561         sub.prop(scene, "frame_step", text="Step")
562
563         sub.label(text="Frame Rate:")
564         sub.prop(rd, "fps")
565         sub.prop(rd, "fps_base", text="/")
566
567
568 class RENDER_PT_stamp(RenderButtonsPanel):
569     bl_label = "Stamp"
570     bl_default_closed = True
571     COMPAT_ENGINES = {'BLENDER_RENDER'}
572
573     def draw_header(self, context):
574         rd = context.scene.render
575
576         self.layout.prop(rd, "render_stamp", text="")
577
578     def draw(self, context):
579         layout = self.layout
580
581         rd = context.scene.render
582         wide_ui = context.region.width > narrowui
583
584         layout.active = rd.render_stamp
585
586         split = layout.split()
587
588         col = split.column()
589         col.prop(rd, "stamp_time", text="Time")
590         col.prop(rd, "stamp_date", text="Date")
591         col.prop(rd, "stamp_render_time", text="RenderTime")
592         col.prop(rd, "stamp_frame", text="Frame")
593         col.prop(rd, "stamp_scene", text="Scene")
594         col.prop(rd, "stamp_camera", text="Camera")
595         col.prop(rd, "stamp_filename", text="Filename")
596         col.prop(rd, "stamp_marker", text="Marker")
597         col.prop(rd, "stamp_sequencer_strip", text="Seq. Strip")
598
599         if wide_ui:
600             col = split.column()
601         col.active = rd.render_stamp
602         col.prop(rd, "stamp_foreground", slider=True)
603         col.prop(rd, "stamp_background", slider=True)
604         col.separator()
605         col.prop(rd, "stamp_font_size", text="Font Size")
606
607         row = layout.split(percentage=0.2)
608         row.prop(rd, "stamp_note", text="Note")
609         sub = row.row()
610         sub.active = rd.stamp_note
611         sub.prop(rd, "stamp_note_text", text="")
612
613
614 class RENDER_PT_bake(RenderButtonsPanel):
615     bl_label = "Bake"
616     bl_default_closed = True
617     COMPAT_ENGINES = {'BLENDER_RENDER'}
618
619     def draw(self, context):
620         layout = self.layout
621
622         rd = context.scene.render
623         wide_ui = context.region.width > narrowui
624
625         layout.operator("object.bake_image", icon='RENDER_STILL')
626
627         if wide_ui:
628             layout.prop(rd, "bake_type")
629         else:
630             layout.prop(rd, "bake_type", text="")
631
632         if rd.bake_type == 'NORMALS':
633             if wide_ui:
634                 layout.prop(rd, "bake_normal_space")
635             else:
636                 layout.prop(rd, "bake_normal_space", text="")
637         elif rd.bake_type in ('DISPLACEMENT', 'AO'):
638             layout.prop(rd, "bake_normalized")
639
640         # col.prop(rd, "bake_aa_mode")
641         # col.prop(rd, "bake_enable_aa")
642
643         layout.separator()
644
645         split = layout.split()
646
647         col = split.column()
648         col.prop(rd, "bake_clear")
649         col.prop(rd, "bake_margin")
650         col.prop(rd, "bake_quad_split", text="Split")
651
652         if wide_ui:
653             col = split.column()
654         col.prop(rd, "bake_active")
655         sub = col.column()
656         sub.active = rd.bake_active
657         sub.prop(rd, "bake_distance")
658         sub.prop(rd, "bake_bias")
659
660
661 classes = [
662     RENDER_MT_presets,
663     RENDER_MT_ffmpeg_presets,
664     RENDER_PT_render,
665     RENDER_PT_layers,
666     RENDER_PT_dimensions,
667     RENDER_PT_antialiasing,
668     RENDER_PT_motion_blur,
669     RENDER_PT_shading,
670     RENDER_PT_output,
671     RENDER_PT_encoding,
672     RENDER_PT_performance,
673     RENDER_PT_post_processing,
674     RENDER_PT_stamp,
675     RENDER_PT_bake]
676
677
678 def register():
679     register = bpy.types.register
680     for cls in classes:
681         register(cls)
682
683
684 def unregister():
685     unregister = bpy.types.unregister
686     for cls in classes:
687         unregister(cls)
688
689 if __name__ == "__main__":
690     register()