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