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