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