57df602f19a08492b2a783ca1ec63f5ec4a7d12e
[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.use_game_engine is False) 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         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         split = layout.split()
420
421         col = split.column()
422         col.prop(rd, "use_stamp_time", text="Time")
423         col.prop(rd, "use_stamp_date", text="Date")
424         col.prop(rd, "use_stamp_render_time", text="RenderTime")
425         col.prop(rd, "use_stamp_frame", text="Frame")
426         col.prop(rd, "use_stamp_scene", text="Scene")
427         col.prop(rd, "use_stamp_camera", text="Camera")
428         col.prop(rd, "use_stamp_lens", text="Lens")
429         col.prop(rd, "use_stamp_filename", text="Filename")
430         col.prop(rd, "use_stamp_marker", text="Marker")
431         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
432
433         col = split.column()
434         col.active = rd.use_stamp
435         col.prop(rd, "stamp_foreground", slider=True)
436         col.prop(rd, "stamp_background", slider=True)
437         col.separator()
438         col.prop(rd, "stamp_font_size", text="Font Size")
439
440         row = layout.split(percentage=0.2)
441         row.prop(rd, "use_stamp_note", text="Note")
442         sub = row.row()
443         sub.active = rd.use_stamp_note
444         sub.prop(rd, "stamp_note_text", text="")
445
446
447 class RENDER_PT_output(RenderButtonsPanel, Panel):
448     bl_label = "Output"
449     COMPAT_ENGINES = {'BLENDER_RENDER'}
450
451     def draw(self, context):
452         layout = self.layout
453
454         rd = context.scene.render
455         image_settings = rd.image_settings
456         file_format = rd.image_settings.file_format
457
458         layout.prop(rd, "filepath", text="")
459         
460         flow = layout.column_flow()
461         flow.prop(rd, "use_overwrite")
462         flow.prop(rd, "use_placeholder")
463         flow.prop(rd, "use_file_extension")
464
465         layout.template_image_settings(rd.image_settings)
466
467         if file_format == 'QUICKTIME_CARBON':
468             layout.operator("scene.render_data_set_quicktime_codec")
469
470         elif file_format == 'QUICKTIME_QTKIT':
471             split = layout.split()
472             col = split.column()
473             col.prop(rd, "quicktime_codec_type", text="Video Codec")
474             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
475
476             # Audio
477             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
478             if rd.quicktime_audiocodec_type != 'No audio':
479                 split = layout.split()
480                 if rd.quicktime_audiocodec_type == 'LPCM':
481                     split.prop(rd, "quicktime_audio_bitdepth", text="")
482
483                 split.prop(rd, "quicktime_audio_samplerate", text="")
484
485                 split = layout.split()
486                 col = split.column()
487                 if rd.quicktime_audiocodec_type == 'AAC':
488                     col.prop(rd, "quicktime_audio_bitrate")
489
490                 subsplit = split.split()
491                 col = subsplit.column()
492
493                 if rd.quicktime_audiocodec_type == 'AAC':
494                     col.prop(rd, "quicktime_audio_codec_isvbr")
495
496                 col = subsplit.column()
497                 col.prop(rd, "quicktime_audio_resampling_hq")
498
499
500 class RENDER_PT_encoding(RenderButtonsPanel, Panel):
501     bl_label = "Encoding"
502     bl_options = {'DEFAULT_CLOSED'}
503     COMPAT_ENGINES = {'BLENDER_RENDER'}
504
505     @classmethod
506     def poll(cls, context):
507         rd = context.scene.render
508         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
509
510     def draw(self, context):
511         layout = self.layout
512
513         rd = context.scene.render
514
515         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
516
517         split = layout.split()
518         split.prop(rd, "ffmpeg_format")
519         if rd.ffmpeg_format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
520             split.prop(rd, "ffmpeg_codec")
521         else:
522             split.label()
523
524         row = layout.row()
525         row.prop(rd, "ffmpeg_video_bitrate")
526         row.prop(rd, "ffmpeg_gopsize")
527
528         split = layout.split()
529
530         col = split.column()
531         col.label(text="Rate:")
532         col.prop(rd, "ffmpeg_minrate", text="Minimum")
533         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
534         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
535
536         col = split.column()
537         col.prop(rd, "ffmpeg_autosplit")
538         col.label(text="Mux:")
539         col.prop(rd, "ffmpeg_muxrate", text="Rate")
540         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
541
542         layout.separator()
543
544         # Audio:
545         if rd.ffmpeg_format not in {'MP3'}:
546             layout.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
547
548         row = layout.row()
549         row.prop(rd, "ffmpeg_audio_bitrate")
550         row.prop(rd, "ffmpeg_audio_volume", slider=True)
551
552
553 class RENDER_PT_bake(RenderButtonsPanel, Panel):
554     bl_label = "Bake"
555     bl_options = {'DEFAULT_CLOSED'}
556     COMPAT_ENGINES = {'BLENDER_RENDER'}
557
558     def draw(self, context):
559         layout = self.layout
560
561         rd = context.scene.render
562
563         layout.operator("object.bake_image", icon='RENDER_STILL')
564
565         layout.prop(rd, "bake_type")
566
567         multires_bake = False
568         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
569             layout.prop(rd, 'use_bake_multires')
570             multires_bake = rd.use_bake_multires
571
572         if not multires_bake:
573             if rd.bake_type == 'NORMALS':
574                 layout.prop(rd, "bake_normal_space")
575             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
576                 layout.prop(rd, "use_bake_normalize")
577
578             # col.prop(rd, "bake_aa_mode")
579             # col.prop(rd, "use_bake_antialiasing")
580
581             layout.separator()
582
583             split = layout.split()
584
585             col = split.column()
586             col.prop(rd, "use_bake_clear")
587             col.prop(rd, "bake_margin")
588             col.prop(rd, "bake_quad_split", text="Split")
589
590             col = split.column()
591             col.prop(rd, "use_bake_selected_to_active")
592             sub = col.column()
593             sub.active = rd.use_bake_selected_to_active
594             sub.prop(rd, "bake_distance")
595             sub.prop(rd, "bake_bias")
596         else:
597             if rd.bake_type == 'DISPLACEMENT':
598                 layout.prop(rd, "use_bake_lores_mesh")
599
600             layout.prop(rd, "use_bake_clear")
601             layout.prop(rd, "bake_margin")
602
603
604 if __name__ == "__main__":  # only for live edit.
605     bpy.utils.register_module(__name__)