Merged changes to revision 25007.
[blender-staging.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 = 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.operator("screen.render", text="Image", icon='ICON_RENDER_STILL')
57
58         if wide_ui:
59             col = split.column()
60         col.operator("screen.render", text="Animation", icon='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 = 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.operator("scene.render_layer_add", icon='ICON_ZOOMIN', text="")
82         col.operator("scene.render_layer_remove", icon='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         col.prop(rl, "sky")
117                 
118         col = split.column()
119         col.prop(rl, "edge")
120         col.prop(rl, "strand")
121         col.prop(rl, "freestyle")
122
123         if rl.zmask:
124             split = layout.split()
125             split.label(text="Zmask Layers:")
126             split.column().prop(rl, "zmask_layers", text="")
127
128         layout.separator()
129
130         split = layout.split()
131
132         col = split.column()
133         col.label(text="Passes:")
134         col.prop(rl, "pass_combined")
135         col.prop(rl, "pass_z")
136         col.prop(rl, "pass_vector")
137         col.prop(rl, "pass_normal")
138         col.prop(rl, "pass_uv")
139         col.prop(rl, "pass_mist")
140         col.prop(rl, "pass_object_index")
141
142         if wide_ui:
143             col = split.column()
144         col.label()
145         col.prop(rl, "pass_color")
146         col.prop(rl, "pass_diffuse")
147         row = col.row()
148         row.prop(rl, "pass_specular")
149         row.prop(rl, "pass_specular_exclude", text="", icon='ICON_X')
150         row = col.row()
151         row.prop(rl, "pass_shadow")
152         row.prop(rl, "pass_shadow_exclude", text="", icon='ICON_X')
153         row = col.row()
154         row.prop(rl, "pass_ao")
155         row.prop(rl, "pass_ao_exclude", text="", icon='ICON_X')
156         row = col.row()
157         row.prop(rl, "pass_reflection")
158         row.prop(rl, "pass_reflection_exclude", text="", icon='ICON_X')
159         row = col.row()
160         row.prop(rl, "pass_refraction")
161         row.prop(rl, "pass_refraction_exclude", text="", icon='ICON_X')
162
163         if rl.freestyle:
164             layout.separator()
165
166             split = layout.split()
167
168             col = split.column()
169             col.label(text="Freestyle:")
170             freestyle = rl.freestyle_settings
171             col.prop(freestyle, "sphere_radius", text="Sphere Radius")
172             col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
173             col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
174             col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
175
176             col.operator("scene.freestyle_module_add", text="Add Style Module")
177
178             for i, module in enumerate(freestyle.modules):
179                     box = layout.box()
180                     box.set_context_pointer("freestyle_module", module)
181                     row = box.row(align=True)
182                     row.prop(module, "is_displayed", text="")
183                     row.prop(module, "module_path", text="")
184                     row.operator("scene.freestyle_module_remove", icon='ICON_X', text="")
185                     props = row.operator("scene.freestyle_module_move_up", icon='VICON_MOVE_UP', text="")
186                     props.active = (i > 0)
187                     props = row.operator("scene.freestyle_module_move_down", icon='VICON_MOVE_DOWN', text="")
188                     props.active = (i < len(freestyle.modules) - 1)
189
190
191 class RENDER_PT_shading(RenderButtonsPanel):
192     bl_label = "Shading"
193     COMPAT_ENGINES = set(['BLENDER_RENDER'])
194
195     def draw(self, context):
196         layout = self.layout
197
198         rd = context.scene.render_data
199         wide_ui = context.region.width > narrowui
200
201         split = layout.split()
202
203         col = split.column()
204         col.prop(rd, "render_textures", text="Textures")
205         col.prop(rd, "render_shadows", text="Shadows")
206         col.prop(rd, "render_sss", text="Subsurface Scattering")
207         col.prop(rd, "render_envmaps", text="Environment Map")
208
209         if wide_ui:
210             col = split.column()
211         col.prop(rd, "render_raytracing", text="Ray Tracing")
212         col.prop(rd, "color_management")
213         col.prop(rd, "alpha_mode", text="Alpha")
214
215
216 class RENDER_PT_performance(RenderButtonsPanel):
217     bl_label = "Performance"
218     bl_default_closed = True
219     COMPAT_ENGINES = set(['BLENDER_RENDER'])
220
221     def draw(self, context):
222         layout = self.layout
223
224         rd = context.scene.render_data
225         wide_ui = context.region.width > narrowui
226
227         split = layout.split()
228
229         col = split.column()
230         col.label(text="Threads:")
231         col.row().prop(rd, "threads_mode", expand=True)
232         sub = col.column()
233         sub.enabled = rd.threads_mode == 'THREADS_FIXED'
234         sub.prop(rd, "threads")
235         sub = col.column(align=True)
236         sub.label(text="Tiles:")
237         sub.prop(rd, "parts_x", text="X")
238         sub.prop(rd, "parts_y", text="Y")
239
240         if wide_ui:
241             col = split.column()
242         col.label(text="Memory:")
243         sub = col.column()
244         sub.prop(rd, "save_buffers")
245         sub.enabled = not rd.full_sample
246         sub = col.column()
247         sub.active = rd.use_compositing
248         sub.prop(rd, "free_image_textures")
249         sub = col.column()
250         sub.active = rd.render_raytracing
251         sub.label(text="Acceleration structure:")
252         sub.prop(rd, "raytrace_structure", text="")
253         if rd.raytrace_structure == 'OCTREE':
254             sub.prop(rd, "octree_resolution", text="Resolution")
255         else:
256             sub.prop(rd, "use_instances", text="Instances")
257         sub.prop(rd, "use_local_coords", text="Local Coordinates")
258
259
260 class RENDER_PT_post_processing(RenderButtonsPanel):
261     bl_label = "Post Processing"
262     bl_default_closed = True
263     COMPAT_ENGINES = set(['BLENDER_RENDER'])
264
265     def draw(self, context):
266         layout = self.layout
267
268         rd = context.scene.render_data
269         wide_ui = context.region.width > narrowui
270
271         split = layout.split()
272
273         col = split.column()
274         col.prop(rd, "use_compositing")
275         col.prop(rd, "use_sequencer")
276
277         if wide_ui:
278             col = split.column()
279         col.prop(rd, "dither_intensity", text="Dither", slider=True)
280
281         layout.separator()
282
283         split = layout.split()
284
285         col = split.column()
286         col.prop(rd, "fields", text="Fields")
287         sub = col.column()
288         sub.active = rd.fields
289         sub.row().prop(rd, "field_order", expand=True)
290         sub.prop(rd, "fields_still", text="Still")
291
292
293         if wide_ui:
294             col = split.column()
295         else:
296             col.separator()
297         col.prop(rd, "edge")
298         sub = col.column()
299         sub.active = rd.edge
300         sub.prop(rd, "edge_threshold", text="Threshold", slider=True)
301         sub.prop(rd, "edge_color", text="")
302
303         layout.separator()
304
305         split = layout.split()
306         col = split.column()
307         col.prop(rd, "freestyle", text="Freestyle")
308
309
310 class RENDER_PT_output(RenderButtonsPanel):
311     bl_label = "Output"
312     COMPAT_ENGINES = set(['BLENDER_RENDER'])
313
314     def draw(self, context):
315         layout = self.layout
316
317         rd = context.scene.render_data
318         wide_ui = context.region.width > narrowui
319
320         layout.prop(rd, "output_path", text="")
321
322         split = layout.split()
323         col = split.column()
324         col.prop(rd, "file_format", text="")
325         col.row().prop(rd, "color_mode", text="Color", expand=True)
326
327         if wide_ui:
328             col = split.column()
329         col.prop(rd, "file_extensions")
330         col.prop(rd, "use_overwrite")
331         col.prop(rd, "use_placeholder")
332
333         if rd.file_format in ('AVIJPEG', 'JPEG'):
334             split = layout.split()
335             split.prop(rd, "quality", slider=True)
336
337         elif rd.file_format == 'OPENEXR':
338             split = layout.split()
339
340             col = split.column()
341             col.label(text="Codec:")
342             col.prop(rd, "exr_codec", text="")
343
344             if wide_ui:
345                 subsplit = split.split()
346                 col = subsplit.column()
347             col.prop(rd, "exr_half")
348             col.prop(rd, "exr_zbuf")
349
350             if wide_ui:
351                 col = subsplit.column()
352             col.prop(rd, "exr_preview")
353
354         elif rd.file_format == 'JPEG2000':
355             split = layout.split()
356             col = split.column()
357             col.label(text="Depth:")
358             col.row().prop(rd, "jpeg2k_depth", expand=True)
359
360             if wide_ui:
361                 col = split.column()
362             col.prop(rd, "jpeg2k_preset", text="")
363             col.prop(rd, "jpeg2k_ycc")
364
365         elif rd.file_format in ('CINEON', 'DPX'):
366             split = layout.split()
367             col = split.column()
368             col.prop(rd, "cineon_log", text="Convert to Log")
369
370             if wide_ui:
371                 col = split.column(align=True)
372             col.active = rd.cineon_log
373             col.prop(rd, "cineon_black", text="Black")
374             col.prop(rd, "cineon_white", text="White")
375             col.prop(rd, "cineon_gamma", text="Gamma")
376
377         elif rd.file_format == 'TIFF':
378             split = layout.split()
379             split.prop(rd, "tiff_bit")
380
381         elif rd.file_format == 'QUICKTIME_QTKIT':
382             split = layout.split()
383             col = split.column()
384             col.prop(rd, "quicktime_codec_type")
385             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
386
387
388 class RENDER_PT_encoding(RenderButtonsPanel):
389     bl_label = "Encoding"
390     bl_default_closed = True
391     COMPAT_ENGINES = set(['BLENDER_RENDER'])
392
393     def poll(self, context):
394         rd = context.scene.render_data
395         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
396
397     def draw(self, context):
398         layout = self.layout
399
400         rd = context.scene.render_data
401         wide_ui = context.region.width > narrowui
402
403         split = layout.split()
404
405         col = split.column()
406         col.prop(rd, "ffmpeg_format")
407         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
408             if wide_ui:
409                 col = split.column()
410             col.prop(rd, "ffmpeg_codec")
411         else:
412             if wide_ui:
413                 split.label()
414
415         split = layout.split()
416
417         col = split.column()
418         col.prop(rd, "ffmpeg_video_bitrate")
419         if wide_ui:
420             col = split.column()
421         col.prop(rd, "ffmpeg_gopsize")
422
423         split = layout.split()
424
425         col = split.column()
426         col.label(text="Rate:")
427         col.prop(rd, "ffmpeg_minrate", text="Minimum")
428         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
429         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
430
431         if wide_ui:
432             col = split.column()
433
434         col.prop(rd, "ffmpeg_autosplit")
435         col.label(text="Mux:")
436         col.prop(rd, "ffmpeg_muxrate", text="Rate")
437         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
438
439         # Audio:
440         layout.prop(rd, "ffmpeg_multiplex_audio", text="Audio")
441
442         sub = layout.column()
443         sub.active = rd.ffmpeg_multiplex_audio
444         sub.prop(rd, "ffmpeg_audio_codec", text="Codec")
445         sub.separator()
446
447         split = sub.split()
448
449         col = split.column()
450         col.prop(rd, "ffmpeg_audio_bitrate")
451         col.prop(rd, "ffmpeg_audio_mixrate")
452
453         if wide_ui:
454             col = split.column()
455         col.prop(rd, "ffmpeg_audio_volume", slider=True)
456
457
458 class RENDER_PT_antialiasing(RenderButtonsPanel):
459     bl_label = "Anti-Aliasing"
460     COMPAT_ENGINES = set(['BLENDER_RENDER'])
461
462     def draw_header(self, context):
463         rd = context.scene.render_data
464
465         self.layout.prop(rd, "antialiasing", text="")
466
467     def draw(self, context):
468         layout = self.layout
469
470         rd = context.scene.render_data
471         wide_ui = context.region.width > narrowui
472         layout.active = rd.antialiasing
473
474         split = layout.split()
475
476         col = split.column()
477         col.row().prop(rd, "antialiasing_samples", expand=True)
478         col.prop(rd, "full_sample")
479
480         if wide_ui:
481             col = split.column()
482         col.prop(rd, "pixel_filter", text="")
483         col.prop(rd, "filter_size", text="Size")
484
485
486 class RENDER_PT_dimensions(RenderButtonsPanel):
487     bl_label = "Dimensions"
488     COMPAT_ENGINES = set(['BLENDER_RENDER'])
489
490     def draw(self, context):
491         layout = self.layout
492
493         scene = context.scene
494         rd = scene.render_data
495         wide_ui = context.region.width > narrowui
496
497         row = layout.row().split()
498         sub = row.row(align=True).split(percentage=0.75)
499         sub.menu("RENDER_MT_presets", text="Presets")
500         sub.operator("render.preset_add", text="Add")
501
502         split = layout.split()
503
504         col = split.column()
505         sub = col.column(align=True)
506         sub.label(text="Resolution:")
507         sub.prop(rd, "resolution_x", text="X")
508         sub.prop(rd, "resolution_y", text="Y")
509         sub.prop(rd, "resolution_percentage", text="")
510
511         sub.label(text="Aspect Ratio:")
512         sub.prop(rd, "pixel_aspect_x", text="X")
513         sub.prop(rd, "pixel_aspect_y", text="Y")
514
515         row = col.row()
516         row.prop(rd, "use_border", text="Border")
517         sub = row.row()
518         sub.active = rd.use_border
519         sub.prop(rd, "crop_to_border", text="Crop")
520
521         if wide_ui:
522             col = split.column()
523         sub = col.column(align=True)
524         sub.label(text="Frame Range:")
525         sub.prop(scene, "start_frame", text="Start")
526         sub.prop(scene, "end_frame", text="End")
527         sub.prop(scene, "frame_step", text="Step")
528
529         sub.label(text="Frame Rate:")
530         sub.prop(rd, "fps")
531         sub.prop(rd, "fps_base", text="/")
532
533
534 class RENDER_PT_stamp(RenderButtonsPanel):
535     bl_label = "Stamp"
536     bl_default_closed = True
537     COMPAT_ENGINES = set(['BLENDER_RENDER'])
538
539     def draw_header(self, context):
540         rd = context.scene.render_data
541
542         self.layout.prop(rd, "render_stamp", text="")
543
544     def draw(self, context):
545         layout = self.layout
546
547         rd = context.scene.render_data
548         wide_ui = context.region.width > narrowui
549
550         layout.active = rd.render_stamp
551
552         split = layout.split()
553
554         col = split.column()
555         col.prop(rd, "stamp_time", text="Time")
556         col.prop(rd, "stamp_date", text="Date")
557         col.prop(rd, "stamp_render_time", text="RenderTime")
558         col.prop(rd, "stamp_frame", text="Frame")
559         col.prop(rd, "stamp_scene", text="Scene")
560         col.prop(rd, "stamp_camera", text="Camera")
561         col.prop(rd, "stamp_filename", text="Filename")
562         col.prop(rd, "stamp_marker", text="Marker")
563         col.prop(rd, "stamp_sequence_strip", text="Seq. Strip")
564
565         if wide_ui:
566             col = split.column()
567         col.active = rd.render_stamp
568         col.prop(rd, "stamp_foreground", slider=True)
569         col.prop(rd, "stamp_background", slider=True)
570         col.separator()
571         col.prop(rd, "stamp_font_size", text="Font Size")
572
573         row = layout.split(percentage=0.2)
574         row.prop(rd, "stamp_note", text="Note")
575         sub = row.row()
576         sub.active = rd.stamp_note
577         sub.prop(rd, "stamp_note_text", text="")
578
579
580 bpy.types.register(RENDER_MT_presets)
581
582 bpy.types.register(RENDER_PT_render)
583 bpy.types.register(RENDER_PT_layers)
584 bpy.types.register(RENDER_PT_dimensions)
585 bpy.types.register(RENDER_PT_antialiasing)
586 bpy.types.register(RENDER_PT_shading)
587 bpy.types.register(RENDER_PT_output)
588 bpy.types.register(RENDER_PT_encoding)
589 bpy.types.register(RENDER_PT_performance)
590 bpy.types.register(RENDER_PT_post_processing)
591 bpy.types.register(RENDER_PT_stamp)