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