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