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