remove use of gettext: _("...") style translation now its handled by rna.
[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         file_format = rd.file_format
456
457         layout.prop(rd, "filepath", text="")
458
459         split = layout.split()
460
461         col = split.column()
462         col.prop(rd, "file_format", text="")
463         col.row().prop(rd, "color_mode", text="Color", expand=True)
464
465         col = split.column()
466         col.prop(rd, "use_file_extension")
467         col.prop(rd, "use_overwrite")
468         col.prop(rd, "use_placeholder")
469
470         if file_format in {'AVI_JPEG', 'JPEG'}:
471             layout.prop(rd, "file_quality", slider=True)
472
473         if file_format == 'PNG':
474             layout.prop(rd, "file_quality", slider=True, text="Compression")
475
476         if file_format in {'OPEN_EXR', 'MULTILAYER'}:
477             row = layout.row()
478             row.prop(rd, "exr_codec", text="Codec")
479
480             if file_format == 'OPEN_EXR':
481                 row = layout.row()
482                 row.prop(rd, "use_exr_half")
483                 row.prop(rd, "exr_zbuf")
484                 row.prop(rd, "exr_preview")
485
486         elif file_format == 'JPEG2000':
487             split = layout.split()
488             col = split.column()
489             col.label(text="Depth:")
490             col.row().prop(rd, "jpeg2k_depth", expand=True)
491
492             col = split.column()
493             col.prop(rd, "jpeg2k_preset", text="")
494             col.prop(rd, "jpeg2k_ycc")
495
496         elif file_format in {'CINEON', 'DPX'}:
497
498             split = layout.split()
499             split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
500             '''
501             col = split.column()
502             col.prop(rd, "use_cineon_log", text="Convert to Log")
503
504             col = split.column(align=True)
505             col.active = rd.use_cineon_log
506             col.prop(rd, "cineon_black", text="Black")
507             col.prop(rd, "cineon_white", text="White")
508             col.prop(rd, "cineon_gamma", text="Gamma")
509             '''
510
511         elif file_format == 'TIFF':
512             layout.prop(rd, "use_tiff_16bit")
513
514         elif file_format == 'QUICKTIME_CARBON':
515             layout.operator("scene.render_data_set_quicktime_codec")
516
517         elif file_format == 'QUICKTIME_QTKIT':
518             split = layout.split()
519             col = split.column()
520             col.prop(rd, "quicktime_codec_type", text="Video Codec")
521             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
522
523             # Audio
524             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
525             if rd.quicktime_audiocodec_type != 'No audio':
526                 split = layout.split()
527                 if rd.quicktime_audiocodec_type == 'LPCM':
528                     split.prop(rd, "quicktime_audio_bitdepth", text="")
529
530                 split.prop(rd, "quicktime_audio_samplerate", text="")
531
532                 split = layout.split()
533                 col = split.column()
534                 if rd.quicktime_audiocodec_type == 'AAC':
535                     col.prop(rd, "quicktime_audio_bitrate")
536
537                 subsplit = split.split()
538                 col = subsplit.column()
539
540                 if rd.quicktime_audiocodec_type == 'AAC':
541                     col.prop(rd, "quicktime_audio_codec_isvbr")
542
543                 col = subsplit.column()
544                 col.prop(rd, "quicktime_audio_resampling_hq")
545
546
547 class RENDER_PT_encoding(RenderButtonsPanel, Panel):
548     bl_label = "Encoding"
549     bl_options = {'DEFAULT_CLOSED'}
550     COMPAT_ENGINES = {'BLENDER_RENDER'}
551
552     @classmethod
553     def poll(cls, context):
554         rd = context.scene.render
555         return rd.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
556
557     def draw(self, context):
558         layout = self.layout
559
560         rd = context.scene.render
561
562         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
563
564         split = layout.split()
565         split.prop(rd, "ffmpeg_format")
566         if rd.ffmpeg_format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
567             split.prop(rd, "ffmpeg_codec")
568         else:
569             split.label()
570
571         row = layout.row()
572         row.prop(rd, "ffmpeg_video_bitrate")
573         row.prop(rd, "ffmpeg_gopsize")
574
575         split = layout.split()
576
577         col = split.column()
578         col.label(text="Rate:")
579         col.prop(rd, "ffmpeg_minrate", text="Minimum")
580         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
581         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
582
583         col = split.column()
584         col.prop(rd, "ffmpeg_autosplit")
585         col.label(text="Mux:")
586         col.prop(rd, "ffmpeg_muxrate", text="Rate")
587         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
588
589         layout.separator()
590
591         # Audio:
592         if rd.ffmpeg_format not in {'MP3'}:
593             layout.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
594
595         row = layout.row()
596         row.prop(rd, "ffmpeg_audio_bitrate")
597         row.prop(rd, "ffmpeg_audio_volume", slider=True)
598
599
600 class RENDER_PT_bake(RenderButtonsPanel, Panel):
601     bl_label = "Bake"
602     bl_options = {'DEFAULT_CLOSED'}
603     COMPAT_ENGINES = {'BLENDER_RENDER'}
604
605     def draw(self, context):
606         layout = self.layout
607
608         rd = context.scene.render
609
610         layout.operator("object.bake_image", icon='RENDER_STILL')
611
612         layout.prop(rd, "bake_type")
613
614         multires_bake = False
615         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
616             layout.prop(rd, 'use_bake_multires')
617             multires_bake = rd.use_bake_multires
618
619         if not multires_bake:
620             if rd.bake_type == 'NORMALS':
621                 layout.prop(rd, "bake_normal_space")
622             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
623                 layout.prop(rd, "use_bake_normalize")
624
625             # col.prop(rd, "bake_aa_mode")
626             # col.prop(rd, "use_bake_antialiasing")
627
628             layout.separator()
629
630             split = layout.split()
631
632             col = split.column()
633             col.prop(rd, "use_bake_clear")
634             col.prop(rd, "bake_margin")
635             col.prop(rd, "bake_quad_split", text="Split")
636
637             col = split.column()
638             col.prop(rd, "use_bake_selected_to_active")
639             sub = col.column()
640             sub.active = rd.use_bake_selected_to_active
641             sub.prop(rd, "bake_distance")
642             sub.prop(rd, "bake_bias")
643         else:
644             if rd.bake_type == 'DISPLACEMENT':
645                 layout.prop(rd, "use_bake_lores_mesh")
646
647             layout.prop(rd, "use_bake_clear")
648             layout.prop(rd, "bake_margin")
649
650
651 if __name__ == "__main__":  # only for live edit.
652     bpy.utils.register_module(__name__)