* Minor code cleanup.
[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 class RenderButtonsPanel(bpy.types.Panel):
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "render"
28     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
29
30     
31
32     def poll(self, context):
33         rd = context.scene.render_data
34         return (context.scene and rd.use_game_engine == False) and (rd.engine in self.COMPAT_ENGINES)
35    
36     
37
38 class RENDER_PT_render(RenderButtonsPanel):
39     bl_label = "Render"
40     COMPAT_ENGINES = set(['BLENDER_RENDER'])
41
42     def draw(self, context):
43         layout = self.layout
44
45         rd = context.scene.render_data
46         col2 = context.region.width > narrowui
47         
48         split = layout.split()
49         
50         col = split.column()
51         col.itemO("screen.render", text="Image", icon='ICON_RENDER_STILL')
52         
53         if col2:
54             col = split.column()
55         col.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION')
56
57         layout.itemR(rd, "display_mode", text="Display")
58
59
60 class RENDER_PT_layers(RenderButtonsPanel):
61     bl_label = "Layers"
62     bl_default_closed = True
63     COMPAT_ENGINES = set(['BLENDER_RENDER'])
64
65     def draw(self, context):
66         layout = self.layout
67
68         scene = context.scene
69         rd = scene.render_data
70         col2 = context.region.width > narrowui
71         
72         row = layout.row()
73         row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
74
75         col = row.column(align=True)
76         col.itemO("scene.render_layer_add", icon='ICON_ZOOMIN', text="")
77         col.itemO("scene.render_layer_remove", icon='ICON_ZOOMOUT', text="")
78
79         rl = rd.layers[rd.active_layer_index]
80
81         if rl:
82             layout.itemR(rl, "name")
83
84         split = layout.split()
85
86         col = split.column()
87         col.itemR(scene, "visible_layers", text="Scene")
88         if col2:
89             col = split.column()
90         col.itemR(rl, "visible_layers", text="Layer")
91
92         layout.itemR(rl, "light_override", text="Light")
93         layout.itemR(rl, "material_override", text="Material")
94
95         layout.itemS()
96         layout.itemL(text="Include:")
97
98         split = layout.split()
99
100         col = split.column()
101         col.itemR(rl, "zmask")
102         row = col.row()
103         row.itemR(rl, "zmask_negate", text="Negate")
104         row.active = rl.zmask
105         col.itemR(rl, "all_z")
106
107         col = split.column()
108         col.itemR(rl, "solid")
109         col.itemR(rl, "halo")
110         col.itemR(rl, "ztransp")
111
112         col = split.column()
113         col.itemR(rl, "sky")
114         col.itemR(rl, "edge")
115         col.itemR(rl, "strand")
116
117         if rl.zmask:
118             split = layout.split()
119             split.itemL(text="Zmask Layers:")
120             split.column().itemR(rl, "zmask_layers", text="")
121
122         layout.itemS()
123
124         split = layout.split()
125
126         col = split.column()
127         col.itemL(text="Passes:")
128         col.itemR(rl, "pass_combined")
129         col.itemR(rl, "pass_z")
130         col.itemR(rl, "pass_vector")
131         col.itemR(rl, "pass_normal")
132         col.itemR(rl, "pass_uv")
133         col.itemR(rl, "pass_mist")
134         col.itemR(rl, "pass_object_index")
135
136         if col2:
137             col = split.column()
138         col.itemL()
139         col.itemR(rl, "pass_color")
140         col.itemR(rl, "pass_diffuse")
141         row = col.row()
142         row.itemR(rl, "pass_specular")
143         row.itemR(rl, "pass_specular_exclude", text="", icon='ICON_X')
144         row = col.row()
145         row.itemR(rl, "pass_shadow")
146         row.itemR(rl, "pass_shadow_exclude", text="", icon='ICON_X')
147         row = col.row()
148         row.itemR(rl, "pass_ao")
149         row.itemR(rl, "pass_ao_exclude", text="", icon='ICON_X')
150         row = col.row()
151         row.itemR(rl, "pass_reflection")
152         row.itemR(rl, "pass_reflection_exclude", text="", icon='ICON_X')
153         row = col.row()
154         row.itemR(rl, "pass_refraction")
155         row.itemR(rl, "pass_refraction_exclude", text="", icon='ICON_X')
156
157
158 class RENDER_PT_shading(RenderButtonsPanel):
159     bl_label = "Shading"
160     COMPAT_ENGINES = set(['BLENDER_RENDER'])
161
162     def draw(self, context):
163         layout = self.layout
164
165         rd = context.scene.render_data
166         col2 = context.region.width > narrowui
167         
168         split = layout.split()
169
170         col = split.column()
171         col.itemR(rd, "render_textures", text="Textures")
172         col.itemR(rd, "render_shadows", text="Shadows")
173         col.itemR(rd, "render_sss", text="Subsurface Scattering")
174         col.itemR(rd, "render_envmaps", text="Environment Map")
175         
176         if col2:
177             col = split.column()
178         col.itemR(rd, "render_raytracing", text="Ray Tracing")
179         col.itemR(rd, "color_management")
180         col.itemR(rd, "alpha_mode", text="Alpha")
181
182
183 class RENDER_PT_performance(RenderButtonsPanel):
184     bl_label = "Performance"
185     bl_default_closed = True
186     COMPAT_ENGINES = set(['BLENDER_RENDER'])
187
188     def draw(self, context):
189         layout = self.layout
190
191         rd = context.scene.render_data
192         col2 = context.region.width > narrowui
193         
194         split = layout.split()
195
196         col = split.column(align=True)
197         col.itemL(text="Threads:")
198         col.row().itemR(rd, "threads_mode", expand=True)
199         sub = col.column()
200         sub.enabled = rd.threads_mode == 'THREADS_FIXED'
201         sub.itemR(rd, "threads")
202         col.itemL(text="Tiles:")
203         col.itemR(rd, "parts_x", text="X")
204         col.itemR(rd, "parts_y", text="Y")
205
206         if col2:
207             col = split.column()
208         col.itemL(text="Memory:")
209         sub = col.column()
210         sub.itemR(rd, "save_buffers")
211         sub.enabled = not rd.full_sample
212         sub = col.column()
213         sub.active = rd.use_compositing
214         sub.itemR(rd, "free_image_textures")
215         sub = col.column()
216         sub.active = rd.render_raytracing
217         sub.itemL(text="Acceleration structure:")
218         sub.itemR(rd, "raytrace_structure", text="")
219         if rd.raytrace_structure == 'OCTREE':
220             sub.itemR(rd, "octree_resolution", text="Resolution")
221         else:
222             sub.itemR(rd, "use_instances", text="Instances")
223         sub.itemR(rd, "use_local_coords", text="Local Coordinates")
224
225
226 class RENDER_PT_post_processing(RenderButtonsPanel):
227     bl_label = "Post Processing"
228     bl_default_closed = True
229     COMPAT_ENGINES = set(['BLENDER_RENDER'])
230
231     def draw(self, context):
232         layout = self.layout
233         
234         rd = context.scene.render_data
235         col2 = context.region.width > narrowui
236         
237         split = layout.split()
238
239         col = split.column()
240         col.itemR(rd, "use_compositing")
241         col.itemR(rd, "use_sequencer")
242
243         if col2:
244             col = split.column()
245         col.itemR(rd, "dither_intensity", text="Dither", slider=True)
246
247         layout.itemS()
248
249         split = layout.split()
250
251         col = split.column()
252         col.itemR(rd, "fields", text="Fields")
253         sub = col.column()
254         sub.active = rd.fields
255         sub.row().itemR(rd, "field_order", expand=True)
256         sub.itemR(rd, "fields_still", text="Still")
257
258
259         if col2:
260             col = split.column()
261         else:
262             col.itemS()
263         col.itemR(rd, "edge")
264         sub = col.column()
265         sub.active = rd.edge
266         sub.itemR(rd, "edge_threshold", text="Threshold", slider=True)
267         sub.itemR(rd, "edge_color", text="")
268
269
270 class RENDER_PT_output(RenderButtonsPanel):
271     bl_label = "Output"
272     COMPAT_ENGINES = set(['BLENDER_RENDER'])
273
274     def draw(self, context):
275         layout = self.layout
276         
277         rd = context.scene.render_data
278         col2 = context.region.width > narrowui
279         
280         layout.itemR(rd, "output_path", text="")
281
282         split = layout.split()
283         col = split.column()
284         col.itemR(rd, "file_format", text="")
285         col.row().itemR(rd, "color_mode", text="Color", expand=True)
286
287         if col2:
288             col = split.column()
289         col.itemR(rd, "file_extensions")
290         col.itemR(rd, "use_overwrite")
291         col.itemR(rd, "use_placeholder")
292
293         if rd.file_format in ('AVIJPEG', 'JPEG'):
294             split = layout.split()
295             split.itemR(rd, "quality", slider=True)
296
297         elif rd.file_format == 'OPENEXR':
298             split = layout.split()
299
300             col = split.column()
301             col.itemL(text="Codec:")
302             col.itemR(rd, "exr_codec", text="")
303             
304             if col2:
305                 subsplit = split.split()
306                 col = subsplit.column()
307             col.itemR(rd, "exr_half")
308             col.itemR(rd, "exr_zbuf")
309             
310             if col2:
311                 col = subsplit.column()
312             col.itemR(rd, "exr_preview")
313
314         elif rd.file_format == 'JPEG2000':
315             split = layout.split()
316             col = split.column()
317             col.itemL(text="Depth:")
318             col.row().itemR(rd, "jpeg2k_depth", expand=True)
319
320             if col2:
321                 col = split.column()
322             col.itemR(rd, "jpeg2k_preset", text="")
323             col.itemR(rd, "jpeg2k_ycc")
324
325         elif rd.file_format in ('CINEON', 'DPX'):
326             split = layout.split()
327             col = split.column()
328             col.itemR(rd, "cineon_log", text="Convert to Log")
329
330             if col2:
331                 col = split.column(align=True)
332             col.active = rd.cineon_log
333             col.itemR(rd, "cineon_black", text="Black")
334             col.itemR(rd, "cineon_white", text="White")
335             col.itemR(rd, "cineon_gamma", text="Gamma")
336
337         elif rd.file_format == 'TIFF':
338             split = layout.split()
339             split.itemR(rd, "tiff_bit")
340
341
342 class RENDER_PT_encoding(RenderButtonsPanel):
343     bl_label = "Encoding"
344     bl_default_closed = True
345     COMPAT_ENGINES = set(['BLENDER_RENDER'])
346
347     def poll(self, context):
348         rd = context.scene.render_data
349         return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
350
351     def draw(self, context):
352         layout = self.layout
353
354         rd = context.scene.render_data
355         col2 = context.region.width > narrowui
356
357         split = layout.split()
358
359         split.itemR(rd, "ffmpeg_format")
360         if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
361             split.itemR(rd, "ffmpeg_codec")
362         else:
363             split.itemL()
364
365         split = layout.split()
366
367         col = split.column()
368         col.itemR(rd, "ffmpeg_video_bitrate")
369         col.itemL(text="Rate:")
370         col.itemR(rd, "ffmpeg_minrate", text="Minimum")
371         col.itemR(rd, "ffmpeg_maxrate", text="Maximum")
372         col.itemR(rd, "ffmpeg_buffersize", text="Buffer")
373
374         if col2:
375             col = split.column()
376         col.itemR(rd, "ffmpeg_gopsize")
377         col.itemR(rd, "ffmpeg_autosplit")
378         col.itemL(text="Mux:")
379         col.itemR(rd, "ffmpeg_muxrate", text="Rate")
380         col.itemR(rd, "ffmpeg_packetsize", text="Packet Size")
381
382         row = layout.row()
383         row.itemL(text="Audio:")
384         row = layout.row()
385         row.itemR(rd, "ffmpeg_audio_codec")
386
387         split = layout.split()
388
389         col = split.column()
390         col.itemR(rd, "ffmpeg_audio_bitrate")
391         col.itemR(rd, "ffmpeg_audio_mixrate")
392         
393         if col2:
394             col = split.column()
395         col.itemR(rd, "ffmpeg_multiplex_audio")
396         col.itemR(rd, "ffmpeg_audio_volume")
397
398
399 class RENDER_PT_antialiasing(RenderButtonsPanel):
400     bl_label = "Anti-Aliasing"
401     COMPAT_ENGINES = set(['BLENDER_RENDER'])
402
403     def draw_header(self, context):
404         rd = context.scene.render_data
405
406         self.layout.itemR(rd, "antialiasing", text="")
407
408     def draw(self, context):
409         layout = self.layout
410
411         rd = context.scene.render_data
412         col2 = context.region.width > narrowui
413         layout.active = rd.antialiasing
414         
415         split = layout.split()
416
417         col = split.column()
418         col.row().itemR(rd, "antialiasing_samples", expand=True)
419         col.itemR(rd, "full_sample")
420
421         if col2:
422             col = split.column()
423         col.itemR(rd, "pixel_filter", text="")
424         col.itemR(rd, "filter_size", text="Size", slider=True)
425
426
427 class RENDER_PT_dimensions(RenderButtonsPanel):
428     bl_label = "Dimensions"
429     COMPAT_ENGINES = set(['BLENDER_RENDER'])
430
431     def draw(self, context):
432         layout = self.layout
433
434         scene = context.scene
435         rd = scene.render_data
436         col2 = context.region.width > narrowui
437         
438         split = layout.split()
439
440         col = split.column()
441         sub = col.column(align=True)
442         sub.itemL(text="Resolution:")
443         sub.itemR(rd, "resolution_x", text="X")
444         sub.itemR(rd, "resolution_y", text="Y")
445         sub.itemR(rd, "resolution_percentage", text="")
446
447         sub.itemL(text="Aspect Ratio:")
448         sub.itemR(rd, "pixel_aspect_x", text="X")
449         sub.itemR(rd, "pixel_aspect_y", text="Y")
450
451         row = col.row()
452         row.itemR(rd, "use_border", text="Border")
453         sub = row.row()
454         sub.active = rd.use_border
455         sub.itemR(rd, "crop_to_border", text="Crop")
456
457         if col2:
458             col = split.column()
459         sub = col.column(align=True)
460         sub.itemL(text="Frame Range:")
461         sub.itemR(scene, "start_frame", text="Start")
462         sub.itemR(scene, "end_frame", text="End")
463         sub.itemR(scene, "frame_step", text="Step")
464         
465         sub = col.column(align=True)
466         sub.itemL(text="Frame Rate:")
467         sub.itemR(rd, "fps")
468         sub.itemR(rd, "fps_base", text="/")
469
470
471 class RENDER_PT_stamp(RenderButtonsPanel):
472     bl_label = "Stamp"
473     bl_default_closed = True
474     COMPAT_ENGINES = set(['BLENDER_RENDER'])
475
476     def draw_header(self, context):
477         rd = context.scene.render_data
478
479         self.layout.itemR(rd, "render_stamp", text="")
480
481     def draw(self, context):
482         layout = self.layout
483
484         rd = context.scene.render_data
485         col2 = context.region.width > narrowui
486
487         layout.active = rd.render_stamp
488
489         split = layout.split()
490
491         col = split.column()
492         col.itemR(rd, "stamp_time", text="Time")
493         col.itemR(rd, "stamp_date", text="Date")
494         col.itemR(rd, "stamp_render_time", text="RenderTime")
495         col.itemR(rd, "stamp_frame", text="Frame")
496         col.itemR(rd, "stamp_scene", text="Scene")
497         col.itemR(rd, "stamp_camera", text="Camera")
498         col.itemR(rd, "stamp_filename", text="Filename")
499         col.itemR(rd, "stamp_marker", text="Marker")
500         col.itemR(rd, "stamp_sequence_strip", text="Seq. Strip")
501
502         if col2:
503             col = split.column()
504         col.active = rd.render_stamp
505         col.itemR(rd, "stamp_foreground", slider=True)
506         col.itemR(rd, "stamp_background", slider=True)
507         col.itemR(rd, "stamp_font_size", text="Font Size")
508
509         row = layout.split(percentage=0.2)
510         row.itemR(rd, "stamp_note", text="Note")
511         sub = row.row()
512         sub.active = rd.stamp_note
513         sub.itemR(rd, "stamp_note_text", text="")
514
515 bpy.types.register(RENDER_PT_render)
516 bpy.types.register(RENDER_PT_layers)
517 bpy.types.register(RENDER_PT_dimensions)
518 bpy.types.register(RENDER_PT_antialiasing)
519 bpy.types.register(RENDER_PT_shading)
520 bpy.types.register(RENDER_PT_output)
521 bpy.types.register(RENDER_PT_encoding)
522 bpy.types.register(RENDER_PT_performance)
523 bpy.types.register(RENDER_PT_post_processing)
524 bpy.types.register(RENDER_PT_stamp)