9814dd7e9022933b4c97efbc5a51af1761d9f72e
[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         sub = col.column(align=True)
336         sub.label(text="Threads:")
337         sub.row().prop(rd, "threads_mode", expand=True)
338         subsub = sub.column()
339         subsub.enabled = rd.threads_mode == 'FIXED'
340         subsub.prop(rd, "threads")
341         
342         sub = col.column(align=True)
343         sub.label(text="Tile Size:")
344         sub.prop(rd, "tile_x", text="X")
345         sub.prop(rd, "tile_y", text="Y")
346
347         col = split.column()
348         col.label(text="Memory:")
349         sub = col.column()
350         sub.enabled = not (rd.use_border or rd.use_full_sample)
351         sub.prop(rd, "use_save_buffers")
352         sub = col.column()
353         sub.active = rd.use_compositing
354         sub.prop(rd, "use_free_image_textures")
355         sub.prop(rd, "use_free_unused_nodes")
356         sub = col.column()
357         sub.active = rd.use_raytrace
358         sub.label(text="Acceleration structure:")
359         sub.prop(rd, "raytrace_method", text="")
360         if rd.raytrace_method == 'OCTREE':
361             sub.prop(rd, "octree_resolution", text="Resolution")
362         else:
363             sub.prop(rd, "use_instances", text="Instances")
364         sub.prop(rd, "use_local_coords", text="Local Coordinates")
365
366
367 class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
368     bl_label = "Post Processing"
369     bl_options = {'DEFAULT_CLOSED'}
370     COMPAT_ENGINES = {'BLENDER_RENDER'}
371
372     def draw(self, context):
373         layout = self.layout
374
375         rd = context.scene.render
376
377         split = layout.split()
378
379         col = split.column()
380         col.prop(rd, "use_compositing")
381         col.prop(rd, "use_sequencer")
382
383         split.prop(rd, "dither_intensity", text="Dither", slider=True)
384
385         layout.separator()
386
387         split = layout.split()
388
389         col = split.column()
390         col.prop(rd, "use_fields", text="Fields")
391         sub = col.column()
392         sub.active = rd.use_fields
393         sub.row().prop(rd, "field_order", expand=True)
394         sub.prop(rd, "use_fields_still", text="Still")
395
396         col = split.column()
397         col.prop(rd, "use_edge_enhance")
398         sub = col.column()
399         sub.active = rd.use_edge_enhance
400         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
401         sub.prop(rd, "edge_color", text="")
402
403
404 class RENDER_PT_stamp(RenderButtonsPanel, Panel):
405     bl_label = "Stamp"
406     bl_options = {'DEFAULT_CLOSED'}
407     COMPAT_ENGINES = {'BLENDER_RENDER'}
408
409     def draw_header(self, context):
410         rd = context.scene.render
411
412         self.layout.prop(rd, "use_stamp", text="")
413
414     def draw(self, context):
415         layout = self.layout
416
417         rd = context.scene.render
418
419         layout.active = rd.use_stamp
420
421         layout.prop(rd, "stamp_font_size", text="Font Size")
422
423         row = layout.row()
424         row.column().prop(rd, "stamp_foreground", slider=True)
425         row.column().prop(rd, "stamp_background", slider=True)
426
427         split = layout.split()
428
429         col = split.column()
430         col.prop(rd, "use_stamp_time", text="Time")
431         col.prop(rd, "use_stamp_date", text="Date")
432         col.prop(rd, "use_stamp_render_time", text="RenderTime")
433         col.prop(rd, "use_stamp_frame", text="Frame")
434         col.prop(rd, "use_stamp_scene", text="Scene")
435
436         col = split.column()
437         col.prop(rd, "use_stamp_camera", text="Camera")
438         col.prop(rd, "use_stamp_lens", text="Lens")
439         col.prop(rd, "use_stamp_filename", text="Filename")
440         col.prop(rd, "use_stamp_marker", text="Marker")
441         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
442
443         row = layout.split(percentage=0.2)
444         row.prop(rd, "use_stamp_note", text="Note")
445         sub = row.row()
446         sub.active = rd.use_stamp_note
447         sub.prop(rd, "stamp_note_text", text="")
448
449
450 class RENDER_PT_output(RenderButtonsPanel, Panel):
451     bl_label = "Output"
452     COMPAT_ENGINES = {'BLENDER_RENDER'}
453
454     def draw(self, context):
455         layout = self.layout
456
457         rd = context.scene.render
458         image_settings = rd.image_settings
459         file_format = image_settings.file_format
460
461         layout.prop(rd, "filepath", text="")
462
463         flow = layout.column_flow()
464         flow.prop(rd, "use_overwrite")
465         flow.prop(rd, "use_placeholder")
466         flow.prop(rd, "use_file_extension")
467
468         layout.template_image_settings(image_settings, color_management=False)
469
470         if file_format == 'QUICKTIME_CARBON':
471             layout.operator("scene.render_data_set_quicktime_codec")
472
473         elif file_format == 'QUICKTIME_QTKIT':
474             quicktime = rd.quicktime
475
476             split = layout.split()
477             col = split.column()
478             col.prop(quicktime, "codec_type", text="Video Codec")
479             col.prop(quicktime, "codec_spatial_quality", text="Quality")
480
481             # Audio
482             col.prop(quicktime, "audiocodec_type", text="Audio Codec")
483             if quicktime.audiocodec_type != 'No audio':
484                 split = layout.split()
485                 if quicktime.audiocodec_type == 'LPCM':
486                     split.prop(quicktime, "audio_bitdepth", text="")
487
488                 split.prop(quicktime, "audio_samplerate", text="")
489
490                 split = layout.split()
491                 col = split.column()
492                 if quicktime.audiocodec_type == 'AAC':
493                     col.prop(quicktime, "audio_bitrate")
494
495                 subsplit = split.split()
496                 col = subsplit.column()
497
498                 if quicktime.audiocodec_type == 'AAC':
499                     col.prop(quicktime, "audio_codec_isvbr")
500
501                 col = subsplit.column()
502                 col.prop(quicktime, "audio_resampling_hq")
503
504
505 class RENDER_PT_encoding(RenderButtonsPanel, Panel):
506     bl_label = "Encoding"
507     bl_options = {'DEFAULT_CLOSED'}
508     COMPAT_ENGINES = {'BLENDER_RENDER'}
509
510     @classmethod
511     def poll(cls, context):
512         rd = context.scene.render
513         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
514
515     def draw(self, context):
516         layout = self.layout
517
518         rd = context.scene.render
519         ffmpeg = rd.ffmpeg
520
521         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
522
523         split = layout.split()
524         split.prop(rd.ffmpeg, "format")
525         if ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
526             split.prop(ffmpeg, "codec")
527         elif rd.ffmpeg.format == 'H264':
528             split.prop(ffmpeg, "use_lossless_output")
529         else:
530             split.label()
531
532         row = layout.row()
533         row.prop(ffmpeg, "video_bitrate")
534         row.prop(ffmpeg, "gopsize")
535
536         split = layout.split()
537
538         col = split.column()
539         col.label(text="Rate:")
540         col.prop(ffmpeg, "minrate", text="Minimum")
541         col.prop(ffmpeg, "maxrate", text="Maximum")
542         col.prop(ffmpeg, "buffersize", text="Buffer")
543
544         col = split.column()
545         col.prop(ffmpeg, "use_autosplit")
546         col.label(text="Mux:")
547         col.prop(ffmpeg, "muxrate", text="Rate")
548         col.prop(ffmpeg, "packetsize", text="Packet Size")
549
550         layout.separator()
551
552         # Audio:
553         if ffmpeg.format != 'MP3':
554             layout.prop(ffmpeg, "audio_codec", text="Audio Codec")
555
556         row = layout.row()
557         row.prop(ffmpeg, "audio_bitrate")
558         row.prop(ffmpeg, "audio_volume", slider=True)
559
560
561 class RENDER_PT_bake(RenderButtonsPanel, Panel):
562     bl_label = "Bake"
563     bl_options = {'DEFAULT_CLOSED'}
564     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
565
566     def draw(self, context):
567         layout = self.layout
568
569         rd = context.scene.render
570
571         layout.operator("object.bake_image", icon='RENDER_STILL')
572
573         layout.prop(rd, "bake_type")
574
575         multires_bake = False
576         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
577             layout.prop(rd, "use_bake_multires")
578             multires_bake = rd.use_bake_multires
579
580         if not multires_bake:
581             if rd.bake_type == 'NORMALS':
582                 layout.prop(rd, "bake_normal_space")
583             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
584                 layout.prop(rd, "use_bake_normalize")
585
586             # col.prop(rd, "bake_aa_mode")
587             # col.prop(rd, "use_bake_antialiasing")
588
589             layout.separator()
590
591             split = layout.split()
592
593             col = split.column()
594             col.prop(rd, "use_bake_clear")
595             col.prop(rd, "bake_margin")
596             col.prop(rd, "bake_quad_split", text="Split")
597
598             col = split.column()
599             col.prop(rd, "use_bake_selected_to_active")
600             sub = col.column()
601             sub.active = rd.use_bake_selected_to_active
602             sub.prop(rd, "bake_distance")
603             sub.prop(rd, "bake_bias")
604         else:
605             if rd.bake_type == 'DISPLACEMENT':
606                 layout.prop(rd, "use_bake_lores_mesh")
607
608             layout.prop(rd, "use_bake_clear")
609             layout.prop(rd, "bake_margin")
610
611
612 if __name__ == "__main__":  # only for live edit.
613     bpy.utils.register_module(__name__)