feature request from colin levy, camera lens stamp.
[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     @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_options = {'DEFAULT_CLOSED'}
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.layers, "active_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         row = layout.row()
88         rl = rd.layers.active
89         if rl:
90             row.prop(rl, "name")
91         row.prop(rd, "use_single_layer", text="", icon_only=True)
92
93         split = layout.split()
94
95         col = split.column()
96         col.prop(scene, "layers", text="Scene")
97         col.label(text="")
98         col.prop(rl, "light_override", text="Light")
99         col.prop(rl, "material_override", text="Material")
100
101         col = split.column()
102         col.prop(rl, "layers", text="Layer")
103         col.label(text="Mask Layers:")
104         col.prop(rl, "layers_zmask", text="")
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_options = {'DEFAULT_CLOSED'}
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.prop(rd, "use_free_unused_nodes")
227         sub = col.column()
228         sub.active = rd.use_raytrace
229         sub.label(text="Acceleration structure:")
230         sub.prop(rd, "raytrace_method", text="")
231         if rd.raytrace_method == 'OCTREE':
232             sub.prop(rd, "octree_resolution", text="Resolution")
233         else:
234             sub.prop(rd, "use_instances", text="Instances")
235         sub.prop(rd, "use_local_coords", text="Local Coordinates")
236
237
238 class RENDER_PT_post_processing(RenderButtonsPanel, bpy.types.Panel):
239     bl_label = "Post Processing"
240     bl_options = {'DEFAULT_CLOSED'}
241     COMPAT_ENGINES = {'BLENDER_RENDER'}
242
243     def draw(self, context):
244         layout = self.layout
245
246         rd = context.scene.render
247
248         split = layout.split()
249
250         col = split.column()
251         col.prop(rd, "use_compositing")
252         col.prop(rd, "use_sequencer")
253
254         col = split.column()
255         col.prop(rd, "dither_intensity", text="Dither", slider=True)
256
257         layout.separator()
258
259         split = layout.split()
260
261         col = split.column()
262         col.prop(rd, "use_fields", text="Fields")
263         sub = col.column()
264         sub.active = rd.use_fields
265         sub.row().prop(rd, "field_order", expand=True)
266         sub.prop(rd, "use_fields_still", text="Still")
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
341             split = layout.split()
342             split.label("FIXME: hard coded Non-Linear, Gamma:1.0")
343             '''
344             col = split.column()
345             col.prop(rd, "use_cineon_log", text="Convert to Log")
346
347             col = split.column(align=True)
348             col.active = rd.use_cineon_log
349             col.prop(rd, "cineon_black", text="Black")
350             col.prop(rd, "cineon_white", text="White")
351             col.prop(rd, "cineon_gamma", text="Gamma")
352             '''
353
354         elif file_format == 'TIFF':
355             split = layout.split()
356             split.prop(rd, "use_tiff_16bit")
357
358         elif file_format == 'QUICKTIME_CARBON':
359             split = layout.split()
360             split.operator("scene.render_data_set_quicktime_codec")
361
362         elif file_format == 'QUICKTIME_QTKIT':
363             split = layout.split()
364             col = split.column()
365             col.prop(rd, "quicktime_codec_type", text="Video Codec")
366             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
367
368             # Audio
369             col.prop(rd, "quicktime_audiocodec_type", text="Audio Codec")
370             if rd.quicktime_audiocodec_type != 'No audio':
371                 split = layout.split()
372                 col = split.column()
373                 if rd.quicktime_audiocodec_type == 'LPCM':
374                     col.prop(rd, "quicktime_audio_bitdepth", text="")
375
376                 col = split.column()
377                 col.prop(rd, "quicktime_audio_samplerate", text="")
378
379                 split = layout.split()
380                 col = split.column()
381                 if rd.quicktime_audiocodec_type == 'AAC':
382                     col.prop(rd, "quicktime_audio_bitrate")
383
384                 subsplit = split.split()
385                 col = subsplit.column()
386
387                 if rd.quicktime_audiocodec_type == 'AAC':
388                     col.prop(rd, "quicktime_audio_codec_isvbr")
389
390                 col = subsplit.column()
391                 col.prop(rd, "quicktime_audio_resampling_hq")
392
393
394 class RENDER_PT_encoding(RenderButtonsPanel, bpy.types.Panel):
395     bl_label = "Encoding"
396     bl_options = {'DEFAULT_CLOSED'}
397     COMPAT_ENGINES = {'BLENDER_RENDER'}
398
399     @classmethod
400     def poll(cls, context):
401         rd = context.scene.render
402         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
403
404     def draw(self, context):
405         layout = self.layout
406
407         rd = context.scene.render
408
409         layout.menu("RENDER_MT_ffmpeg_presets", text="Presets")
410
411         split = layout.split()
412
413         col = split.column()
414         col.prop(rd, "ffmpeg_format")
415         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
416             col = split.column()
417             col.prop(rd, "ffmpeg_codec")
418         else:
419             split.label()
420
421         split = layout.split()
422
423         col = split.column()
424         col.prop(rd, "ffmpeg_video_bitrate")
425
426         col = split.column()
427         col.prop(rd, "ffmpeg_gopsize")
428
429         split = layout.split()
430
431         col = split.column()
432         col.label(text="Rate:")
433         col.prop(rd, "ffmpeg_minrate", text="Minimum")
434         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
435         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
436
437         col = split.column()
438
439         col.prop(rd, "ffmpeg_autosplit")
440         col.label(text="Mux:")
441         col.prop(rd, "ffmpeg_muxrate", text="Rate")
442         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
443
444         # Audio:
445         sub = layout.column()
446
447         if rd.ffmpeg_format not in ('MP3', ):
448             sub.prop(rd, "ffmpeg_audio_codec", text="Audio Codec")
449
450         sub.separator()
451
452         split = sub.split()
453
454         col = split.column()
455         col.prop(rd, "ffmpeg_audio_bitrate")
456         col.prop(rd, "ffmpeg_audio_mixrate")
457
458         col = split.column()
459         col.prop(rd, "ffmpeg_audio_volume", slider=True)
460
461
462 class RENDER_PT_antialiasing(RenderButtonsPanel, bpy.types.Panel):
463     bl_label = "Anti-Aliasing"
464     COMPAT_ENGINES = {'BLENDER_RENDER'}
465
466     def draw_header(self, context):
467         rd = context.scene.render
468
469         self.layout.prop(rd, "use_antialiasing", text="")
470
471     def draw(self, context):
472         layout = self.layout
473
474         rd = context.scene.render
475         layout.active = rd.use_antialiasing
476
477         split = layout.split()
478
479         col = split.column()
480         col.row().prop(rd, "antialiasing_samples", expand=True)
481         sub = col.row()
482         sub.enabled = not rd.use_border
483         sub.prop(rd, "use_full_sample")
484
485         col = split.column()
486         col.prop(rd, "pixel_filter_type", text="")
487         col.prop(rd, "filter_size", text="Size")
488
489
490 class RENDER_PT_motion_blur(RenderButtonsPanel, bpy.types.Panel):
491     bl_label = "Sampled Motion Blur"
492     bl_options = {'DEFAULT_CLOSED'}
493     COMPAT_ENGINES = {'BLENDER_RENDER'}
494
495     @classmethod
496     def poll(cls, context):
497         rd = context.scene.render
498         return not rd.use_full_sample and (rd.engine in cls.COMPAT_ENGINES)
499
500     def draw_header(self, context):
501         rd = context.scene.render
502
503         self.layout.prop(rd, "use_motion_blur", text="")
504
505     def draw(self, context):
506         layout = self.layout
507
508         rd = context.scene.render
509         layout.active = rd.use_motion_blur
510
511         row = layout.row()
512         row.prop(rd, "motion_blur_samples")
513         row.prop(rd, "motion_blur_shutter")
514
515
516 class RENDER_PT_dimensions(RenderButtonsPanel, bpy.types.Panel):
517     bl_label = "Dimensions"
518     COMPAT_ENGINES = {'BLENDER_RENDER'}
519
520     def draw(self, context):
521         layout = self.layout
522
523         scene = context.scene
524         rd = scene.render
525
526         row = layout.row(align=True)
527         row.menu("RENDER_MT_presets", text=bpy.types.RENDER_MT_presets.bl_label)
528         row.operator("render.preset_add", text="", icon="ZOOMIN")
529         row.operator("render.preset_add", text="", icon="ZOOMOUT").remove_active = True
530
531         split = layout.split()
532
533         col = split.column()
534         sub = col.column(align=True)
535         sub.label(text="Resolution:")
536         sub.prop(rd, "resolution_x", text="X")
537         sub.prop(rd, "resolution_y", text="Y")
538         sub.prop(rd, "resolution_percentage", text="")
539
540         sub.label(text="Aspect Ratio:")
541         sub.prop(rd, "pixel_aspect_x", text="X")
542         sub.prop(rd, "pixel_aspect_y", text="Y")
543
544         row = col.row()
545         row.prop(rd, "use_border", text="Border")
546         sub = row.row()
547         sub.active = rd.use_border
548         sub.prop(rd, "use_crop_to_border", text="Crop")
549
550         col = split.column()
551         sub = col.column(align=True)
552         sub.label(text="Frame Range:")
553         sub.prop(scene, "frame_start", text="Start")
554         sub.prop(scene, "frame_end", text="End")
555         sub.prop(scene, "frame_step", text="Step")
556
557         sub.label(text="Frame Rate:")
558         sub.prop(rd, "fps")
559         sub.prop(rd, "fps_base", text="/")
560         subrow = sub.row(align=True)
561         subrow.prop(rd, "frame_map_old", text="Old")
562         subrow.prop(rd, "frame_map_new", text="New")
563
564
565 class RENDER_PT_stamp(RenderButtonsPanel, bpy.types.Panel):
566     bl_label = "Stamp"
567     bl_options = {'DEFAULT_CLOSED'}
568     COMPAT_ENGINES = {'BLENDER_RENDER'}
569
570     def draw_header(self, context):
571         rd = context.scene.render
572
573         self.layout.prop(rd, "use_stamp", text="")
574
575     def draw(self, context):
576         layout = self.layout
577
578         rd = context.scene.render
579
580         layout.active = rd.use_stamp
581
582         split = layout.split()
583
584         col = split.column()
585         col.prop(rd, "use_stamp_time", text="Time")
586         col.prop(rd, "use_stamp_date", text="Date")
587         col.prop(rd, "use_stamp_render_time", text="RenderTime")
588         col.prop(rd, "use_stamp_frame", text="Frame")
589         col.prop(rd, "use_stamp_scene", text="Scene")
590         col.prop(rd, "use_stamp_camera", text="Camera")
591         col.prop(rd, "use_stamp_lens", text="Lens")
592         col.prop(rd, "use_stamp_filename", text="Filename")
593         col.prop(rd, "use_stamp_marker", text="Marker")
594         col.prop(rd, "use_stamp_sequencer_strip", text="Seq. Strip")
595
596         col = split.column()
597         col.active = rd.use_stamp
598         col.prop(rd, "stamp_foreground", slider=True)
599         col.prop(rd, "stamp_background", slider=True)
600         col.separator()
601         col.prop(rd, "stamp_font_size", text="Font Size")
602
603         row = layout.split(percentage=0.2)
604         row.prop(rd, "use_stamp_note", text="Note")
605         sub = row.row()
606         sub.active = rd.use_stamp_note
607         sub.prop(rd, "stamp_note_text", text="")
608
609
610 class RENDER_PT_bake(RenderButtonsPanel, bpy.types.Panel):
611     bl_label = "Bake"
612     bl_options = {'DEFAULT_CLOSED'}
613     COMPAT_ENGINES = {'BLENDER_RENDER'}
614
615     def draw(self, context):
616         layout = self.layout
617
618         rd = context.scene.render
619
620         layout.operator("object.bake_image", icon='RENDER_STILL')
621
622         layout.prop(rd, "bake_type")
623
624         if rd.bake_type == 'NORMALS':
625             layout.prop(rd, "bake_normal_space")
626         elif rd.bake_type in ('DISPLACEMENT', 'AO'):
627             layout.prop(rd, "use_bake_normalize")
628
629         # col.prop(rd, "bake_aa_mode")
630         # col.prop(rd, "use_bake_antialiasing")
631
632         layout.separator()
633
634         split = layout.split()
635
636         col = split.column()
637         col.prop(rd, "use_bake_clear")
638         col.prop(rd, "bake_margin")
639         col.prop(rd, "bake_quad_split", text="Split")
640
641         col = split.column()
642         col.prop(rd, "use_bake_selected_to_active")
643         sub = col.column()
644         sub.active = rd.use_bake_selected_to_active
645         sub.prop(rd, "bake_distance")
646         sub.prop(rd, "bake_bias")
647
648
649 def register():
650     pass
651
652
653 def unregister():
654     pass
655
656 if __name__ == "__main__":
657     register()