1e9c15eedae108d4b22dbe1b9d0505d2c622ec52
[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 from blf import gettext as _
23
24
25 class RENDER_MT_presets(Menu):
26     bl_label = "Render Presets"
27     preset_subdir = "render"
28     preset_operator = "script.execute_preset"
29     draw = Menu.draw_preset
30
31
32 class RENDER_MT_ffmpeg_presets(Menu):
33     bl_label = "FFMPEG Presets"
34     preset_subdir = "ffmpeg"
35     preset_operator = "script.python_file_run"
36     draw = Menu.draw_preset
37
38
39 class RENDER_MT_framerate_presets(Menu):
40     bl_label = "Frame Rate Presets"
41     preset_subdir = "framerate"
42     preset_operator = "script.execute_preset"
43     draw = Menu.draw_preset
44
45
46 class RenderButtonsPanel():
47     bl_space_type = 'PROPERTIES'
48     bl_region_type = 'WINDOW'
49     bl_context = "render"
50     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
51
52     @classmethod
53     def poll(cls, context):
54         rd = context.scene.render
55         return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
56
57
58 class RENDER_PT_render(RenderButtonsPanel, Panel):
59     bl_label = "Render"
60     COMPAT_ENGINES = {'BLENDER_RENDER'}
61
62     def draw(self, context):
63         layout = self.layout
64
65         rd = context.scene.render
66
67         row = layout.row()
68         row.operator("render.render", text=_("Image"), icon='RENDER_STILL')
69         row.operator("render.render", text=_("Animation"), icon='RENDER_ANIMATION').animation = True
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 == 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, "use_color_management")
320         col.prop(rd, "alpha_mode", text=_("Alpha"))
321
322
323 class RENDER_PT_performance(RenderButtonsPanel, Panel):
324     bl_label = "Performance"
325     bl_options = {'DEFAULT_CLOSED'}
326     COMPAT_ENGINES = {'BLENDER_RENDER'}
327
328     def draw(self, context):
329         layout = self.layout
330
331         rd = context.scene.render
332
333         split = layout.split()
334
335         col = split.column()
336         col.label(text=_("Threads:"))
337         col.row().prop(rd, "threads_mode", expand=True)
338         sub = col.column()
339         sub.enabled = rd.threads_mode == 'FIXED'
340         sub.prop(rd, "threads")
341         sub = col.column(align=True)
342         sub.label(text=_("Tiles:"))
343         sub.prop(rd, "parts_x", text="X")
344         sub.prop(rd, "parts_y", text="Y")
345
346         col = split.column()
347         col.label(text=_("Memory:"))
348         sub = col.column()
349         sub.enabled = not (rd.use_border or rd.use_full_sample)
350         sub.prop(rd, "use_save_buffers")
351         sub = col.column()
352         sub.active = rd.use_compositing
353         sub.prop(rd, "use_free_image_textures")
354         sub.prop(rd, "use_free_unused_nodes")
355         sub = col.column()
356         sub.active = rd.use_raytrace
357         sub.label(text=_("Acceleration structure:"))
358         sub.prop(rd, "raytrace_method", text="")
359         if rd.raytrace_method == 'OCTREE':
360             sub.prop(rd, "octree_resolution", text=_("Resolution"))
361         else:
362             sub.prop(rd, "use_instances", text=_("Instances"))
363         sub.prop(rd, "use_local_coords", text=_("Local Coordinates"))
364
365
366 class RENDER_PT_post_processing(RenderButtonsPanel, Panel):
367     bl_label = "Post Processing"
368     bl_options = {'DEFAULT_CLOSED'}
369     COMPAT_ENGINES = {'BLENDER_RENDER'}
370
371     def draw(self, context):
372         layout = self.layout
373
374         rd = context.scene.render
375
376         split = layout.split()
377
378         col = split.column()
379         col.prop(rd, "use_compositing")
380         col.prop(rd, "use_sequencer")
381
382         split.prop(rd, "dither_intensity", text=_("Dither"), slider=True)
383
384         layout.separator()
385
386         split = layout.split()
387
388         col = split.column()
389         col.prop(rd, "use_fields", text=_("Fields"))
390         sub = col.column()
391         sub.active = rd.use_fields
392         sub.row().prop(rd, "field_order", expand=True)
393         sub.prop(rd, "use_fields_still", text=_("Still"))
394
395         col = split.column()
396         col.prop(rd, "use_edge_enhance")
397         sub = col.column()
398         sub.active = rd.use_edge_enhance
399         sub.prop(rd, "edge_threshold", text=_("Threshold"), slider=True)
400         sub.prop(rd, "edge_color", text="")
401
402
403 class RENDER_PT_stamp(RenderButtonsPanel, Panel):
404     bl_label = "Stamp"
405     bl_options = {'DEFAULT_CLOSED'}
406     COMPAT_ENGINES = {'BLENDER_RENDER'}
407
408     def draw_header(self, context):
409         rd = context.scene.render
410
411         self.layout.prop(rd, "use_stamp", text="")
412
413     def draw(self, context):
414         layout = self.layout
415
416         rd = context.scene.render
417
418         layout.active = rd.use_stamp
419
420         split = layout.split()
421
422         col = split.column()
423         col.prop(rd, "use_stamp_time", text=_("Time"))
424         col.prop(rd, "use_stamp_date", text=_("Date"))
425         col.prop(rd, "use_stamp_render_time", text=_("RenderTime"))
426         col.prop(rd, "use_stamp_frame", text=_("Frame"))
427         col.prop(rd, "use_stamp_scene", text=_("Scene"))
428         col.prop(rd, "use_stamp_camera", text=_("Camera"))
429         col.prop(rd, "use_stamp_lens", text=_("Lens"))
430         col.prop(rd, "use_stamp_filename", text=_("Filename"))
431         col.prop(rd, "use_stamp_marker", text=_("Marker"))
432         col.prop(rd, "use_stamp_sequencer_strip", text=_("Seq. Strip"))
433
434         col = split.column()
435         col.active = rd.use_stamp
436         col.prop(rd, "stamp_foreground", slider=True)
437         col.prop(rd, "stamp_background", slider=True)
438         col.separator()
439         col.prop(rd, "stamp_font_size", text=_("Font Size"))
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         file_format = rd.file_format
457
458         layout.prop(rd, "filepath", text="")
459
460         split = layout.split()
461
462         col = split.column()
463         col.prop(rd, "file_format", text="")
464         col.row().prop(rd, "color_mode", text=_("Color"), expand=True)
465
466         col = split.column()
467         col.prop(rd, "use_file_extension")
468         col.prop(rd, "use_overwrite")
469         col.prop(rd, "use_placeholder")
470
471         if file_format in {'AVI_JPEG', 'JPEG'}:
472             layout.prop(rd, "file_quality", slider=True)
473
474         if file_format == 'PNG':
475             layout.prop(rd, "file_quality", slider=True, text=_("Compression"))
476
477         if file_format in {'OPEN_EXR', 'MULTILAYER'}:
478             row = layout.row()
479             row.prop(rd, "exr_codec", text=_("Codec"))
480
481             if file_format == 'OPEN_EXR':
482                 row = layout.row()
483                 row.prop(rd, "use_exr_half")
484                 row.prop(rd, "exr_zbuf")
485                 row.prop(rd, "exr_preview")
486
487         elif file_format == 'JPEG2000':
488             split = layout.split()
489             col = split.column()
490             col.label(text=_("Depth:"))
491             col.row().prop(rd, "jpeg2k_depth", expand=True)
492
493             col = split.column()
494             col.prop(rd, "jpeg2k_preset", text="")
495             col.prop(rd, "jpeg2k_ycc")
496
497         elif file_format in {'CINEON', 'DPX'}:
498
499             split = layout.split()
500             split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
501             '''
502             col = split.column()
503             col.prop(rd, "use_cineon_log", text=_("Convert to Log"))
504
505             col = split.column(align=True)
506             col.active = rd.use_cineon_log
507             col.prop(rd, "cineon_black", text=_("Black"))
508             col.prop(rd, "cineon_white", text=_("White"))
509             col.prop(rd, "cineon_gamma", text=_("Gamma"))
510             '''
511
512         elif file_format == 'TIFF':
513             layout.prop(rd, "use_tiff_16bit")
514
515         elif file_format == 'QUICKTIME_CARBON':
516             layout.operator("scene.render_data_set_quicktime_codec")
517
518         elif file_format == 'QUICKTIME_QTKIT':
519             split = layout.split()
520             col = split.column()
521             col.prop(rd, "quicktime_codec_type", text=_("Video Codec"))
522             col.prop(rd, "quicktime_codec_spatial_quality", text=_("Quality"))
523
524             # Audio
525             col.prop(rd, "quicktime_audiocodec_type", text=_("Audio Codec"))
526             if rd.quicktime_audiocodec_type != 'No audio':
527                 split = layout.split()
528                 if rd.quicktime_audiocodec_type == 'LPCM':
529                     split.prop(rd, "quicktime_audio_bitdepth", text="")
530
531                 split.prop(rd, "quicktime_audio_samplerate", text="")
532
533                 split = layout.split()
534                 col = split.column()
535                 if rd.quicktime_audiocodec_type == 'AAC':
536                     col.prop(rd, "quicktime_audio_bitrate")
537
538                 subsplit = split.split()
539                 col = subsplit.column()
540
541                 if rd.quicktime_audiocodec_type == 'AAC':
542                     col.prop(rd, "quicktime_audio_codec_isvbr")
543
544                 col = subsplit.column()
545                 col.prop(rd, "quicktime_audio_resampling_hq")
546
547
548 class RENDER_PT_encoding(RenderButtonsPanel, Panel):
549     bl_label = "Encoding"
550     bl_options = {'DEFAULT_CLOSED'}
551     COMPAT_ENGINES = {'BLENDER_RENDER'}
552
553     @classmethod
554     def poll(cls, context):
555         rd = context.scene.render
556         return rd.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
557
558     def draw(self, context):
559         layout = self.layout
560
561         rd = context.scene.render
562
563         layout.menu("RENDER_MT_ffmpeg_presets", text=_("Presets"))
564
565         split = layout.split()
566         split.prop(rd, "ffmpeg_format")
567         if rd.ffmpeg_format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
568             split.prop(rd, "ffmpeg_codec")
569         else:
570             split.label()
571
572         row = layout.row()
573         row.prop(rd, "ffmpeg_video_bitrate")
574         row.prop(rd, "ffmpeg_gopsize")
575
576         split = layout.split()
577
578         col = split.column()
579         col.label(text=_("Rate:"))
580         col.prop(rd, "ffmpeg_minrate", text=_("Minimum"))
581         col.prop(rd, "ffmpeg_maxrate", text=_("Maximum"))
582         col.prop(rd, "ffmpeg_buffersize", text=_("Buffer"))
583
584         col = split.column()
585         col.prop(rd, "ffmpeg_autosplit")
586         col.label(text=_("Mux:"))
587         col.prop(rd, "ffmpeg_muxrate", text=_("Rate"))
588         col.prop(rd, "ffmpeg_packetsize", text=_("Packet Size"))
589
590         layout.separator()
591
592         # Audio:
593         if rd.ffmpeg_format not in {'MP3'}:
594             layout.prop(rd, "ffmpeg_audio_codec", text=_("Audio Codec"))
595
596         row = layout.row()
597         row.prop(rd, "ffmpeg_audio_bitrate")
598         row.prop(rd, "ffmpeg_audio_volume", slider=True)
599
600
601 class RENDER_PT_bake(RenderButtonsPanel, Panel):
602     bl_label = "Bake"
603     bl_options = {'DEFAULT_CLOSED'}
604     COMPAT_ENGINES = {'BLENDER_RENDER'}
605
606     def draw(self, context):
607         layout = self.layout
608
609         rd = context.scene.render
610
611         layout.operator("object.bake_image", icon='RENDER_STILL')
612
613         layout.prop(rd, "bake_type")
614
615         multires_bake = False
616         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
617             layout.prop(rd, 'use_bake_multires')
618             multires_bake = rd.use_bake_multires
619
620         if not multires_bake:
621             if rd.bake_type == 'NORMALS':
622                 layout.prop(rd, "bake_normal_space")
623             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
624                 layout.prop(rd, "use_bake_normalize")
625
626             # col.prop(rd, "bake_aa_mode")
627             # col.prop(rd, "use_bake_antialiasing")
628
629             layout.separator()
630
631             split = layout.split()
632
633             col = split.column()
634             col.prop(rd, "use_bake_clear")
635             col.prop(rd, "bake_margin")
636             col.prop(rd, "bake_quad_split", text=_("Split"))
637
638             col = split.column()
639             col.prop(rd, "use_bake_selected_to_active")
640             sub = col.column()
641             sub.active = rd.use_bake_selected_to_active
642             sub.prop(rd, "bake_distance")
643             sub.prop(rd, "bake_bias")
644         else:
645             if rd.bake_type == 'DISPLACEMENT':
646                 layout.prop(rd, "use_bake_lores_mesh")
647
648             layout.prop(rd, "use_bake_clear")
649             layout.prop(rd, "bake_margin")
650
651
652 if __name__ == "__main__":  # only for live edit.
653     bpy.utils.register_module(__name__)