Sculpt:
[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
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='ICON_X')
149         row = col.row()
150         row.prop(rl, "pass_shadow")
151         row.prop(rl, "pass_shadow_exclude", text="", icon='ICON_X')
152         row = col.row()
153         row.prop(rl, "pass_ao")
154         row.prop(rl, "pass_ao_exclude", text="", icon='ICON_X')
155         row = col.row()
156         row.prop(rl, "pass_reflection")
157         row.prop(rl, "pass_reflection_exclude", text="", icon='ICON_X')
158         row = col.row()
159         row.prop(rl, "pass_refraction")
160         row.prop(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.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 = 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.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 = 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.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 = 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.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, "file_extensions")
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_QTKIT':
348             split = layout.split()
349             col = split.column()
350             col.prop(rd, "quicktime_codec_type")
351             col.prop(rd, "quicktime_codec_spatial_quality", text="Quality")
352
353
354 class RENDER_PT_encoding(RenderButtonsPanel):
355     bl_label = "Encoding"
356     bl_default_closed = True
357     COMPAT_ENGINES = set(['BLENDER_RENDER'])
358
359     def poll(self, context):
360         rd = context.scene.render_data
361         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
362
363     def draw(self, context):
364         layout = self.layout
365
366         rd = context.scene.render_data
367         wide_ui = context.region.width > narrowui
368
369         split = layout.split()
370
371         col = split.column()
372         col.prop(rd, "ffmpeg_format")
373         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
374             if wide_ui:
375                 col = split.column()
376             col.prop(rd, "ffmpeg_codec")
377         else:
378             if wide_ui:
379                 split.label()
380
381         split = layout.split()
382
383         col = split.column()
384         col.prop(rd, "ffmpeg_video_bitrate")
385         if wide_ui:
386             col = split.column()
387         col.prop(rd, "ffmpeg_gopsize")
388
389         split = layout.split()
390
391         col = split.column()
392         col.label(text="Rate:")
393         col.prop(rd, "ffmpeg_minrate", text="Minimum")
394         col.prop(rd, "ffmpeg_maxrate", text="Maximum")
395         col.prop(rd, "ffmpeg_buffersize", text="Buffer")
396
397         if wide_ui:
398             col = split.column()
399
400         col.prop(rd, "ffmpeg_autosplit")
401         col.label(text="Mux:")
402         col.prop(rd, "ffmpeg_muxrate", text="Rate")
403         col.prop(rd, "ffmpeg_packetsize", text="Packet Size")
404         
405         # Audio: 
406         layout.prop(rd, "ffmpeg_multiplex_audio", text="Audio")
407
408         sub = layout.column()
409         sub.active = rd.ffmpeg_multiplex_audio
410         sub.prop(rd, "ffmpeg_audio_codec", text="Codec")
411         sub.separator()
412
413         split = sub.split()
414
415         col = split.column()
416         col.prop(rd, "ffmpeg_audio_bitrate")
417         col.prop(rd, "ffmpeg_audio_mixrate")
418
419         if wide_ui:
420             col = split.column()
421         col.prop(rd, "ffmpeg_audio_volume", slider=True)
422
423
424 class RENDER_PT_antialiasing(RenderButtonsPanel):
425     bl_label = "Anti-Aliasing"
426     COMPAT_ENGINES = set(['BLENDER_RENDER'])
427
428     def draw_header(self, context):
429         rd = context.scene.render_data
430
431         self.layout.prop(rd, "antialiasing", text="")
432
433     def draw(self, context):
434         layout = self.layout
435
436         rd = context.scene.render_data
437         wide_ui = context.region.width > narrowui
438         layout.active = rd.antialiasing
439
440         split = layout.split()
441
442         col = split.column()
443         col.row().prop(rd, "antialiasing_samples", expand=True)
444         col.prop(rd, "full_sample")
445
446         if wide_ui:
447             col = split.column()
448         col.prop(rd, "pixel_filter", text="")
449         col.prop(rd, "filter_size", text="Size")
450
451
452 class RENDER_PT_dimensions(RenderButtonsPanel):
453     bl_label = "Dimensions"
454     COMPAT_ENGINES = set(['BLENDER_RENDER'])
455
456     def draw(self, context):
457         layout = self.layout
458
459         scene = context.scene
460         rd = scene.render_data
461         wide_ui = context.region.width > narrowui
462
463         row = layout.row().split()
464         sub = row.row(align=True).split(percentage=0.75)
465         sub.menu("RENDER_MT_presets", text="Presets")
466         sub.operator("render.preset_add", text="Add")
467
468         split = layout.split()
469
470         col = split.column()
471         sub = col.column(align=True)
472         sub.label(text="Resolution:")
473         sub.prop(rd, "resolution_x", text="X")
474         sub.prop(rd, "resolution_y", text="Y")
475         sub.prop(rd, "resolution_percentage", text="")
476
477         sub.label(text="Aspect Ratio:")
478         sub.prop(rd, "pixel_aspect_x", text="X")
479         sub.prop(rd, "pixel_aspect_y", text="Y")
480
481         row = col.row()
482         row.prop(rd, "use_border", text="Border")
483         sub = row.row()
484         sub.active = rd.use_border
485         sub.prop(rd, "crop_to_border", text="Crop")
486
487         if wide_ui:
488             col = split.column()
489         sub = col.column(align=True)
490         sub.label(text="Frame Range:")
491         sub.prop(scene, "start_frame", text="Start")
492         sub.prop(scene, "end_frame", text="End")
493         sub.prop(scene, "frame_step", text="Step")
494
495         sub.label(text="Frame Rate:")
496         sub.prop(rd, "fps")
497         sub.prop(rd, "fps_base", text="/")
498
499
500 class RENDER_PT_stamp(RenderButtonsPanel):
501     bl_label = "Stamp"
502     bl_default_closed = True
503     COMPAT_ENGINES = set(['BLENDER_RENDER'])
504
505     def draw_header(self, context):
506         rd = context.scene.render_data
507
508         self.layout.prop(rd, "render_stamp", text="")
509
510     def draw(self, context):
511         layout = self.layout
512
513         rd = context.scene.render_data
514         wide_ui = context.region.width > narrowui
515
516         layout.active = rd.render_stamp
517
518         split = layout.split()
519
520         col = split.column()
521         col.prop(rd, "stamp_time", text="Time")
522         col.prop(rd, "stamp_date", text="Date")
523         col.prop(rd, "stamp_render_time", text="RenderTime")
524         col.prop(rd, "stamp_frame", text="Frame")
525         col.prop(rd, "stamp_scene", text="Scene")
526         col.prop(rd, "stamp_camera", text="Camera")
527         col.prop(rd, "stamp_filename", text="Filename")
528         col.prop(rd, "stamp_marker", text="Marker")
529         col.prop(rd, "stamp_sequence_strip", text="Seq. Strip")
530
531         if wide_ui:
532             col = split.column()
533         col.active = rd.render_stamp
534         col.prop(rd, "stamp_foreground", slider=True)
535         col.prop(rd, "stamp_background", slider=True)
536         col.separator()
537         col.prop(rd, "stamp_font_size", text="Font Size")
538
539         row = layout.split(percentage=0.2)
540         row.prop(rd, "stamp_note", text="Note")
541         sub = row.row()
542         sub.active = rd.stamp_note
543         sub.prop(rd, "stamp_note_text", text="")
544
545
546 bpy.types.register(RENDER_MT_presets)
547
548 bpy.types.register(RENDER_PT_render)
549 bpy.types.register(RENDER_PT_layers)
550 bpy.types.register(RENDER_PT_dimensions)
551 bpy.types.register(RENDER_PT_antialiasing)
552 bpy.types.register(RENDER_PT_shading)
553 bpy.types.register(RENDER_PT_output)
554 bpy.types.register(RENDER_PT_encoding)
555 bpy.types.register(RENDER_PT_performance)
556 bpy.types.register(RENDER_PT_post_processing)
557 bpy.types.register(RENDER_PT_stamp)