7b080445aee9226bb73f5e7605b46a9027e9db34
[blender.git] / release / scripts / 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 RenderButtonsPanel():
38     bl_space_type = 'PROPERTIES'
39     bl_region_type = 'WINDOW'
40     bl_context = "render"
41     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
42
43
44 class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel):
45     bl_label = "Render"
46     COMPAT_ENGINES = {'BLENDER_RENDER'}
47
48     @staticmethod
49     def poll(context):
50         rd = context.scene.render
51         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
52
53     def draw(self, context):
54         layout = self.layout
55
56         rd = context.scene.render
57
58         split = layout.split()
59
60         col = split.column()
61         col.operator("render.render", text="Image", icon='RENDER_STILL')
62
63         col = split.column()
64         col.operator("render.render", text="Animation", icon='RENDER_ANIMATION').animation = True
65
66         layout.prop(rd, "display_mode", text="Display")
67
68
69 class RENDER_PT_layers(RenderButtonsPanel, bpy.types.Panel):
70     bl_label = "Layers"
71     bl_default_closed = True
72     COMPAT_ENGINES = {'BLENDER_RENDER'}
73
74     @staticmethod
75     def poll(context):
76         rd = context.scene.render
77         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
78
79     def draw(self, context):
80         layout = self.layout
81
82         scene = context.scene
83         rd = scene.render
84
85         row = layout.row()
86         row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
87
88         col = row.column(align=True)
89         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
90         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
91
92         rl = rd.layers[rd.active_layer_index]
93
94         if rl:
95             layout.prop(rl, "name")
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, "visible_layers", text="Layer")
107         col.label(text="Mask Layers:")
108         col.prop(rl, "zmask_layers", text="")
109
110
111         layout.separator()
112         layout.label(text="Include:")
113
114         split = layout.split()
115
116         col = split.column()
117         col.prop(rl, "zmask")
118         row = col.row()
119         row.prop(rl, "zmask_negate", text="Negate")
120         row.active = rl.zmask
121         col.prop(rl, "all_z")
122
123         col = split.column()
124         col.prop(rl, "solid")
125         col.prop(rl, "halo")
126         col.prop(rl, "ztransp")
127
128         col = split.column()
129         col.prop(rl, "sky")
130         col.prop(rl, "edge")
131         col.prop(rl, "strand")
132
133         layout.separator()
134
135         split = layout.split()
136
137         col = split.column()
138         col.label(text="Passes:")
139         col.prop(rl, "pass_combined")
140         col.prop(rl, "pass_z")
141         col.prop(rl, "pass_vector")
142         col.prop(rl, "pass_normal")
143         col.prop(rl, "pass_uv")
144         col.prop(rl, "pass_mist")
145         col.prop(rl, "pass_object_index")
146         col.prop(rl, "pass_color")
147
148         col = split.column()
149         col.label()
150         col.prop(rl, "pass_diffuse")
151         row = col.row()
152         row.prop(rl, "pass_specular")
153         row.prop(rl, "pass_specular_exclude", text="")
154         row = col.row()
155         row.prop(rl, "pass_shadow")
156         row.prop(rl, "pass_shadow_exclude", text="")
157         row = col.row()
158         row.prop(rl, "pass_emit")
159         row.prop(rl, "pass_emit_exclude", text="")
160         row = col.row()
161         row.prop(rl, "pass_ao")
162         row.prop(rl, "pass_ao_exclude", text="")
163         row = col.row()
164         row.prop(rl, "pass_environment")
165         row.prop(rl, "pass_environment_exclude", text="")
166         row = col.row()
167         row.prop(rl, "pass_indirect")
168         row.prop(rl, "pass_indirect_exclude", text="")
169         row = col.row()
170         row.prop(rl, "pass_reflection")
171         row.prop(rl, "pass_reflection_exclude", text="")
172         row = col.row()
173         row.prop(rl, "pass_refraction")
174         row.prop(rl, "pass_refraction_exclude", text="")
175
176
177 class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel):
178     bl_label = "Shading"
179     COMPAT_ENGINES = {'BLENDER_RENDER'}
180
181     @staticmethod
182     def poll(context):
183         rd = context.scene.render
184         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
185
186     def draw(self, context):
187         layout = self.layout
188
189         rd = context.scene.render
190
191         split = layout.split()
192
193         col = split.column()
194         col.prop(rd, "use_textures", text="Textures")
195         col.prop(rd, "use_shadows", text="Shadows")
196         col.prop(rd, "use_sss", text="Subsurface Scattering")
197         col.prop(rd, "use_envmaps", text="Environment Map")
198
199         col = split.column()
200         col.prop(rd, "use_raytracing", text="Ray Tracing")
201         col.prop(rd, "color_management")
202         col.prop(rd, "alpha_mode", text="Alpha")
203
204
205 class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel):
206     bl_label = "Performance"
207     bl_default_closed = True
208     COMPAT_ENGINES = {'BLENDER_RENDER'}
209
210     @staticmethod
211     def poll(context):
212         rd = context.scene.render
213         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
214
215     def draw(self, context):
216         layout = self.layout
217
218         rd = context.scene.render
219
220         split = layout.split()
221
222         col = split.column()
223         col.label(text="Threads:")
224         col.row().prop(rd, "threads_mode", expand=True)
225         sub = col.column()
226         sub.enabled = rd.threads_mode == 'FIXED'
227         sub.prop(rd, "threads")
228         sub = col.column(align=True)
229         sub.label(text="Tiles:")
230         sub.prop(rd, "parts_x", text="X")
231         sub.prop(rd, "parts_y", text="Y")
232
233         col = split.column()
234         col.label(text="Memory:")
235         sub = col.column()
236         sub.enabled = not (rd.use_border or rd.full_sample)
237         sub.prop(rd, "save_buffers")
238         sub = col.column()
239         sub.active = rd.use_compositing
240         sub.prop(rd, "free_image_textures")
241         sub = col.column()
242         sub.active = rd.use_raytracing
243         sub.label(text="Acceleration structure:")
244         sub.prop(rd, "raytrace_structure", text="")
245         if rd.raytrace_structure == 'OCTREE':
246             sub.prop(rd, "octree_resolution", text="Resolution")
247         else:
248             sub.prop(rd, "use_instances", text="Instances")
249         sub.prop(rd, "use_local_coords", text="Local Coordinates")
250
251
252 class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
253     bl_label = "Post Processing"
254     bl_default_closed = True
255     COMPAT_ENGINES = {'BLENDER_RENDER'}
256
257     @staticmethod
258     def poll(context):
259         rd = context.scene.render
260         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
261
262     def draw(self, context):
263         layout = self.layout
264
265         rd = context.scene.render
266
267         split = layout.split()
268
269         col = split.column()
270         col.prop(rd, "use_compositing")
271         col.prop(rd, "use_sequencer")
272
273         col = split.column()
274         col.prop(rd, "dither_intensity", text="Dither", slider=True)
275
276         layout.separator()
277
278         split = layout.split()
279
280         col = split.column()
281         col.prop(rd, "fields", text="Fields")
282         sub = col.column()
283         sub.active = rd.fields
284         sub.row().prop(rd, "field_order", expand=True)
285         sub.prop(rd, "fields_still", text="Still")
286
287
288         col = split.column()
289         col.prop(rd, "edge")
290         sub = col.column()
291         sub.active = rd.edge
292         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
293         sub.prop(rd, "edge_color", text="")
294
295
296 class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel):
297     bl_label = "Output"
298     COMPAT_ENGINES = {'BLENDER_RENDER'}
299
300     @staticmethod
301     def poll(context):
302         rd = context.scene.render
303         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
304
305     def draw(self, context):
306         layout = self.layout
307
308         rd = context.scene.render
309         file_format = rd.file_format
310
311         layout.prop(rd, "output_path", text="")
312
313         split = layout.split()
314         col = split.column()
315         col.prop(rd, "file_format", text="")
316         col.row().prop(rd, "color_mode", text="Color", expand=True)
317
318         col = split.column()
319         col.prop(rd, "use_file_extension")
320         col.prop(rd, "use_overwrite")
321         col.prop(rd, "use_placeholder")
322
323         if file_format in ('AVI_JPEG', 'JPEG'):
324             split = layout.split()
325             split.prop(rd, "file_quality", slider=True)
326         
327         if file_format == 'PNG':
328             split = layout.split()
329             split.prop(rd, "file_quality", slider=True, text="Compression")
330
331         elif file_format == 'MULTILAYER':
332             split = layout.split()
333
334             col = split.column()
335             col.label(text="Codec:")
336             col.prop(rd, "exr_codec", text="")
337             col = split.column()
338
339         elif file_format == 'OPEN_EXR':
340             split = layout.split()
341
342             col = split.column()
343             col.label(text="Codec:")
344             col.prop(rd, "exr_codec", text="")
345
346             subsplit = split.split()
347             col = subsplit.column()
348             col.prop(rd, "exr_half")
349             col.prop(rd, "exr_zbuf")
350
351             col = subsplit.column()
352             col.prop(rd, "exr_preview")
353
354         elif file_format == 'JPEG2000':
355             split = layout.split()
356             col = split.column()
357             col.label(text="Depth:")
358             col.row().prop(rd, "jpeg2k_depth", expand=True)
359
360             col = split.column()
361             col.prop(rd, "jpeg2k_preset", text="")
362             col.prop(rd, "jpeg2k_ycc")
363
364         elif file_format in ('CINEON', 'DPX'):
365             split = layout.split()
366             col = split.column()
367             col.prop(rd, "cineon_log", text="Convert to Log")
368
369             col = split.column(align=True)
370             col.active = rd.cineon_log
371             col.prop(rd, "cineon_black", text="Black")
372             col.prop(rd, "cineon_white", text="White")
373             col.prop(rd, "cineon_gamma", text="Gamma")
374
375         elif file_format == 'TIFF':
376             split = layout.split()
377             split.prop(rd, "tiff_bit")
378
379         elif file_format == 'QUICKTIME_CARBON':
380             split = layout.split()
381             split.operator("scene.render_data_set_quicktime_codec")
382
383         elif file_format == 'QUICKTIME_QTKIT':
384             split = layout.split()
385             col = split.column()
386             col.prop(rd, "quicktime_codec_type", text="Video Codec")
387             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
388
389             # Audio
390             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
391             if rd.quicktime_audiocodec_type != 'No audio':
392                 split = layout.split()
393                 col = split.column()
394                 if rd.quicktime_audiocodec_type == 'LPCM':
395                     col.prop(rd, "quicktime_audio_bitdepth", text="")
396
397                 col = split.column()
398                 col.prop(rd, "quicktime_audio_samplerate", text="")
399
400                 split = layout.split()
401                 col = split.column()
402                 if rd.quicktime_audiocodec_type == 'AAC':
403                     col.prop(rd, "quicktime_audio_bitrate")
404
405                 subsplit = split.split()
406                 col = subsplit.column()
407
408                 if rd.quicktime_audiocodec_type == 'AAC':
409                     col.prop(rd, "quicktime_audio_codec_isvbr")
410                     
411                 col = subsplit.column()
412                 col.prop(rd, "quicktime_audio_resampling_hq")
413
414
415 class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
416     bl_label = "Encoding"
417     bl_default_closed = True
418     COMPAT_ENGINES = {'BLENDER_RENDER'}
419
420     @staticmethod
421     def poll(context):
422         rd = context.scene.render
423         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
424
425     def draw(self, context):
426         layout = self.layout
427
428         rd = context.scene.render
429
430         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
431
432         split = layout.split()
433
434         col = split.column()
435         col.prop(rd, "ffmpeg_format")
436         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
437             col = split.column()
438             col.prop(rd, "ffmpeg_codec")
439         else:
440             split.label()
441
442         split = layout.split()
443
444         col = split.column()
445         col.prop(rd, "ffmpeg_video_bitrate")
446
447         col = split.column()
448         col.prop(rd, "ffmpeg_gopsize")
449
450         split = layout.split()
451
452         col = split.column()
453         col.label(text="Rate:")
454         col.prop(rd, "ffmpeg_minrate", text="Minimum")
455         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
456         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
457
458         col = split.column()
459
460         col.prop(rd, "ffmpeg_autosplit")
461         col.label(text="Mux:")
462         col.prop(rd, "ffmpeg_muxrate", text="Rate")
463         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
464
465         # Audio:
466         sub = layout.column()
467
468         if rd.ffmpeg_format not in ('MP3'):
469             sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
470
471         sub.separator()
472
473         split = sub.split()
474
475         col = split.column()
476         col.prop(rd, "ffmpeg_audio_bitrate")
477         col.prop(rd, "ffmpeg_audio_mixrate")
478
479         col = split.column()
480         col.prop(rd, "ffmpeg_audio_volume", slider=True)
481
482
483 class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
484     bl_label = "Anti-Aliasing"
485     COMPAT_ENGINES = {'BLENDER_RENDER'}
486
487     @staticmethod
488     def poll(context):
489         rd = context.scene.render
490         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
491
492     def draw_header(self, context):
493         rd = context.scene.render
494
495         self.layout.prop(rd, "render_antialiasing", text="")
496
497     def draw(self, context):
498         layout = self.layout
499
500         rd = context.scene.render
501         layout.active = rd.render_antialiasing
502
503         split = layout.split()
504
505         col = split.column()
506         col.row().prop(rd, "antialiasing_samples", expand=True)
507         sub = col.row()
508         sub.enabled = not rd.use_border
509         sub.prop(rd, "full_sample")
510
511         col = split.column()
512         col.prop(rd, "pixel_filter", text="")
513         col.prop(rd, "filter_size", text="Size")
514
515
516 class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
517     bl_label = "Full Sample Motion Blur"
518     bl_default_closed = True
519     COMPAT_ENGINES = {'BLENDER_RENDER'}
520
521     @staticmethod
522     def poll(context):
523         rd = context.scene.render
524         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
525
526     def draw_header(self, context):
527         rd = context.scene.render
528
529         self.layout.prop(rd, "motion_blur", text="")
530
531     def draw(self, context):
532         layout = self.layout
533
534         rd = context.scene.render
535         layout.active = rd.motion_blur
536
537         row = layout.row()
538         row.prop(rd, "motion_blur_samples")
539         row.prop(rd, "motion_blur_shutter")
540
541 class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
542     bl_label = "Dimensions"
543     COMPAT_ENGINES = {'BLENDER_RENDER'}
544
545     @staticmethod
546     def poll(context):
547         rd = context.scene.render
548         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
549
550     def draw(self, context):
551         layout = self.layout
552
553         scene = context.scene
554         rd = scene.render
555
556         row = layout.row(align=True)
557         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
558         row.operator("render.preset_add", text="", icon="ZOOMIN")
559
560         split = layout.split()
561
562         col = split.column()
563         sub = col.column(align=True)
564         sub.label(text="Resolution:")
565         sub.prop(rd, "resolution_x", text="X")
566         sub.prop(rd, "resolution_y", text="Y")
567         sub.prop(rd, "resolution_percentage", text="")
568
569         sub.label(text="Aspect Ratio:")
570         sub.prop(rd, "pixel_aspect_x", text="X")
571         sub.prop(rd, "pixel_aspect_y", text="Y")
572
573         row = col.row()
574         row.prop(rd, "use_border", text="Border")
575         sub = row.row()
576         sub.active = rd.use_border
577         sub.prop(rd, "crop_to_border", text="Crop")
578
579         col = split.column()
580         sub = col.column(align=True)
581         sub.label(text="Frame Range:")
582         sub.prop(scene, "frame_start", text="Start")
583         sub.prop(scene, "frame_end", text="End")
584         sub.prop(scene, "frame_step", text="Step")
585
586         sub.label(text="Frame Rate:")
587         sub.prop(rd, "fps")
588         sub.prop(rd, "fps_base", text="/")
589
590
591 class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
592     bl_label = "Stamp"
593     bl_default_closed = True
594     COMPAT_ENGINES = {'BLENDER_RENDER'}
595
596     @staticmethod
597     def poll(context):
598         rd = context.scene.render
599         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
600
601     def draw_header(self, context):
602         rd = context.scene.render
603
604         self.layout.prop(rd, "render_stamp", text="")
605
606     def draw(self, context):
607         layout = self.layout
608
609         rd = context.scene.render
610
611         layout.active = rd.render_stamp
612
613         split = layout.split()
614
615         col = split.column()
616         col.prop(rd, "stamp_time", text="Time")
617         col.prop(rd, "stamp_date", text="Date")
618         col.prop(rd, "stamp_render_time", text="RenderTime")
619         col.prop(rd, "stamp_frame", text="Frame")
620         col.prop(rd, "stamp_scene", text="Scene")
621         col.prop(rd, "stamp_camera", text="Camera")
622         col.prop(rd, "stamp_filename", text="Filename")
623         col.prop(rd, "stamp_marker", text="Marker")
624         col.prop(rd, "stamp_sequencer_strip", text="Seq. Strip")
625
626         col = split.column()
627         col.active = rd.render_stamp
628         col.prop(rd, "stamp_foreground", slider=True)
629         col.prop(rd, "stamp_background", slider=True)
630         col.separator()
631         col.prop(rd, "stamp_font_size", text="Font Size")
632
633         row = layout.split(percentage=0.2)
634         row.prop(rd, "stamp_note", text="Note")
635         sub = row.row()
636         sub.active = rd.stamp_note
637         sub.prop(rd, "stamp_note_text", text="")
638
639
640 class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
641     bl_label = "Bake"
642     bl_default_closed = True
643     COMPAT_ENGINES = {'BLENDER_RENDER'}
644
645     @staticmethod
646     def poll(context):
647         rd = context.scene.render
648         return (context.scene and rd.use_game_engine is False) and (rd.engine in __class__.COMPAT_ENGINES)
649
650     def draw(self, context):
651         layout = self.layout
652
653         rd = context.scene.render
654
655         layout.operator("object.bake_image", icon='RENDER_STILL')
656
657         layout.prop(rd, "bake_type")
658
659         if rd.bake_type == 'NORMALS':
660             layout.prop(rd, "bake_normal_space")
661         elif rd.bake_type in ('DISPLACEMENT', 'AO'):
662             layout.prop(rd, "bake_normalized")
663
664         # col.prop(rd, "bake_aa_mode")
665         # col.prop(rd, "bake_enable_aa")
666
667         layout.separator()
668
669         split = layout.split()
670
671         col = split.column()
672         col.prop(rd, "bake_clear")
673         col.prop(rd, "bake_margin")
674         col.prop(rd, "bake_quad_split", text="Split")
675
676         col = split.column()
677         col.prop(rd, "bake_active")
678         sub = col.column()
679         sub.active = rd.bake_active
680         sub.prop(rd, "bake_distance")
681         sub.prop(rd, "bake_bias")
682
683
684 def register():
685     pass
686
687
688 def unregister():
689     pass
690
691 if __name__ == "__main__":
692     register()