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