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