UI: fix render properties panel order, it didn't match order in startup.blend,
[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
22
23 class RENDER_MT_presets(bpy.types.Menu):
24     bl_label = "Render Presets"
25     preset_subdir = "render"
26     preset_operator = "script.execute_preset"
27     draw = bpy.types.Menu.draw_preset
28
29
30 class RENDER_MT_ffmpeg_presets(bpy.types.Menu):
31     bl_label = "FFMPEG Presets"
32     preset_subdir = "ffmpeg"
33     preset_operator = "script.python_file_run"
34     draw = bpy.types.Menu.draw_preset
35
36
37 class RENDER_MT_framerate_presets(bpy.types.Menu):
38     bl_label = "Frame Rate Presets"
39     preset_subdir = "framerate"
40     preset_operator = "script.execute_preset"
41     draw = bpy.types.Menu.draw_preset
42
43
44 class RenderButtonsPanel():
45     bl_space_type = 'PROPERTIES'
46     bl_region_type = 'WINDOW'
47     bl_context = "render"
48     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
49
50     @classmethod
51     def poll(cls, context):
52         rd = context.scene.render
53         return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
54
55
56 class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel):
57     bl_label = "Render"
58     COMPAT_ENGINES = {'BLENDER_RENDER'}
59
60     def draw(self, context):
61         layout = self.layout
62
63         rd = context.scene.render
64
65         row = layout.row()
66         row.operator("render.render", text="Image", icon='RENDER_STILL')
67         row.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
68
69         layout.prop(rd, "display_mode", text="Display")
70
71
72 class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel):
73     bl_label = "Layers"
74     bl_options = {'DEFAULT_CLOSED'}
75     COMPAT_ENGINES = {'BLENDER_RENDER'}
76
77     def draw(self, context):
78         layout = self.layout
79
80         scene = context.scene
81         rd = scene.render
82
83         row = layout.row()
84         row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
85
86         col = row.column(align=True)
87         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
88         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
89
90         row = layout.row()
91         rl = rd.layers.active
92         if rl:
93             row.prop(rl, "name")
94         row.prop(rd, "use_single_layer", text="", icon_only=True)
95
96         split = layout.split()
97
98         col = split.column()
99         col.prop(scene, "layers", text="Scene")
100         col.label(text="")
101         col.prop(rl, "light_override", text="Light")
102         col.prop(rl, "material_override", text="Material")
103
104         col = split.column()
105         col.prop(rl, "layers", text="Layer")
106         col.label(text="Mask Layers:")
107         col.prop(rl, "layers_zmask", text="")
108
109         layout.separator()
110         layout.label(text="Include:")
111
112         split = layout.split()
113
114         col = split.column()
115         col.prop(rl, "use_zmask")
116         row = col.row()
117         row.prop(rl, "invert_zmask", text="Negate")
118         row.active = rl.use_zmask
119         col.prop(rl, "use_all_z")
120
121         col = split.column()
122         col.prop(rl, "use_solid")
123         col.prop(rl, "use_halo")
124         col.prop(rl, "use_ztransp")
125
126         col = split.column()
127         col.prop(rl, "use_sky")
128         col.prop(rl, "use_edge_enhance")
129         col.prop(rl, "use_strand")
130
131         layout.separator()
132
133         split = layout.split()
134
135         col = split.column()
136         col.label(text="Passes:")
137         col.prop(rl, "use_pass_combined")
138         col.prop(rl, "use_pass_z")
139         col.prop(rl, "use_pass_vector")
140         col.prop(rl, "use_pass_normal")
141         col.prop(rl, "use_pass_uv")
142         col.prop(rl, "use_pass_mist")
143         col.prop(rl, "use_pass_object_index")
144         col.prop(rl, "use_pass_color")
145
146         col = split.column()
147         col.label()
148         col.prop(rl, "use_pass_diffuse")
149         row = col.row()
150         row.prop(rl, "use_pass_specular")
151         row.prop(rl, "exclude_specular", text="")
152         row = col.row()
153         row.prop(rl, "use_pass_shadow")
154         row.prop(rl, "exclude_shadow", text="")
155         row = col.row()
156         row.prop(rl, "use_pass_emit")
157         row.prop(rl, "exclude_emit", text="")
158         row = col.row()
159         row.prop(rl, "use_pass_ambient_occlusion")
160         row.prop(rl, "exclude_ambient_occlusion", text="")
161         row = col.row()
162         row.prop(rl, "use_pass_environment")
163         row.prop(rl, "exclude_environment", text="")
164         row = col.row()
165         row.prop(rl, "use_pass_indirect")
166         row.prop(rl, "exclude_indirect", text="")
167         row = col.row()
168         row.prop(rl, "use_pass_reflection")
169         row.prop(rl, "exclude_reflection", text="")
170         row = col.row()
171         row.prop(rl, "use_pass_refraction")
172         row.prop(rl, "exclude_refraction", text="")
173
174
175 class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
176     bl_label = "Dimensions"
177     COMPAT_ENGINES = {'BLENDER_RENDER'}
178
179     def draw(self, context):
180         layout = self.layout
181
182         scene = context.scene
183         rd = scene.render
184
185         row = layout.row(align=True)
186         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
187         row.operator("render.preset_add", text="", icon="ZOOMIN")
188         row.operator("render.preset_add", text="", icon="ZOOMOUT").remove_active = True
189
190         split = layout.split()
191
192         col = split.column()
193         sub = col.column(align=True)
194         sub.label(text="Resolution:")
195         sub.prop(rd, "resolution_x", text="X")
196         sub.prop(rd, "resolution_y", text="Y")
197         sub.prop(rd, "resolution_percentage", text="")
198
199         sub.label(text="Aspect Ratio:")
200         sub.prop(rd, "pixel_aspect_x", text="X")
201         sub.prop(rd, "pixel_aspect_y", text="Y")
202
203         row = col.row()
204         row.prop(rd, "use_border", text="Border")
205         sub = row.row()
206         sub.active = rd.use_border
207         sub.prop(rd, "use_crop_to_border", text="Crop")
208
209         col = split.column()
210         sub = col.column(align=True)
211         sub.label(text="Frame Range:")
212         sub.prop(scene, "frame_start", text="Start")
213         sub.prop(scene, "frame_end", text="End")
214         sub.prop(scene, "frame_step", text="Step")
215
216         sub.label(text="Frame Rate:")
217         if rd.fps_base == 1:
218             fps_rate = round(rd.fps / rd.fps_base)
219         else:
220             fps_rate = round(rd.fps / rd.fps_base, 2)
221
222         # TODO: Change the following to iterate over existing presets
223         custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60})
224
225         if custom_framerate == True:
226             fps_label_text = "Custom (" + str(fps_rate) + " fps)"
227         else:
228             fps_label_text = str(fps_rate) + " fps"
229
230         sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
231
232         if custom_framerate or (bpy.types.RENDER_MT_framerate_presets.bl_label == "Custom"):
233             sub.prop(rd, "fps")
234             sub.prop(rd, "fps_base", text="/")
235         subrow = sub.row(align=True)
236         subrow.label(text="Time Remapping:")
237         subrow = sub.row(align=True)
238         subrow.prop(rd, "frame_map_old", text="Old")
239         subrow.prop(rd, "frame_map_new", text="New")
240
241
242 class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
243     bl_label = "Anti-Aliasing"
244     COMPAT_ENGINES = {'BLENDER_RENDER'}
245
246     def draw_header(self, context):
247         rd = context.scene.render
248
249         self.layout.prop(rd, "use_antialiasing", text="")
250
251     def draw(self, context):
252         layout = self.layout
253
254         rd = context.scene.render
255         layout.active = rd.use_antialiasing
256
257         split = layout.split()
258
259         col = split.column()
260         col.row().prop(rd, "antialiasing_samples", expand=True)
261         sub = col.row()
262         sub.enabled = not rd.use_border
263         sub.prop(rd, "use_full_sample")
264
265         col = split.column()
266         col.prop(rd, "pixel_filter_type", text="")
267         col.prop(rd, "filter_size", text="Size")
268
269
270 class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
271     bl_label = "Sampled Motion Blur"
272     bl_options = {'DEFAULT_CLOSED'}
273     COMPAT_ENGINES = {'BLENDER_RENDER'}
274
275     @classmethod
276     def poll(cls, context):
277         rd = context.scene.render
278         return not rd.use_full_sample and (rd.engine in cls.COMPAT_ENGINES)
279
280     def draw_header(self, context):
281         rd = context.scene.render
282
283         self.layout.prop(rd, "use_motion_blur", text="")
284
285     def draw(self, context):
286         layout = self.layout
287
288         rd = context.scene.render
289         layout.active = rd.use_motion_blur
290
291         row = layout.row()
292         row.prop(rd, "motion_blur_samples")
293         row.prop(rd, "motion_blur_shutter")
294
295
296 class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel):
297     bl_label = "Shading"
298     bl_options = {'DEFAULT_CLOSED'}
299     COMPAT_ENGINES = {'BLENDER_RENDER'}
300
301     def draw(self, context):
302         layout = self.layout
303
304         rd = context.scene.render
305
306         split = layout.split()
307
308         col = split.column()
309         col.prop(rd, "use_textures", text="Textures")
310         col.prop(rd, "use_shadows", text="Shadows")
311         col.prop(rd, "use_sss", text="Subsurface Scattering")
312         col.prop(rd, "use_envmaps", text="Environment Map")
313
314         col = split.column()
315         col.prop(rd, "use_raytrace", text="Ray Tracing")
316         col.prop(rd, "use_color_management")
317         col.prop(rd, "alpha_mode", text="Alpha")
318
319
320 class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel):
321     bl_label = "Performance"
322     bl_options = {'DEFAULT_CLOSED'}
323     COMPAT_ENGINES = {'BLENDER_RENDER'}
324
325     def draw(self, context):
326         layout = self.layout
327
328         rd = context.scene.render
329
330         split = layout.split()
331
332         col = split.column()
333         col.label(text="Threads:")
334         col.row().prop(rd, "threads_mode", expand=True)
335         sub = col.column()
336         sub.enabled = rd.threads_mode == 'FIXED'
337         sub.prop(rd, "threads")
338         sub = col.column(align=True)
339         sub.label(text="Tiles:")
340         sub.prop(rd, "parts_x", text="X")
341         sub.prop(rd, "parts_y", text="Y")
342
343         col = split.column()
344         col.label(text="Memory:")
345         sub = col.column()
346         sub.enabled = not (rd.use_border or rd.use_full_sample)
347         sub.prop(rd, "use_save_buffers")
348         sub = col.column()
349         sub.active = rd.use_compositing
350         sub.prop(rd, "use_free_image_textures")
351         sub.prop(rd, "use_free_unused_nodes")
352         sub = col.column()
353         sub.active = rd.use_raytrace
354         sub.label(text="Acceleration structure:")
355         sub.prop(rd, "raytrace_method", text="")
356         if rd.raytrace_method == 'OCTREE':
357             sub.prop(rd, "octree_resolution", text="Resolution")
358         else:
359             sub.prop(rd, "use_instances", text="Instances")
360         sub.prop(rd, "use_local_coords", text="Local Coordinates")
361
362
363 class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
364     bl_label = "Post Processing"
365     bl_options = {'DEFAULT_CLOSED'}
366     COMPAT_ENGINES = {'BLENDER_RENDER'}
367
368     def draw(self, context):
369         layout = self.layout
370
371         rd = context.scene.render
372
373         split = layout.split()
374
375         col = split.column()
376         col.prop(rd, "use_compositing")
377         col.prop(rd, "use_sequencer")
378
379         col = split.column()
380         col.prop(rd, "dither_intensity", text="Dither", slider=True)
381
382         layout.separator()
383
384         split = layout.split()
385
386         col = split.column()
387         col.prop(rd, "use_fields", text="Fields")
388         sub = col.column()
389         sub.active = rd.use_fields
390         sub.row().prop(rd, "field_order", expand=True)
391         sub.prop(rd, "use_fields_still", text="Still")
392
393         col = split.column()
394         col.prop(rd, "use_edge_enhance")
395         sub = col.column()
396         sub.active = rd.use_edge_enhance
397         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
398         sub.prop(rd, "edge_color", text="")
399
400
401 class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
402     bl_label = "Stamp"
403     bl_options = {'DEFAULT_CLOSED'}
404     COMPAT_ENGINES = {'BLENDER_RENDER'}
405
406     def draw_header(self, context):
407         rd = context.scene.render
408
409         self.layout.prop(rd, "use_stamp", text="")
410
411     def draw(self, context):
412         layout = self.layout
413
414         rd = context.scene.render
415
416         layout.active = rd.use_stamp
417
418         split = layout.split()
419
420         col = split.column()
421         col.prop(rd, "use_stamp_time", text="Time")
422         col.prop(rd, "use_stamp_date", text="Date")
423         col.prop(rd, "use_stamp_render_time", text="RenderTime")
424         col.prop(rd, "use_stamp_frame", text="Frame")
425         col.prop(rd, "use_stamp_scene", text="Scene")
426         col.prop(rd, "use_stamp_camera", text="Camera")
427         col.prop(rd, "use_stamp_lens", text="Lens")
428         col.prop(rd, "use_stamp_filename", text="Filename")
429         col.prop(rd, "use_stamp_marker", text="Marker")
430         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
431
432         col = split.column()
433         col.active = rd.use_stamp
434         col.prop(rd, "stamp_foreground", slider=True)
435         col.prop(rd, "stamp_background", slider=True)
436         col.separator()
437         col.prop(rd, "stamp_font_size", text="Font Size")
438
439         row = layout.split(percentage=0.2)
440         row.prop(rd, "use_stamp_note", text="Note")
441         sub = row.row()
442         sub.active = rd.use_stamp_note
443         sub.prop(rd, "stamp_note_text", text="")
444
445
446 class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel):
447     bl_label = "Output"
448     COMPAT_ENGINES = {'BLENDER_RENDER'}
449
450     def draw(self, context):
451         layout = self.layout
452
453         rd = context.scene.render
454         file_format = rd.file_format
455
456         layout.prop(rd, "filepath", text="")
457
458         split = layout.split()
459
460         col = split.column()
461         col.prop(rd, "file_format", text="")
462         col.row().prop(rd, "color_mode", text="Color", expand=True)
463
464         col = split.column()
465         col.prop(rd, "use_file_extension")
466         col.prop(rd, "use_overwrite")
467         col.prop(rd, "use_placeholder")
468
469         if file_format in {'AVI_JPEG', 'JPEG'}:
470             layout.prop(rd, "file_quality", slider=True)
471
472         if file_format == 'PNG':
473             layout.prop(rd, "file_quality", slider=True, text="Compression")
474
475         if file_format in {'OPEN_EXR', 'MULTILAYER'}:
476             row = layout.row()
477             row.prop(rd, "exr_codec", text="Codec")
478
479             if file_format == 'OPEN_EXR':
480                 row = layout.row()
481                 row.prop(rd, "use_exr_half")
482                 row.prop(rd, "exr_zbuf")
483                 row.prop(rd, "exr_preview")
484
485         elif file_format == 'JPEG2000':
486             split = layout.split()
487             col = split.column()
488             col.label(text="Depth:")
489             col.row().prop(rd, "jpeg2k_depth", expand=True)
490
491             col = split.column()
492             col.prop(rd, "jpeg2k_preset", text="")
493             col.prop(rd, "jpeg2k_ycc")
494
495         elif file_format in {'CINEON', 'DPX'}:
496
497             split = layout.split()
498             split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
499             '''
500             col = split.column()
501             col.prop(rd, "use_cineon_log", text="Convert to Log")
502
503             col = split.column(align=True)
504             col.active = rd.use_cineon_log
505             col.prop(rd, "cineon_black", text="Black")
506             col.prop(rd, "cineon_white", text="White")
507             col.prop(rd, "cineon_gamma", text="Gamma")
508             '''
509
510         elif file_format == 'TIFF':
511             layout.prop(rd, "use_tiff_16bit")
512
513         elif file_format == 'QUICKTIME_CARBON':
514             layout.operator("scene.render_data_set_quicktime_codec")
515
516         elif file_format == 'QUICKTIME_QTKIT':
517             split = layout.split()
518             col = split.column()
519             col.prop(rd, "quicktime_codec_type", text="Video Codec")
520             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
521
522             # Audio
523             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
524             if rd.quicktime_audiocodec_type != 'No audio':
525                 split = layout.split()
526                 if rd.quicktime_audiocodec_type == 'LPCM':
527                     split.prop(rd, "quicktime_audio_bitdepth", text="")
528
529                 split.prop(rd, "quicktime_audio_samplerate", text="")
530
531                 split = layout.split()
532                 col = split.column()
533                 if rd.quicktime_audiocodec_type == 'AAC':
534                     col.prop(rd, "quicktime_audio_bitrate")
535
536                 subsplit = split.split()
537                 col = subsplit.column()
538
539                 if rd.quicktime_audiocodec_type == 'AAC':
540                     col.prop(rd, "quicktime_audio_codec_isvbr")
541
542                 col = subsplit.column()
543                 col.prop(rd, "quicktime_audio_resampling_hq")
544
545
546 class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
547     bl_label = "Encoding"
548     bl_options = {'DEFAULT_CLOSED'}
549     COMPAT_ENGINES = {'BLENDER_RENDER'}
550
551     @classmethod
552     def poll(cls, context):
553         rd = context.scene.render
554         return rd.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
555
556     def draw(self, context):
557         layout = self.layout
558
559         rd = context.scene.render
560
561         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
562
563         split = layout.split()
564         split.prop(rd, "ffmpeg_format")
565         if rd.ffmpeg_format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
566             split.prop(rd, "ffmpeg_codec")
567         else:
568             split.label()
569
570         row = layout.row()
571         row.prop(rd, "ffmpeg_video_bitrate")
572         row.prop(rd, "ffmpeg_gopsize")
573
574         split = layout.split()
575
576         col = split.column()
577         col.label(text="Rate:")
578         col.prop(rd, "ffmpeg_minrate", text="Minimum")
579         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
580         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
581
582         col = split.column()
583         col.prop(rd, "ffmpeg_autosplit")
584         col.label(text="Mux:")
585         col.prop(rd, "ffmpeg_muxrate", text="Rate")
586         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
587
588         layout.separator()
589
590         # Audio:
591         if rd.ffmpeg_format not in {'MP3'}:
592             layout.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
593
594         split = layout.split()
595
596         col = split.column()
597         col.prop(rd, "ffmpeg_audio_bitrate")
598         col.prop(rd, "ffmpeg_audio_mixrate")
599
600         split.prop(rd, "ffmpeg_audio_volume", slider=True)
601
602
603 class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
604     bl_label = "Bake"
605     bl_options = {'DEFAULT_CLOSED'}
606     COMPAT_ENGINES = {'BLENDER_RENDER'}
607
608     def draw(self, context):
609         layout = self.layout
610
611         rd = context.scene.render
612
613         layout.operator("object.bake_image", icon='RENDER_STILL')
614
615         layout.prop(rd, "bake_type")
616
617         multires_bake = False
618         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
619             layout.prop(rd, 'use_bake_multires')
620             multires_bake = rd.use_bake_multires
621
622         if not multires_bake:
623             if rd.bake_type == 'NORMALS':
624                 layout.prop(rd, "bake_normal_space")
625             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
626                 layout.prop(rd, "use_bake_normalize")
627
628             # col.prop(rd, "bake_aa_mode")
629             # col.prop(rd, "use_bake_antialiasing")
630
631             layout.separator()
632
633             split = layout.split()
634
635             col = split.column()
636             col.prop(rd, "use_bake_clear")
637             col.prop(rd, "bake_margin")
638             col.prop(rd, "bake_quad_split", text="Split")
639
640             col = split.column()
641             col.prop(rd, "use_bake_selected_to_active")
642             sub = col.column()
643             sub.active = rd.use_bake_selected_to_active
644             sub.prop(rd, "bake_distance")
645             sub.prop(rd, "bake_bias")
646         else:
647             if rd.bake_type == 'DISPLACEMENT':
648                 layout.prop(rd, "use_bake_lores_mesh")
649
650             layout.prop(rd, "use_bake_clear")
651             layout.prop(rd, "bake_margin")
652
653
654 if __name__ == "__main__":  # only for live edit.
655     bpy.utils.register_module(__name__)