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