COLLADA branch: merge from trunk -r 24522:24758.
[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 == False) and (rd.engine in self.COMPAT_ENGINES)
41
42
43 class RENDER_PT_render(RenderButtonsPanel):
44     bl_label = "Render"
45     COMPAT_ENGINES = set(['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.itemO("screen.render", text="Image", icon='ICON_RENDER_STILL')
57
58         if wide_ui:
59             col = split.column()
60         col.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION')
61
62         layout.itemR(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 = set(['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.itemO("scene.render_layer_add", icon='ICON_ZOOMIN', text="")
82         col.itemO("scene.render_layer_remove", icon='ICON_ZOOMOUT', text="")
83
84         rl = rd.layers[rd.active_layer_index]
85
86         if rl:
87             layout.itemR(rl, "name")
88
89         split = layout.split()
90
91         col = split.column()
92         col.itemR(scene, "visible_layers", text="Scene")
93         if wide_ui:
94             col = split.column()
95         col.itemR(rl, "visible_layers", text="Layer")
96
97         layout.itemR(rl, "light_override", text="Light")
98         layout.itemR(rl, "material_override", text="Material")
99
100         layout.itemS()
101         layout.itemL(text="Include:")
102
103         split = layout.split()
104
105         col = split.column()
106         col.itemR(rl, "zmask")
107         row = col.row()
108         row.itemR(rl, "zmask_negate", text="Negate")
109         row.active = rl.zmask
110         col.itemR(rl, "all_z")
111
112         col = split.column()
113         col.itemR(rl, "solid")
114         col.itemR(rl, "halo")
115         col.itemR(rl, "ztransp")
116
117         col = split.column()
118         col.itemR(rl, "sky")
119         col.itemR(rl, "edge")
120         col.itemR(rl, "strand")
121
122         if rl.zmask:
123             split = layout.split()
124             split.itemL(text="Zmask Layers:")
125             split.column().itemR(rl, "zmask_layers", text="")
126
127         layout.itemS()
128
129         split = layout.split()
130
131         col = split.column()
132         col.itemL(text="Passes:")
133         col.itemR(rl, "pass_combined")
134         col.itemR(rl, "pass_z")
135         col.itemR(rl, "pass_vector")
136         col.itemR(rl, "pass_normal")
137         col.itemR(rl, "pass_uv")
138         col.itemR(rl, "pass_mist")
139         col.itemR(rl, "pass_object_index")
140
141         if wide_ui:
142             col = split.column()
143         col.itemL()
144         col.itemR(rl, "pass_color")
145         col.itemR(rl, "pass_diffuse")
146         row = col.row()
147         row.itemR(rl, "pass_specular")
148         row.itemR(rl, "pass_specular_exclude", text="", icon='ICON_X')
149         row = col.row()
150         row.itemR(rl, "pass_shadow")
151         row.itemR(rl, "pass_shadow_exclude", text="", icon='ICON_X')
152         row = col.row()
153         row.itemR(rl, "pass_ao")
154         row.itemR(rl, "pass_ao_exclude", text="", icon='ICON_X')
155         row = col.row()
156         row.itemR(rl, "pass_reflection")
157         row.itemR(rl, "pass_reflection_exclude", text="", icon='ICON_X')
158         row = col.row()
159         row.itemR(rl, "pass_refraction")
160         row.itemR(rl, "pass_refraction_exclude", text="", icon='ICON_X')
161
162
163 class RENDER_PT_shading(RenderButtonsPanel):
164     bl_label = "Shading"
165     COMPAT_ENGINES = set(['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.itemR(rd, "render_textures", text="Textures")
177         col.itemR(rd, "render_shadows", text="Shadows")
178         col.itemR(rd, "render_sss", text="Subsurface Scattering")
179         col.itemR(rd, "render_envmaps", text="Environment Map")
180
181         if wide_ui:
182             col = split.column()
183         col.itemR(rd, "render_raytracing", text="Ray Tracing")
184         col.itemR(rd, "color_management")
185         col.itemR(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 = set(['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.itemL(text="Threads:")
203         col.row().itemR(rd, "threads_mode", expand=True)
204         sub = col.column()
205         sub.enabled = rd.threads_mode == 'THREADS_FIXED'
206         sub.itemR(rd, "threads")
207         sub = col.column(align=True)
208         sub.itemL(text="Tiles:")
209         sub.itemR(rd, "parts_x", text="X")
210         sub.itemR(rd, "parts_y", text="Y")
211
212         if wide_ui:
213             col = split.column()
214         col.itemL(text="Memory:")
215         sub = col.column()
216         sub.itemR(rd, "save_buffers")
217         sub.enabled = not rd.full_sample
218         sub = col.column()
219         sub.active = rd.use_compositing
220         sub.itemR(rd, "free_image_textures")
221         sub = col.column()
222         sub.active = rd.render_raytracing
223         sub.itemL(text="Acceleration structure:")
224         sub.itemR(rd, "raytrace_structure", text="")
225         if rd.raytrace_structure == 'OCTREE':
226             sub.itemR(rd, "octree_resolution", text="Resolution")
227         else:
228             sub.itemR(rd, "use_instances", text="Instances")
229         sub.itemR(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 = set(['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.itemR(rd, "use_compositing")
247         col.itemR(rd, "use_sequencer")
248
249         if wide_ui:
250             col = split.column()
251         col.itemR(rd, "dither_intensity", text="Dither", slider=True)
252
253         layout.itemS()
254
255         split = layout.split()
256
257         col = split.column()
258         col.itemR(rd, "fields", text="Fields")
259         sub = col.column()
260         sub.active = rd.fields
261         sub.row().itemR(rd, "field_order", expand=True)
262         sub.itemR(rd, "fields_still", text="Still")
263
264
265         if wide_ui:
266             col = split.column()
267         else:
268             col.itemS()
269         col.itemR(rd, "edge")
270         sub = col.column()
271         sub.active = rd.edge
272         sub.itemR(rd, "edge_threshold", text="Threshold", slider=True)
273         sub.itemR(rd, "edge_color", text="")
274
275
276 class RENDER_PT_output(RenderButtonsPanel):
277     bl_label = "Output"
278     COMPAT_ENGINES = set(['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.itemR(rd, "output_path", text="")
287
288         split = layout.split()
289         col = split.column()
290         col.itemR(rd, "file_format", text="")
291         col.row().itemR(rd, "color_mode", text="Color", expand=True)
292
293         if wide_ui:
294             col = split.column()
295         col.itemR(rd, "file_extensions")
296         col.itemR(rd, "use_overwrite")
297         col.itemR(rd, "use_placeholder")
298
299         if rd.file_format in ('AVIJPEG', 'JPEG'):
300             split = layout.split()
301             split.itemR(rd, "quality", slider=True)
302
303         elif rd.file_format == 'OPENEXR':
304             split = layout.split()
305
306             col = split.column()
307             col.itemL(text="Codec:")
308             col.itemR(rd, "exr_codec", text="")
309
310             if wide_ui:
311                 subsplit = split.split()
312                 col = subsplit.column()
313             col.itemR(rd, "exr_half")
314             col.itemR(rd, "exr_zbuf")
315
316             if wide_ui:
317                 col = subsplit.column()
318             col.itemR(rd, "exr_preview")
319
320         elif rd.file_format == 'JPEG2000':
321             split = layout.split()
322             col = split.column()
323             col.itemL(text="Depth:")
324             col.row().itemR(rd, "jpeg2k_depth", expand=True)
325
326             if wide_ui:
327                 col = split.column()
328             col.itemR(rd, "jpeg2k_preset", text="")
329             col.itemR(rd, "jpeg2k_ycc")
330
331         elif rd.file_format in ('CINEON', 'DPX'):
332             split = layout.split()
333             col = split.column()
334             col.itemR(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.itemR(rd, "cineon_black", text="Black")
340             col.itemR(rd, "cineon_white", text="White")
341             col.itemR(rd, "cineon_gamma", text="Gamma")
342
343         elif rd.file_format == 'TIFF':
344             split = layout.split()
345             split.itemR(rd, "tiff_bit")
346
347
348 class RENDER_PT_QTencoding(RenderButtonsPanel):
349     bl_label = "Encoding"
350     bl_default_closed = True
351     COMPAT_ENGINES = set(['BLENDER_RENDER'])
352
353     def poll(self, context):
354         rd = context.scene.render_data
355         return rd.file_format in ('QUICKTIME_QTKIT') # QUICKTIME will be added later
356
357     def draw(self, context):
358         layout = self.layout
359
360         rd = context.scene.render_data
361         wide_ui = context.region.width > narrowui
362
363         split = layout.split()
364
365         split.itemR(rd, "quicktime_codec_type")
366
367         split = layout.split()
368
369         if rd.file_format == 'QUICKTIME_QTKIT':
370             split.itemR(rd, "quicktime_codec_spatial_quality", text="Quality", slider=True)
371
372
373 class RENDER_PT_encoding(RenderButtonsPanel):
374     bl_label = "Encoding"
375     bl_default_closed = True
376     COMPAT_ENGINES = set(['BLENDER_RENDER'])
377
378     def poll(self, context):
379         rd = context.scene.render_data
380         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
381
382     def draw(self, context):
383         layout = self.layout
384
385         rd = context.scene.render_data
386         wide_ui = context.region.width > narrowui
387
388         split = layout.split()
389
390         col = split.column()
391         col.itemR(rd, "ffmpeg_format")
392         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
393             if wide_ui:
394                 col = split.column()
395             col.itemR(rd, "ffmpeg_codec")
396         else:
397             if wide_ui:
398                 split.itemL()
399
400         split = layout.split()
401
402         col = split.column()
403         col.itemR(rd, "ffmpeg_video_bitrate")
404         if wide_ui:
405             col = split.column()
406         col.itemR(rd, "ffmpeg_gopsize")
407
408         split = layout.split()
409
410         col = split.column()
411         col.itemL(text="Rate:")
412         col.itemR(rd, "ffmpeg_minrate", text="Minimum")
413         col.itemR(rd, "ffmpeg_maxrate", text="Maximum")
414         col.itemR(rd, "ffmpeg_buffersize", text="Buffer")
415
416         if wide_ui:
417             col = split.column()
418
419         col.itemR(rd, "ffmpeg_autosplit")
420         col.itemL(text="Mux:")
421         col.itemR(rd, "ffmpeg_muxrate", text="Rate")
422         col.itemR(rd, "ffmpeg_packetsize", text="Packet Size")
423
424         row = layout.row()
425         row.itemL(text="Audio:")
426         row = layout.row()
427         row.itemR(rd, "ffmpeg_audio_codec", text="Codec")
428
429         split = layout.split()
430
431         col = split.column()
432         col.itemR(rd, "ffmpeg_audio_bitrate")
433         col.itemR(rd, "ffmpeg_audio_mixrate")
434
435         if wide_ui:
436             col = split.column()
437         col.itemR(rd, "ffmpeg_multiplex_audio")
438         col.itemR(rd, "ffmpeg_audio_volume", slider=True)
439
440
441 class RENDER_PT_antialiasing(RenderButtonsPanel):
442     bl_label = "Anti-Aliasing"
443     COMPAT_ENGINES = set(['BLENDER_RENDER'])
444
445     def draw_header(self, context):
446         rd = context.scene.render_data
447
448         self.layout.itemR(rd, "antialiasing", text="")
449
450     def draw(self, context):
451         layout = self.layout
452
453         rd = context.scene.render_data
454         wide_ui = context.region.width > narrowui
455         layout.active = rd.antialiasing
456
457         split = layout.split()
458
459         col = split.column()
460         col.row().itemR(rd, "antialiasing_samples", expand=True)
461         col.itemR(rd, "full_sample")
462
463         if wide_ui:
464             col = split.column()
465         col.itemR(rd, "pixel_filter", text="")
466         col.itemR(rd, "filter_size", text="Size", slider=True)
467
468
469 class RENDER_PT_dimensions(RenderButtonsPanel):
470     bl_label = "Dimensions"
471     COMPAT_ENGINES = set(['BLENDER_RENDER'])
472
473     def draw(self, context):
474         layout = self.layout
475
476         scene = context.scene
477         rd = scene.render_data
478         wide_ui = context.region.width > narrowui
479         
480         row = layout.row().split()
481         sub = row.row(align=True).split(percentage=0.75)
482         sub.itemM("RENDER_MT_presets", text="Presets")
483         sub.itemO("render.preset_add", text="Add")
484
485         split = layout.split()
486
487         col = split.column()
488         sub = col.column(align=True)
489         sub.itemL(text="Resolution:")
490         sub.itemR(rd, "resolution_x", text="X")
491         sub.itemR(rd, "resolution_y", text="Y")
492         sub.itemR(rd, "resolution_percentage", text="")
493
494         sub.itemL(text="Aspect Ratio:")
495         sub.itemR(rd, "pixel_aspect_x", text="X")
496         sub.itemR(rd, "pixel_aspect_y", text="Y")
497
498         row = col.row()
499         row.itemR(rd, "use_border", text="Border")
500         sub = row.row()
501         sub.active = rd.use_border
502         sub.itemR(rd, "crop_to_border", text="Crop")
503
504         if wide_ui:
505             col = split.column()
506         sub = col.column(align=True)
507         sub.itemL(text="Frame Range:")
508         sub.itemR(scene, "start_frame", text="Start")
509         sub.itemR(scene, "end_frame", text="End")
510         sub.itemR(scene, "frame_step", text="Step")
511
512         sub.itemL(text="Frame Rate:")
513         sub.itemR(rd, "fps")
514         sub.itemR(rd, "fps_base", text="/")  
515
516
517 class RENDER_PT_stamp(RenderButtonsPanel):
518     bl_label = "Stamp"
519     bl_default_closed = True
520     COMPAT_ENGINES = set(['BLENDER_RENDER'])
521
522     def draw_header(self, context):
523         rd = context.scene.render_data
524
525         self.layout.itemR(rd, "render_stamp", text="")
526
527     def draw(self, context):
528         layout = self.layout
529
530         rd = context.scene.render_data
531         wide_ui = context.region.width > narrowui
532
533         layout.active = rd.render_stamp
534
535         split = layout.split()
536
537         col = split.column()
538         col.itemR(rd, "stamp_time", text="Time")
539         col.itemR(rd, "stamp_date", text="Date")
540         col.itemR(rd, "stamp_render_time", text="RenderTime")
541         col.itemR(rd, "stamp_frame", text="Frame")
542         col.itemR(rd, "stamp_scene", text="Scene")
543         col.itemR(rd, "stamp_camera", text="Camera")
544         col.itemR(rd, "stamp_filename", text="Filename")
545         col.itemR(rd, "stamp_marker", text="Marker")
546         col.itemR(rd, "stamp_sequence_strip", text="Seq. Strip")
547
548         if wide_ui:
549             col = split.column()
550         col.active = rd.render_stamp
551         col.itemR(rd, "stamp_foreground", slider=True)
552         col.itemR(rd, "stamp_background", slider=True)
553         col.itemS()
554         col.itemR(rd, "stamp_font_size", text="Font Size")
555
556         row = layout.split(percentage=0.2)
557         row.itemR(rd, "stamp_note", text="Note")
558         sub = row.row()
559         sub.active = rd.stamp_note
560         sub.itemR(rd, "stamp_note_text", text="")
561
562
563 bpy.types.register(RENDER_MT_presets)
564
565 bpy.types.register(RENDER_PT_render)
566 bpy.types.register(RENDER_PT_layers)
567 bpy.types.register(RENDER_PT_dimensions)
568 bpy.types.register(RENDER_PT_antialiasing)
569 bpy.types.register(RENDER_PT_shading)
570 bpy.types.register(RENDER_PT_output)
571 bpy.types.register(RENDER_PT_QTencoding)
572 bpy.types.register(RENDER_PT_encoding)
573 bpy.types.register(RENDER_PT_performance)
574 bpy.types.register(RENDER_PT_post_processing)
575 bpy.types.register(RENDER_PT_stamp)