Move FFmpeg and QuickTime settings to own structure inside RenderSettings
[blender.git] / release / scripts / startup / bl_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 from bpy.types import Menu, Panel
22
23
24 class RENDER_MT_presets(Menu):
25     bl_label = "Render Presets"
26     preset_subdir = "render"
27     preset_operator = "script.execute_preset"
28     draw = Menu.draw_preset
29
30
31 class RENDER_MT_ffmpeg_presets(Menu):
32     bl_label = "FFMPEG Presets"
33     preset_subdir = "ffmpeg"
34     preset_operator = "script.python_file_run"
35     draw = Menu.draw_preset
36
37
38 class RENDER_MT_framerate_presets(Menu):
39     bl_label = "Frame Rate Presets"
40     preset_subdir = "framerate"
41     preset_operator = "script.execute_preset"
42     draw = Menu.draw_preset
43
44
45 class RenderButtonsPanel():
46     bl_space_type = 'PROPERTIES'
47     bl_region_type = 'WINDOW'
48     bl_context = "render"
49     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
50
51     @classmethod
52     def poll(cls, context):
53         rd = context.scene.render
54         return context.scene and (rd.engine in cls.COMPAT_ENGINES)
55
56
57 class RENDER_PT_render(RenderButtonsPanel, Panel):
58     bl_label = "Render"
59     COMPAT_ENGINES = {'BLENDER_RENDER'}
60
61     def draw(self, context):
62         layout = self.layout
63
64         rd = context.scene.render
65
66         row = layout.row()
67         row.operator("render.render", text="Image", icon='RENDER_STILL')
68         row.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
69
70         layout.prop(rd, "display_mode", text="Display")
71
72
73 class RENDER_PT_layers(RenderButtonsPanel, Panel):
74     bl_label = "Layers"
75     bl_options = {'DEFAULT_CLOSED'}
76     COMPAT_ENGINES = {'BLENDER_RENDER'}
77
78     def draw(self, context):
79         layout = self.layout
80
81         scene = context.scene
82         rd = scene.render
83
84         row = layout.row()
85         row.template_list(rd, "layers", rd.layers, "active_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         row = layout.row()
92         rl = rd.layers.active
93         if rl:
94             row.prop(rl, "name")
95         row.prop(rd, "use_single_layer", text="", icon_only=True)
96
97         split = layout.split()
98
99         col = split.column()
100         col.prop(scene, "layers", text="Scene")
101         col.label(text="")
102         col.prop(rl, "light_override", text="Light")
103         col.prop(rl, "material_override", text="Material")
104
105         col = split.column()
106         col.prop(rl, "layers", text="Layer")
107         col.label(text="Mask Layers:")
108         col.prop(rl, "layers_zmask", text="")
109
110         layout.separator()
111         layout.label(text="Include:")
112
113         split = layout.split()
114
115         col = split.column()
116         col.prop(rl, "use_zmask")
117         row = col.row()
118         row.prop(rl, "invert_zmask", text="Negate")
119         row.active = rl.use_zmask
120         col.prop(rl, "use_all_z")
121
122         col = split.column()
123         col.prop(rl, "use_solid")
124         col.prop(rl, "use_halo")
125         col.prop(rl, "use_ztransp")
126
127         col = split.column()
128         col.prop(rl, "use_sky")
129         col.prop(rl, "use_edge_enhance")
130         col.prop(rl, "use_strand")
131
132         layout.separator()
133
134         split = layout.split()
135
136         col = split.column()
137         col.label(text="Passes:")
138         col.prop(rl, "use_pass_combined")
139         col.prop(rl, "use_pass_z")
140         col.prop(rl, "use_pass_vector")
141         col.prop(rl, "use_pass_normal")
142         col.prop(rl, "use_pass_uv")
143         col.prop(rl, "use_pass_mist")
144         col.prop(rl, "use_pass_object_index")
145         col.prop(rl, "use_pass_material_index")
146         col.prop(rl, "use_pass_color")
147
148         col = split.column()
149         col.label()
150         col.prop(rl, "use_pass_diffuse")
151         row = col.row()
152         row.prop(rl, "use_pass_specular")
153         row.prop(rl, "exclude_specular", text="")
154         row = col.row()
155         row.prop(rl, "use_pass_shadow")
156         row.prop(rl, "exclude_shadow", text="")
157         row = col.row()
158         row.prop(rl, "use_pass_emit")
159         row.prop(rl, "exclude_emit", text="")
160         row = col.row()
161         row.prop(rl, "use_pass_ambient_occlusion")
162         row.prop(rl, "exclude_ambient_occlusion", text="")
163         row = col.row()
164         row.prop(rl, "use_pass_environment")
165         row.prop(rl, "exclude_environment", text="")
166         row = col.row()
167         row.prop(rl, "use_pass_indirect")
168         row.prop(rl, "exclude_indirect", text="")
169         row = col.row()
170         row.prop(rl, "use_pass_reflection")
171         row.prop(rl, "exclude_reflection", text="")
172         row = col.row()
173         row.prop(rl, "use_pass_refraction")
174         row.prop(rl, "exclude_refraction", text="")
175
176
177 class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
178     bl_label = "Dimensions"
179     COMPAT_ENGINES = {'BLENDER_RENDER'}
180
181     def draw(self, context):
182         layout = self.layout
183
184         scene = context.scene
185         rd = scene.render
186
187         row = layout.row(align=True)
188         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
189         row.operator("render.preset_add", text="", icon='ZOOMIN')
190         row.operator("render.preset_add", text="", icon='ZOOMOUT').remove_active = True
191
192         split = layout.split()
193
194         col = split.column()
195         sub = col.column(align=True)
196         sub.label(text="Resolution:")
197         sub.prop(rd, "resolution_x", text="X")
198         sub.prop(rd, "resolution_y", text="Y")
199         sub.prop(rd, "resolution_percentage", text="")
200
201         sub.label(text="Aspect Ratio:")
202         sub.prop(rd, "pixel_aspect_x", text="X")
203         sub.prop(rd, "pixel_aspect_y", text="Y")
204
205         row = col.row()
206         row.prop(rd, "use_border", text="Border")
207         sub = row.row()
208         sub.active = rd.use_border
209         sub.prop(rd, "use_crop_to_border", text="Crop")
210
211         col = split.column()
212         sub = col.column(align=True)
213         sub.label(text="Frame Range:")
214         sub.prop(scene, "frame_start")
215         sub.prop(scene, "frame_end")
216         sub.prop(scene, "frame_step")
217
218         sub.label(text="Frame Rate:")
219         if rd.fps_base == 1:
220             fps_rate = round(rd.fps / rd.fps_base)
221         else:
222             fps_rate = round(rd.fps / rd.fps_base, 2)
223
224         # TODO: Change the following to iterate over existing presets
225         custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60})
226
227         if custom_framerate == True:
228             fps_label_text = "Custom (" + str(fps_rate) + " fps)"
229         else:
230             fps_label_text = str(fps_rate) + " fps"
231
232         sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
233
234         if custom_framerate or (bpy.types.RENDER_MT_framerate_presets.bl_label == "Custom"):
235             sub.prop(rd, "fps")
236             sub.prop(rd, "fps_base", text="/")
237         subrow = sub.row(align=True)
238         subrow.label(text="Time Remapping:")
239         subrow = sub.row(align=True)
240         subrow.prop(rd, "frame_map_old", text="Old")
241         subrow.prop(rd, "frame_map_new", text="New")
242
243
244 class RENDER_PT_antialiasing(RenderButtonsPanel, Panel):
245     bl_label = "Anti-Aliasing"
246     COMPAT_ENGINES = {'BLENDER_RENDER'}
247
248     def draw_header(self, context):
249         rd = context.scene.render
250
251         self.layout.prop(rd, "use_antialiasing", text="")
252
253     def draw(self, context):
254         layout = self.layout
255
256         rd = context.scene.render
257         layout.active = rd.use_antialiasing
258
259         split = layout.split()
260
261         col = split.column()
262         col.row().prop(rd, "antialiasing_samples", expand=True)
263         sub = col.row()
264         sub.enabled = not rd.use_border
265         sub.prop(rd, "use_full_sample")
266
267         col = split.column()
268         col.prop(rd, "pixel_filter_type", text="")
269         col.prop(rd, "filter_size", text="Size")
270
271
272 class RENDER_PT_motion_blur(RenderButtonsPanel, Panel):
273     bl_label = "Sampled Motion Blur"
274     bl_options = {'DEFAULT_CLOSED'}
275     COMPAT_ENGINES = {'BLENDER_RENDER'}
276
277     @classmethod
278     def poll(cls, context):
279         rd = context.scene.render
280         return not rd.use_full_sample and (rd.engine in cls.COMPAT_ENGINES)
281
282     def draw_header(self, context):
283         rd = context.scene.render
284
285         self.layout.prop(rd, "use_motion_blur", text="")
286
287     def draw(self, context):
288         layout = self.layout
289
290         rd = context.scene.render
291         layout.active = rd.use_motion_blur
292
293         row = layout.row()
294         row.prop(rd, "motion_blur_samples")
295         row.prop(rd, "motion_blur_shutter")
296
297
298 class RENDER_PT_shading(RenderButtonsPanel, Panel):
299     bl_label = "Shading"
300     bl_options = {'DEFAULT_CLOSED'}
301     COMPAT_ENGINES = {'BLENDER_RENDER'}
302
303     def draw(self, context):
304         layout = self.layout
305
306         rd = context.scene.render
307
308         split = layout.split()
309
310         col = split.column()
311         col.prop(rd, "use_textures", text="Textures")
312         col.prop(rd, "use_shadows", text="Shadows")
313         col.prop(rd, "use_sss", text="Subsurface Scattering")
314         col.prop(rd, "use_envmaps", text="Environment Map")
315
316         col = split.column()
317         col.prop(rd, "use_raytrace", text="Ray Tracing")
318         col.prop(rd, "use_color_management")
319         sub = col.row()
320         sub.active = rd.use_color_management == True
321         sub.prop(rd, "use_color_unpremultiply")
322         col.prop(rd, "alpha_mode", text="Alpha")
323
324
325 class RENDER_PT_performance(RenderButtonsPanel, Panel):
326     bl_label = "Performance"
327     bl_options = {'DEFAULT_CLOSED'}
328     COMPAT_ENGINES = {'BLENDER_RENDER'}
329
330     def draw(self, context):
331         layout = self.layout
332
333         rd = context.scene.render
334
335         split = layout.split()
336
337         col = split.column()
338         col.label(text="Threads:")
339         col.row().prop(rd, "threads_mode", expand=True)
340         sub = col.column()
341         sub.enabled = rd.threads_mode == 'FIXED'
342         sub.prop(rd, "threads")
343         sub = col.column(align=True)
344         sub.label(text="Tiles:")
345         sub.prop(rd, "parts_x", text="X")
346         sub.prop(rd, "parts_y", text="Y")
347
348         col = split.column()
349         col.label(text="Memory:")
350         sub = col.column()
351         sub.enabled = not (rd.use_border or rd.use_full_sample)
352         sub.prop(rd, "use_save_buffers")
353         sub = col.column()
354         sub.active = rd.use_compositing
355         sub.prop(rd, "use_free_image_textures")
356         sub.prop(rd, "use_free_unused_nodes")
357         sub = col.column()
358         sub.active = rd.use_raytrace
359         sub.label(text="Acceleration structure:")
360         sub.prop(rd, "raytrace_method", text="")
361         if rd.raytrace_method == 'OCTREE':
362             sub.prop(rd, "octree_resolution", text="Resolution")
363         else:
364             sub.prop(rd, "use_instances", text="Instances")
365         sub.prop(rd, "use_local_coords", text="Local Coordinates")
366
367
368 class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
369     bl_label = "Post Processing"
370     bl_options = {'DEFAULT_CLOSED'}
371     COMPAT_ENGINES = {'BLENDER_RENDER'}
372
373     def draw(self, context):
374         layout = self.layout
375
376         rd = context.scene.render
377
378         split = layout.split()
379
380         col = split.column()
381         col.prop(rd, "use_compositing")
382         col.prop(rd, "use_sequencer")
383
384         split.prop(rd, "dither_intensity", text="Dither", slider=True)
385
386         layout.separator()
387
388         split = layout.split()
389
390         col = split.column()
391         col.prop(rd, "use_fields", text="Fields")
392         sub = col.column()
393         sub.active = rd.use_fields
394         sub.row().prop(rd, "field_order", expand=True)
395         sub.prop(rd, "use_fields_still", text="Still")
396
397         col = split.column()
398         col.prop(rd, "use_edge_enhance")
399         sub = col.column()
400         sub.active = rd.use_edge_enhance
401         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
402         sub.prop(rd, "edge_color", text="")
403
404
405 class RENDER_PT_stamp(RenderButtonsPanel, Panel):
406     bl_label = "Stamp"
407     bl_options = {'DEFAULT_CLOSED'}
408     COMPAT_ENGINES = {'BLENDER_RENDER'}
409
410     def draw_header(self, context):
411         rd = context.scene.render
412
413         self.layout.prop(rd, "use_stamp", text="")
414
415     def draw(self, context):
416         layout = self.layout
417
418         rd = context.scene.render
419
420         layout.active = rd.use_stamp
421         
422         layout.prop(rd, "stamp_font_size", text="Font Size")
423         
424         row = layout.row()
425         row.column().prop(rd, "stamp_foreground", slider=True)
426         row.column().prop(rd, "stamp_background", slider=True)
427
428         split = layout.split()
429
430         col = split.column()
431         col.prop(rd, "use_stamp_time", text="Time")
432         col.prop(rd, "use_stamp_date", text="Date")
433         col.prop(rd, "use_stamp_render_time", text="RenderTime")
434         col.prop(rd, "use_stamp_frame", text="Frame")
435         col.prop(rd, "use_stamp_scene", text="Scene")
436         
437         col = split.column()
438         col.prop(rd, "use_stamp_camera", text="Camera")
439         col.prop(rd, "use_stamp_lens", text="Lens")
440         col.prop(rd, "use_stamp_filename", text="Filename")
441         col.prop(rd, "use_stamp_marker", text="Marker")
442         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
443
444         row = layout.split(percentage=0.2)
445         row.prop(rd, "use_stamp_note", text="Note")
446         sub = row.row()
447         sub.active = rd.use_stamp_note
448         sub.prop(rd, "stamp_note_text", text="")
449
450
451 class RENDER_PT_output(RenderButtonsPanel, Panel):
452     bl_label = "Output"
453     COMPAT_ENGINES = {'BLENDER_RENDER'}
454
455     def draw(self, context):
456         layout = self.layout
457
458         rd = context.scene.render
459         image_settings = rd.image_settings
460         file_format = image_settings.file_format
461
462         layout.prop(rd, "filepath", text="")
463
464         flow = layout.column_flow()
465         flow.prop(rd, "use_overwrite")
466         flow.prop(rd, "use_placeholder")
467         flow.prop(rd, "use_file_extension")
468
469         layout.template_image_settings(image_settings)
470
471         if file_format == 'QUICKTIME_CARBON':
472             layout.operator("scene.render_data_set_quicktime_codec")
473
474         elif file_format == 'QUICKTIME_QTKIT':
475             quicktime = rd.quicktime
476
477             split = layout.split()
478             col = split.column()
479             col.prop(quicktime, "codec_type", text="Video Codec")
480             col.prop(quicktime, "codec_spatial_quality", text="Quality")
481
482             # Audio
483             col.prop(quicktime, "audiocodec_type", text="Audio Codec")
484             if quicktime.audiocodec_type != 'No audio':
485                 split = layout.split()
486                 if quicktime.audiocodec_type == 'LPCM':
487                     split.prop(quicktime, "audio_bitdepth", text="")
488
489                 split.prop(quicktime, "audio_samplerate", text="")
490
491                 split = layout.split()
492                 col = split.column()
493                 if quicktime.audiocodec_type == 'AAC':
494                     col.prop(quicktime, "audio_bitrate")
495
496                 subsplit = split.split()
497                 col = subsplit.column()
498
499                 if rquicktime.audiocodec_type == 'AAC':
500                     col.prop(quicktime, "audio_codec_isvbr")
501
502                 col = subsplit.column()
503                 col.prop(quicktime, "audio_resampling_hq")
504
505
506 class RENDER_PT_encoding(RenderButtonsPanel, Panel):
507     bl_label = "Encoding"
508     bl_options = {'DEFAULT_CLOSED'}
509     COMPAT_ENGINES = {'BLENDER_RENDER'}
510
511     @classmethod
512     def poll(cls, context):
513         rd = context.scene.render
514         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
515
516     def draw(self, context):
517         layout = self.layout
518
519         rd = context.scene.render
520         ffmpeg = rd.ffmpeg
521
522         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
523
524         split = layout.split()
525         split.prop(rd.ffmpeg, "format")
526         if ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
527             split.prop(ffmpeg, "codec")
528         elif rd.ffmpeg.format == 'H264':
529             split.prop(ffmpeg, 'use_lossless_output')
530         else:
531             split.label()
532
533         row = layout.row()
534         row.prop(ffmpeg, "video_bitrate")
535         row.prop(ffmpeg, "gopsize")
536
537         split = layout.split()
538
539         col = split.column()
540         col.label(text="Rate:")
541         col.prop(ffmpeg, "minrate", text="Minimum")
542         col.prop(ffmpeg, "maxrate", text="Maximum")
543         col.prop(ffmpeg, "buffersize", text="Buffer")
544
545         col = split.column()
546         col.prop(ffmpeg, "use_autosplit")
547         col.label(text="Mux:")
548         col.prop(ffmpeg, "muxrate", text="Rate")
549         col.prop(ffmpeg, "packetsize", text="Packet Size")
550
551         layout.separator()
552
553         # Audio:
554         if ffmpeg.format not in {'MP3'}:
555             layout.prop(ffmpeg, "audio_codec", text="Audio Codec")
556
557         row = layout.row()
558         row.prop(ffmpeg, "audio_bitrate")
559         row.prop(ffmpeg, "audio_volume", slider=True)
560
561
562 class RENDER_PT_bake(RenderButtonsPanel, Panel):
563     bl_label = "Bake"
564     bl_options = {'DEFAULT_CLOSED'}
565     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
566
567     def draw(self, context):
568         layout = self.layout
569
570         rd = context.scene.render
571
572         layout.operator("object.bake_image", icon='RENDER_STILL')
573
574         layout.prop(rd, "bake_type")
575
576         multires_bake = False
577         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
578             layout.prop(rd, 'use_bake_multires')
579             multires_bake = rd.use_bake_multires
580
581         if not multires_bake:
582             if rd.bake_type == 'NORMALS':
583                 layout.prop(rd, "bake_normal_space")
584             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
585                 layout.prop(rd, "use_bake_normalize")
586
587             # col.prop(rd, "bake_aa_mode")
588             # col.prop(rd, "use_bake_antialiasing")
589
590             layout.separator()
591
592             split = layout.split()
593
594             col = split.column()
595             col.prop(rd, "use_bake_clear")
596             col.prop(rd, "bake_margin")
597             col.prop(rd, "bake_quad_split", text="Split")
598
599             col = split.column()
600             col.prop(rd, "use_bake_selected_to_active")
601             sub = col.column()
602             sub.active = rd.use_bake_selected_to_active
603             sub.prop(rd, "bake_distance")
604             sub.prop(rd, "bake_bias")
605         else:
606             if rd.bake_type == 'DISPLACEMENT':
607                 layout.prop(rd, "use_bake_lores_mesh")
608
609             layout.prop(rd, "use_bake_clear")
610             layout.prop(rd, "bake_margin")
611
612
613 if __name__ == "__main__":  # only for live edit.
614     bpy.utils.register_module(__name__)