Bake from multires mesh
[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_shading(RenderButtonsPanel, bpy.types.Panel):
176     bl_label = "Shading"
177     COMPAT_ENGINES = {'BLENDER_RENDER'}
178
179     def draw(self, context):
180         layout = self.layout
181
182         rd = context.scene.render
183
184         split = layout.split()
185
186         col = split.column()
187         col.prop(rd, "use_textures", text="Textures")
188         col.prop(rd, "use_shadows", text="Shadows")
189         col.prop(rd, "use_sss", text="Subsurface Scattering")
190         col.prop(rd, "use_envmaps", text="Environment Map")
191
192         col = split.column()
193         col.prop(rd, "use_raytrace", text="Ray Tracing")
194         col.prop(rd, "use_color_management")
195         col.prop(rd, "alpha_mode", text="Alpha")
196
197
198 class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel):
199     bl_label = "Performance"
200     bl_options = {'DEFAULT_CLOSED'}
201     COMPAT_ENGINES = {'BLENDER_RENDER'}
202
203     def draw(self, context):
204         layout = self.layout
205
206         rd = context.scene.render
207
208         split = layout.split()
209
210         col = split.column()
211         col.label(text="Threads:")
212         col.row().prop(rd, "threads_mode", expand=True)
213         sub = col.column()
214         sub.enabled = rd.threads_mode == 'FIXED'
215         sub.prop(rd, "threads")
216         sub = col.column(align=True)
217         sub.label(text="Tiles:")
218         sub.prop(rd, "parts_x", text="X")
219         sub.prop(rd, "parts_y", text="Y")
220
221         col = split.column()
222         col.label(text="Memory:")
223         sub = col.column()
224         sub.enabled = not (rd.use_border or rd.use_full_sample)
225         sub.prop(rd, "use_save_buffers")
226         sub = col.column()
227         sub.active = rd.use_compositing
228         sub.prop(rd, "use_free_image_textures")
229         sub.prop(rd, "use_free_unused_nodes")
230         sub = col.column()
231         sub.active = rd.use_raytrace
232         sub.label(text="Acceleration structure:")
233         sub.prop(rd, "raytrace_method", text="")
234         if rd.raytrace_method == 'OCTREE':
235             sub.prop(rd, "octree_resolution", text="Resolution")
236         else:
237             sub.prop(rd, "use_instances", text="Instances")
238         sub.prop(rd, "use_local_coords", text="Local Coordinates")
239
240
241 class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
242     bl_label = "Post Processing"
243     bl_options = {'DEFAULT_CLOSED'}
244     COMPAT_ENGINES = {'BLENDER_RENDER'}
245
246     def draw(self, context):
247         layout = self.layout
248
249         rd = context.scene.render
250
251         split = layout.split()
252
253         col = split.column()
254         col.prop(rd, "use_compositing")
255         col.prop(rd, "use_sequencer")
256
257         col = split.column()
258         col.prop(rd, "dither_intensity", text="Dither", slider=True)
259
260         layout.separator()
261
262         split = layout.split()
263
264         col = split.column()
265         col.prop(rd, "use_fields", text="Fields")
266         sub = col.column()
267         sub.active = rd.use_fields
268         sub.row().prop(rd, "field_order", expand=True)
269         sub.prop(rd, "use_fields_still", text="Still")
270
271         col = split.column()
272         col.prop(rd, "use_edge_enhance")
273         sub = col.column()
274         sub.active = rd.use_edge_enhance
275         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
276         sub.prop(rd, "edge_color", text="")
277
278
279 class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel):
280     bl_label = "Output"
281     COMPAT_ENGINES = {'BLENDER_RENDER'}
282
283     def draw(self, context):
284         layout = self.layout
285
286         rd = context.scene.render
287         file_format = rd.file_format
288
289         layout.prop(rd, "filepath", text="")
290
291         split = layout.split()
292
293         col = split.column()
294         col.prop(rd, "file_format", text="")
295         col.row().prop(rd, "color_mode", text="Color", expand=True)
296
297         col = split.column()
298         col.prop(rd, "use_file_extension")
299         col.prop(rd, "use_overwrite")
300         col.prop(rd, "use_placeholder")
301
302         if file_format in {'AVI_JPEG', 'JPEG'}:
303             layout.prop(rd, "file_quality", slider=True)
304
305         if file_format == 'PNG':
306             layout.prop(rd, "file_quality", slider=True, text="Compression")
307
308         if file_format in {'OPEN_EXR', 'MULTILAYER'}:
309             row = layout.row()
310             row.prop(rd, "exr_codec", text="Codec")
311
312             if file_format == 'OPEN_EXR':
313                 row = layout.row()
314                 row.prop(rd, "use_exr_half")
315                 row.prop(rd, "exr_zbuf")
316                 row.prop(rd, "exr_preview")
317
318         elif file_format == 'JPEG2000':
319             split = layout.split()
320             col = split.column()
321             col.label(text="Depth:")
322             col.row().prop(rd, "jpeg2k_depth", expand=True)
323
324             col = split.column()
325             col.prop(rd, "jpeg2k_preset", text="")
326             col.prop(rd, "jpeg2k_ycc")
327
328         elif file_format in {'CINEON', 'DPX'}:
329
330             split = layout.split()
331             split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
332             '''
333             col = split.column()
334             col.prop(rd, "use_cineon_log", text="Convert to Log")
335
336             col = split.column(align=True)
337             col.active = rd.use_cineon_log
338             col.prop(rd, "cineon_black", text="Black")
339             col.prop(rd, "cineon_white", text="White")
340             col.prop(rd, "cineon_gamma", text="Gamma")
341             '''
342
343         elif file_format == 'TIFF':
344             layout.prop(rd, "use_tiff_16bit")
345
346         elif file_format == 'QUICKTIME_CARBON':
347             layout.operator("scene.render_data_set_quicktime_codec")
348
349         elif file_format == 'QUICKTIME_QTKIT':
350             split = layout.split()
351             col = split.column()
352             col.prop(rd, "quicktime_codec_type", text="Video Codec")
353             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
354
355             # Audio
356             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
357             if rd.quicktime_audiocodec_type != 'No audio':
358                 split = layout.split()
359                 if rd.quicktime_audiocodec_type == 'LPCM':
360                     split.prop(rd, "quicktime_audio_bitdepth", text="")
361
362                 split.prop(rd, "quicktime_audio_samplerate", text="")
363
364                 split = layout.split()
365                 col = split.column()
366                 if rd.quicktime_audiocodec_type == 'AAC':
367                     col.prop(rd, "quicktime_audio_bitrate")
368
369                 subsplit = split.split()
370                 col = subsplit.column()
371
372                 if rd.quicktime_audiocodec_type == 'AAC':
373                     col.prop(rd, "quicktime_audio_codec_isvbr")
374
375                 col = subsplit.column()
376                 col.prop(rd, "quicktime_audio_resampling_hq")
377
378
379 class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
380     bl_label = "Encoding"
381     bl_options = {'DEFAULT_CLOSED'}
382     COMPAT_ENGINES = {'BLENDER_RENDER'}
383
384     @classmethod
385     def poll(cls, context):
386         rd = context.scene.render
387         return rd.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
388
389     def draw(self, context):
390         layout = self.layout
391
392         rd = context.scene.render
393
394         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
395
396         split = layout.split()
397         split.prop(rd, "ffmpeg_format")
398         if rd.ffmpeg_format in {'AVI', 'QUICKTIME', 'MKV', 'OGG'}:
399             split.prop(rd, "ffmpeg_codec")
400         else:
401             split.label()
402
403         row = layout.row()
404         row.prop(rd, "ffmpeg_video_bitrate")
405         row.prop(rd, "ffmpeg_gopsize")
406
407         split = layout.split()
408
409         col = split.column()
410         col.label(text="Rate:")
411         col.prop(rd, "ffmpeg_minrate", text="Minimum")
412         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
413         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
414
415         col = split.column()
416         col.prop(rd, "ffmpeg_autosplit")
417         col.label(text="Mux:")
418         col.prop(rd, "ffmpeg_muxrate", text="Rate")
419         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
420
421         layout.separator()
422
423         # Audio:
424         if rd.ffmpeg_format not in {'MP3'}:
425             layout.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
426
427         split = layout.split()
428
429         col = split.column()
430         col.prop(rd, "ffmpeg_audio_bitrate")
431         col.prop(rd, "ffmpeg_audio_mixrate")
432
433         split.prop(rd, "ffmpeg_audio_volume", slider=True)
434
435
436 class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
437     bl_label = "Anti-Aliasing"
438     COMPAT_ENGINES = {'BLENDER_RENDER'}
439
440     def draw_header(self, context):
441         rd = context.scene.render
442
443         self.layout.prop(rd, "use_antialiasing", text="")
444
445     def draw(self, context):
446         layout = self.layout
447
448         rd = context.scene.render
449         layout.active = rd.use_antialiasing
450
451         split = layout.split()
452
453         col = split.column()
454         col.row().prop(rd, "antialiasing_samples", expand=True)
455         sub = col.row()
456         sub.enabled = not rd.use_border
457         sub.prop(rd, "use_full_sample")
458
459         col = split.column()
460         col.prop(rd, "pixel_filter_type", text="")
461         col.prop(rd, "filter_size", text="Size")
462
463
464 class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
465     bl_label = "Sampled Motion Blur"
466     bl_options = {'DEFAULT_CLOSED'}
467     COMPAT_ENGINES = {'BLENDER_RENDER'}
468
469     @classmethod
470     def poll(cls, context):
471         rd = context.scene.render
472         return not rd.use_full_sample and (rd.engine in cls.COMPAT_ENGINES)
473
474     def draw_header(self, context):
475         rd = context.scene.render
476
477         self.layout.prop(rd, "use_motion_blur", text="")
478
479     def draw(self, context):
480         layout = self.layout
481
482         rd = context.scene.render
483         layout.active = rd.use_motion_blur
484
485         row = layout.row()
486         row.prop(rd, "motion_blur_samples")
487         row.prop(rd, "motion_blur_shutter")
488
489
490 class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
491     bl_label = "Dimensions"
492     COMPAT_ENGINES = {'BLENDER_RENDER'}
493
494     def draw(self, context):
495         layout = self.layout
496
497         scene = context.scene
498         rd = scene.render
499
500         row = layout.row(align=True)
501         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
502         row.operator("render.preset_add", text="", icon="ZOOMIN")
503         row.operator("render.preset_add", text="", icon="ZOOMOUT").remove_active = True
504
505         split = layout.split()
506
507         col = split.column()
508         sub = col.column(align=True)
509         sub.label(text="Resolution:")
510         sub.prop(rd, "resolution_x", text="X")
511         sub.prop(rd, "resolution_y", text="Y")
512         sub.prop(rd, "resolution_percentage", text="")
513
514         sub.label(text="Aspect Ratio:")
515         sub.prop(rd, "pixel_aspect_x", text="X")
516         sub.prop(rd, "pixel_aspect_y", text="Y")
517
518         row = col.row()
519         row.prop(rd, "use_border", text="Border")
520         sub = row.row()
521         sub.active = rd.use_border
522         sub.prop(rd, "use_crop_to_border", text="Crop")
523
524         col = split.column()
525         sub = col.column(align=True)
526         sub.label(text="Frame Range:")
527         sub.prop(scene, "frame_start", text="Start")
528         sub.prop(scene, "frame_end", text="End")
529         sub.prop(scene, "frame_step", text="Step")
530
531         sub.label(text="Frame Rate:")
532         if rd.fps_base == 1:
533             fps_rate = round(rd.fps / rd.fps_base)
534         else:
535             fps_rate = round(rd.fps / rd.fps_base, 2)
536
537         # TODO: Change the following to iterate over existing presets
538         custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60})
539
540         if custom_framerate == True:
541             fps_label_text = "Custom (" + str(fps_rate) + " fps)"
542         else:
543             fps_label_text = str(fps_rate) + " fps"
544
545         sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
546
547         if custom_framerate or (bpy.types.RENDER_MT_framerate_presets.bl_label == "Custom"):
548             sub.prop(rd, "fps")
549             sub.prop(rd, "fps_base", text="/")
550         subrow = sub.row(align=True)
551         subrow.label(text="Time Remapping:")
552         subrow = sub.row(align=True)
553         subrow.prop(rd, "frame_map_old", text="Old")
554         subrow.prop(rd, "frame_map_new", text="New")
555
556
557 class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
558     bl_label = "Stamp"
559     bl_options = {'DEFAULT_CLOSED'}
560     COMPAT_ENGINES = {'BLENDER_RENDER'}
561
562     def draw_header(self, context):
563         rd = context.scene.render
564
565         self.layout.prop(rd, "use_stamp", text="")
566
567     def draw(self, context):
568         layout = self.layout
569
570         rd = context.scene.render
571
572         layout.active = rd.use_stamp
573
574         split = layout.split()
575
576         col = split.column()
577         col.prop(rd, "use_stamp_time", text="Time")
578         col.prop(rd, "use_stamp_date", text="Date")
579         col.prop(rd, "use_stamp_render_time", text="RenderTime")
580         col.prop(rd, "use_stamp_frame", text="Frame")
581         col.prop(rd, "use_stamp_scene", text="Scene")
582         col.prop(rd, "use_stamp_camera", text="Camera")
583         col.prop(rd, "use_stamp_lens", text="Lens")
584         col.prop(rd, "use_stamp_filename", text="Filename")
585         col.prop(rd, "use_stamp_marker", text="Marker")
586         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
587
588         col = split.column()
589         col.active = rd.use_stamp
590         col.prop(rd, "stamp_foreground", slider=True)
591         col.prop(rd, "stamp_background", slider=True)
592         col.separator()
593         col.prop(rd, "stamp_font_size", text="Font Size")
594
595         row = layout.split(percentage=0.2)
596         row.prop(rd, "use_stamp_note", text="Note")
597         sub = row.row()
598         sub.active = rd.use_stamp_note
599         sub.prop(rd, "stamp_note_text", text="")
600
601
602 class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
603     bl_label = "Bake"
604     bl_options = {'DEFAULT_CLOSED'}
605     COMPAT_ENGINES = {'BLENDER_RENDER'}
606
607     def draw(self, context):
608         layout = self.layout
609
610         rd = context.scene.render
611
612         layout.operator("object.bake_image", icon='RENDER_STILL')
613
614         layout.prop(rd, "bake_type")
615
616         multires_bake = False
617         if rd.bake_type in ['NORMALS', 'DISPLACEMENT']:
618             layout.prop(rd, 'use_bake_multires')
619             multires_bake = rd.use_bake_multires
620
621         if not multires_bake:
622             if rd.bake_type == 'NORMALS':
623                 layout.prop(rd, "bake_normal_space")
624             elif rd.bake_type in {'DISPLACEMENT', 'AO'}:
625                 layout.prop(rd, "use_bake_normalize")
626
627             # col.prop(rd, "bake_aa_mode")
628             # col.prop(rd, "use_bake_antialiasing")
629
630             layout.separator()
631
632             split = layout.split()
633
634             col = split.column()
635             col.prop(rd, "use_bake_clear")
636             col.prop(rd, "bake_margin")
637             col.prop(rd, "bake_quad_split", text="Split")
638
639             col = split.column()
640             col.prop(rd, "use_bake_selected_to_active")
641             sub = col.column()
642             sub.active = rd.use_bake_selected_to_active
643             sub.prop(rd, "bake_distance")
644             sub.prop(rd, "bake_bias")
645         else:
646             if rd.bake_type == 'DISPLACEMENT':
647                 layout.prop(rd, "use_bake_lores_mesh")
648
649             layout.prop(rd, "use_bake_clear")
650             layout.prop(rd, "bake_margin")
651
652 if __name__ == "__main__":  # only for live edit.
653     bpy.utils.register_module(__name__)