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