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