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