rna data path names which are more likely to break animations.
[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
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     @classmethod
44     def poll(cls, context):
45         rd = context.scene.render
46         return (context.scene and rd.use_game_engine is False) and (rd.engine in cls.COMPAT_ENGINES)
47
48
49 class RENDER_PT_render(RenderButtonsPanel, bpy.types.Panel):
50     bl_label = "Render"
51     COMPAT_ENGINES = {'BLENDER_RENDER'}
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     def draw(self, context):
75         layout = self.layout
76
77         scene = context.scene
78         rd = scene.render
79
80         row = layout.row()
81         row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
82
83         col = row.column(align=True)
84         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
85         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
86
87         rl = rd.layers[rd.active_layer_index]
88
89         if rl:
90             layout.prop(rl, "name")
91
92         split = layout.split()
93
94         col = split.column()
95         col.prop(scene, "layers", text="Scene")
96         col.label(text="")
97         col.prop(rl, "light_override", text="Light")
98         col.prop(rl, "material_override", text="Material")
99
100         col = split.column()
101         col.prop(rl, "layers", text="Layer")
102         col.label(text="Mask Layers:")
103         col.prop(rl, "layers_zmask", text="")
104
105
106         layout.separator()
107         layout.label(text="Include:")
108
109         split = layout.split()
110
111         col = split.column()
112         col.prop(rl, "use_zmask")
113         row = col.row()
114         row.prop(rl, "invert_zmask", text="Negate")
115         row.active = rl.use_zmask
116         col.prop(rl, "use_all_z")
117
118         col = split.column()
119         col.prop(rl, "use_solid")
120         col.prop(rl, "use_halo")
121         col.prop(rl, "use_ztransp")
122
123         col = split.column()
124         col.prop(rl, "use_sky")
125         col.prop(rl, "use_edge_enhance")
126         col.prop(rl, "use_strand")
127
128         layout.separator()
129
130         split = layout.split()
131
132         col = split.column()
133         col.label(text="Passes:")
134         col.prop(rl, "use_pass_combined")
135         col.prop(rl, "use_pass_z")
136         col.prop(rl, "use_pass_vector")
137         col.prop(rl, "use_pass_normal")
138         col.prop(rl, "use_pass_uv")
139         col.prop(rl, "use_pass_mist")
140         col.prop(rl, "use_pass_object_index")
141         col.prop(rl, "use_pass_color")
142
143         col = split.column()
144         col.label()
145         col.prop(rl, "use_pass_diffuse")
146         row = col.row()
147         row.prop(rl, "use_pass_specular")
148         row.prop(rl, "exclude_specular", text="")
149         row = col.row()
150         row.prop(rl, "use_pass_shadow")
151         row.prop(rl, "exclude_shadow", text="")
152         row = col.row()
153         row.prop(rl, "use_pass_emit")
154         row.prop(rl, "exclude_emit", text="")
155         row = col.row()
156         row.prop(rl, "use_pass_ambient_occlusion")
157         row.prop(rl, "exclude_ambient_occlusion", text="")
158         row = col.row()
159         row.prop(rl, "use_pass_environment")
160         row.prop(rl, "exclude_environment", text="")
161         row = col.row()
162         row.prop(rl, "use_pass_indirect")
163         row.prop(rl, "exclude_indirect", text="")
164         row = col.row()
165         row.prop(rl, "use_pass_reflection")
166         row.prop(rl, "exclude_reflection", text="")
167         row = col.row()
168         row.prop(rl, "use_pass_refraction")
169         row.prop(rl, "exclude_refraction", text="")
170
171
172 class RENDER_PT_shading(RenderButtonsPanel, bpy.types.Panel):
173     bl_label = "Shading"
174     COMPAT_ENGINES = {'BLENDER_RENDER'}
175
176     def draw(self, context):
177         layout = self.layout
178
179         rd = context.scene.render
180
181         split = layout.split()
182
183         col = split.column()
184         col.prop(rd, "use_textures", text="Textures")
185         col.prop(rd, "use_shadows", text="Shadows")
186         col.prop(rd, "use_sss", text="Subsurface Scattering")
187         col.prop(rd, "use_envmaps", text="Environment Map")
188
189         col = split.column()
190         col.prop(rd, "use_raytrace", text="Ray Tracing")
191         col.prop(rd, "use_color_management")
192         col.prop(rd, "alpha_mode", text="Alpha")
193
194
195 class RENDER_PT_performance(RenderButtonsPanel, bpy.types.Panel):
196     bl_label = "Performance"
197     bl_default_closed = True
198     COMPAT_ENGINES = {'BLENDER_RENDER'}
199
200     def draw(self, context):
201         layout = self.layout
202
203         rd = context.scene.render
204
205         split = layout.split()
206
207         col = split.column()
208         col.label(text="Threads:")
209         col.row().prop(rd, "threads_mode", expand=True)
210         sub = col.column()
211         sub.enabled = rd.threads_mode == 'FIXED'
212         sub.prop(rd, "threads")
213         sub = col.column(align=True)
214         sub.label(text="Tiles:")
215         sub.prop(rd, "parts_x", text="X")
216         sub.prop(rd, "parts_y", text="Y")
217
218         col = split.column()
219         col.label(text="Memory:")
220         sub = col.column()
221         sub.enabled = not (rd.use_border or rd.use_full_sample)
222         sub.prop(rd, "use_save_buffers")
223         sub = col.column()
224         sub.active = rd.use_compositing
225         sub.prop(rd, "use_free_image_textures")
226         sub = col.column()
227         sub.active = rd.use_raytrace
228         sub.label(text="Acceleration structure:")
229         sub.prop(rd, "raytrace_method", text="")
230         if rd.raytrace_method == 'OCTREE':
231             sub.prop(rd, "octree_resolution", text="Resolution")
232         else:
233             sub.prop(rd, "use_instances", text="Instances")
234         sub.prop(rd, "use_local_coords", text="Local Coordinates")
235
236
237 class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
238     bl_label = "Post Processing"
239     bl_default_closed = True
240     COMPAT_ENGINES = {'BLENDER_RENDER'}
241
242     def draw(self, context):
243         layout = self.layout
244
245         rd = context.scene.render
246
247         split = layout.split()
248
249         col = split.column()
250         col.prop(rd, "use_compositing")
251         col.prop(rd, "use_sequencer")
252
253         col = split.column()
254         col.prop(rd, "dither_intensity", text="Dither", slider=True)
255
256         layout.separator()
257
258         split = layout.split()
259
260         col = split.column()
261         col.prop(rd, "use_fields", text="Fields")
262         sub = col.column()
263         sub.active = rd.use_fields
264         sub.row().prop(rd, "field_order", expand=True)
265         sub.prop(rd, "use_fields_still", text="Still")
266
267
268         col = split.column()
269         col.prop(rd, "use_edge_enhance")
270         sub = col.column()
271         sub.active = rd.use_edge_enhance
272         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
273         sub.prop(rd, "edge_color", text="")
274
275
276 class RENDER_PT_output(RenderButtonsPanel, bpy.types.Panel):
277     bl_label = "Output"
278     COMPAT_ENGINES = {'BLENDER_RENDER'}
279
280     def draw(self, context):
281         layout = self.layout
282
283         rd = context.scene.render
284         file_format = rd.file_format
285
286         layout.prop(rd, "filepath", text="")
287
288         split = layout.split()
289         col = split.column()
290         col.prop(rd, "file_format", text="")
291         col.row().prop(rd, "color_mode", text="Color", expand=True)
292
293         col = split.column()
294         col.prop(rd, "use_file_extension")
295         col.prop(rd, "use_overwrite")
296         col.prop(rd, "use_placeholder")
297
298         if file_format in ('AVI_JPEG', 'JPEG'):
299             split = layout.split()
300             split.prop(rd, "file_quality", slider=True)
301         
302         if file_format == 'PNG':
303             split = layout.split()
304             split.prop(rd, "file_quality", slider=True, text="Compression")
305
306         elif file_format == 'MULTILAYER':
307             split = layout.split()
308
309             col = split.column()
310             col.label(text="Codec:")
311             col.prop(rd, "exr_codec", text="")
312             col = split.column()
313
314         elif file_format == 'OPEN_EXR':
315             split = layout.split()
316
317             col = split.column()
318             col.label(text="Codec:")
319             col.prop(rd, "exr_codec", text="")
320
321             subsplit = split.split()
322             col = subsplit.column()
323             col.prop(rd, "use_exr_half")
324             col.prop(rd, "exr_zbuf")
325
326             col = subsplit.column()
327             col.prop(rd, "exr_preview")
328
329         elif file_format == 'JPEG2000':
330             split = layout.split()
331             col = split.column()
332             col.label(text="Depth:")
333             col.row().prop(rd, "jpeg2k_depth", expand=True)
334
335             col = split.column()
336             col.prop(rd, "jpeg2k_preset", text="")
337             col.prop(rd, "jpeg2k_ycc")
338
339         elif file_format in ('CINEON', 'DPX'):
340             split = layout.split()
341             col = split.column()
342             col.prop(rd, "use_cineon_log", text="Convert to Log")
343
344             col = split.column(align=True)
345             col.active = rd.use_cineon_log
346             col.prop(rd, "cineon_black", text="Black")
347             col.prop(rd, "cineon_white", text="White")
348             col.prop(rd, "cineon_gamma", text="Gamma")
349
350         elif file_format == 'TIFF':
351             split = layout.split()
352             split.prop(rd, "use_tiff_16bit")
353
354         elif file_format == 'QUICKTIME_CARBON':
355             split = layout.split()
356             split.operator("scene.render_data_set_quicktime_codec")
357
358         elif file_format == 'QUICKTIME_QTKIT':
359             split = layout.split()
360             col = split.column()
361             col.prop(rd, "quicktime_codec_type", text="Video Codec")
362             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
363
364             # Audio
365             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
366             if rd.quicktime_audiocodec_type != 'No audio':
367                 split = layout.split()
368                 col = split.column()
369                 if rd.quicktime_audiocodec_type == 'LPCM':
370                     col.prop(rd, "quicktime_audio_bitdepth", text="")
371
372                 col = split.column()
373                 col.prop(rd, "quicktime_audio_samplerate", text="")
374
375                 split = layout.split()
376                 col = split.column()
377                 if rd.quicktime_audiocodec_type == 'AAC':
378                     col.prop(rd, "quicktime_audio_bitrate")
379
380                 subsplit = split.split()
381                 col = subsplit.column()
382
383                 if rd.quicktime_audiocodec_type == 'AAC':
384                     col.prop(rd, "quicktime_audio_codec_isvbr")
385                     
386                 col = subsplit.column()
387                 col.prop(rd, "quicktime_audio_resampling_hq")
388
389
390 class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
391     bl_label = "Encoding"
392     bl_default_closed = True
393     COMPAT_ENGINES = {'BLENDER_RENDER'}
394
395     @classmethod
396     def poll(cls, context):
397         rd = context.scene.render
398         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
399
400     def draw(self, context):
401         layout = self.layout
402
403         rd = context.scene.render
404
405         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
406
407         split = layout.split()
408
409         col = split.column()
410         col.prop(rd, "ffmpeg_format")
411         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
412             col = split.column()
413             col.prop(rd, "ffmpeg_codec")
414         else:
415             split.label()
416
417         split = layout.split()
418
419         col = split.column()
420         col.prop(rd, "ffmpeg_video_bitrate")
421
422         col = split.column()
423         col.prop(rd, "ffmpeg_gopsize")
424
425         split = layout.split()
426
427         col = split.column()
428         col.label(text="Rate:")
429         col.prop(rd, "ffmpeg_minrate", text="Minimum")
430         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
431         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
432
433         col = split.column()
434
435         col.prop(rd, "ffmpeg_autosplit")
436         col.label(text="Mux:")
437         col.prop(rd, "ffmpeg_muxrate", text="Rate")
438         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
439
440         # Audio:
441         sub = layout.column()
442
443         if rd.ffmpeg_format not in ('MP3', ):
444             sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
445
446         sub.separator()
447
448         split = sub.split()
449
450         col = split.column()
451         col.prop(rd, "ffmpeg_audio_bitrate")
452         col.prop(rd, "ffmpeg_audio_mixrate")
453
454         col = split.column()
455         col.prop(rd, "ffmpeg_audio_volume", slider=True)
456
457
458 class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
459     bl_label = "Anti-Aliasing"
460     COMPAT_ENGINES = {'BLENDER_RENDER'}
461
462     def draw_header(self, context):
463         rd = context.scene.render
464
465         self.layout.prop(rd, "use_antialiasing", text="")
466
467     def draw(self, context):
468         layout = self.layout
469
470         rd = context.scene.render
471         layout.active = rd.use_antialiasing
472
473         split = layout.split()
474
475         col = split.column()
476         col.row().prop(rd, "antialiasing_samples", expand=True)
477         sub = col.row()
478         sub.enabled = not rd.use_border
479         sub.prop(rd, "use_full_sample")
480
481         col = split.column()
482         col.prop(rd, "pixel_filter_type", text="")
483         col.prop(rd, "filter_size", text="Size")
484
485
486 class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
487     bl_label = "Full Sample Motion Blur"
488     bl_default_closed = True
489     COMPAT_ENGINES = {'BLENDER_RENDER'}
490
491     def draw_header(self, context):
492         rd = context.scene.render
493
494         self.layout.prop(rd, "use_motion_blur", text="")
495
496     def draw(self, context):
497         layout = self.layout
498
499         rd = context.scene.render
500         layout.active = rd.use_motion_blur
501
502         row = layout.row()
503         row.prop(rd, "motion_blur_samples")
504         row.prop(rd, "motion_blur_shutter")
505
506 class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
507     bl_label = "Dimensions"
508     COMPAT_ENGINES = {'BLENDER_RENDER'}
509
510     def draw(self, context):
511         layout = self.layout
512
513         scene = context.scene
514         rd = scene.render
515
516         row = layout.row(align=True)
517         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
518         row.operator("render.preset_add", text="", icon="ZOOMIN")
519
520         split = layout.split()
521
522         col = split.column()
523         sub = col.column(align=True)
524         sub.label(text="Resolution:")
525         sub.prop(rd, "resolution_x", text="X")
526         sub.prop(rd, "resolution_y", text="Y")
527         sub.prop(rd, "resolution_percentage", text="")
528
529         sub.label(text="Aspect Ratio:")
530         sub.prop(rd, "pixel_aspect_x", text="X")
531         sub.prop(rd, "pixel_aspect_y", text="Y")
532
533         row = col.row()
534         row.prop(rd, "use_border", text="Border")
535         sub = row.row()
536         sub.active = rd.use_border
537         sub.prop(rd, "use_crop_to_border", text="Crop")
538
539         col = split.column()
540         sub = col.column(align=True)
541         sub.label(text="Frame Range:")
542         sub.prop(scene, "frame_start", text="Start")
543         sub.prop(scene, "frame_end", text="End")
544         sub.prop(scene, "frame_step", text="Step")
545
546         sub.label(text="Frame Rate:")
547         sub.prop(rd, "fps")
548         sub.prop(rd, "fps_base", text="/")
549
550
551 class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
552     bl_label = "Stamp"
553     bl_default_closed = True
554     COMPAT_ENGINES = {'BLENDER_RENDER'}
555
556     def draw_header(self, context):
557         rd = context.scene.render
558
559         self.layout.prop(rd, "use_stamp", text="")
560
561     def draw(self, context):
562         layout = self.layout
563
564         rd = context.scene.render
565
566         layout.active = rd.use_stamp
567
568         split = layout.split()
569
570         col = split.column()
571         col.prop(rd, "use_stamp_time", text="Time")
572         col.prop(rd, "use_stamp_date", text="Date")
573         col.prop(rd, "use_stamp_render_time", text="RenderTime")
574         col.prop(rd, "use_stamp_frame", text="Frame")
575         col.prop(rd, "use_stamp_scene", text="Scene")
576         col.prop(rd, "use_stamp_camera", text="Camera")
577         col.prop(rd, "use_stamp_filename", text="Filename")
578         col.prop(rd, "use_stamp_marker", text="Marker")
579         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
580
581         col = split.column()
582         col.active = rd.use_stamp
583         col.prop(rd, "stamp_foreground", slider=True)
584         col.prop(rd, "stamp_background", slider=True)
585         col.separator()
586         col.prop(rd, "stamp_font_size", text="Font Size")
587
588         row = layout.split(percentage=0.2)
589         row.prop(rd, "use_stamp_note", text="Note")
590         sub = row.row()
591         sub.active = rd.use_stamp_note
592         sub.prop(rd, "stamp_note_text", text="")
593
594
595 class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
596     bl_label = "Bake"
597     bl_default_closed = True
598     COMPAT_ENGINES = {'BLENDER_RENDER'}
599
600     def draw(self, context):
601         layout = self.layout
602
603         rd = context.scene.render
604
605         layout.operator("object.bake_image", icon='RENDER_STILL')
606
607         layout.prop(rd, "bake_type")
608
609         if rd.bake_type == 'NORMALS':
610             layout.prop(rd, "bake_normal_space")
611         elif rd.bake_type in ('DISPLACEMENT', 'AO'):
612             layout.prop(rd, "use_bake_normalize")
613
614         # col.prop(rd, "bake_aa_mode")
615         # col.prop(rd, "use_bake_antialiasing")
616
617         layout.separator()
618
619         split = layout.split()
620
621         col = split.column()
622         col.prop(rd, "use_bake_clear")
623         col.prop(rd, "bake_margin")
624         col.prop(rd, "bake_quad_split", text="Split")
625
626         col = split.column()
627         col.prop(rd, "use_bake_selected_to_active")
628         sub = col.column()
629         sub.active = rd.use_bake_selected_to_active
630         sub.prop(rd, "bake_distance")
631         sub.prop(rd, "bake_bias")
632
633
634 def register():
635     pass
636
637
638 def unregister():
639     pass
640
641 if __name__ == "__main__":
642     register()