Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / properties_render_layer.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Panel, UIList
22
23
24 class RenderLayerButtonsPanel:
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "render_layer"
28     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
29
30     @classmethod
31     def poll(cls, context):
32         scene = context.scene
33         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
34
35
36 class RENDERLAYER_UL_renderlayers(UIList):
37     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
38         # assert(isinstance(item, bpy.types.SceneLayer)
39         layer = item
40         if self.layout_type in {'DEFAULT', 'COMPACT'}:
41             layout.prop(layer, "name", text="", icon_value=icon, emboss=False)
42             layout.prop(layer, "use", text="", index=index)
43         elif self.layout_type == 'GRID':
44             layout.alignment = 'CENTER'
45             layout.label("", icon_value=icon)
46
47
48 class RENDERLAYER_PT_layers(RenderLayerButtonsPanel, Panel):
49     bl_label = "Layer List"
50     bl_options = {'HIDE_HEADER'}
51     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
52
53     def draw(self, context):
54         layout = self.layout
55
56         scene = context.scene
57         rd = scene.render
58         view_render = scene.view_render
59
60         if view_render.engine == 'BLENDER_GAME':
61             layout.label("Not available in the Game Engine")
62             return
63
64         row = layout.row()
65         col = row.column()
66         col.template_list("RENDERLAYER_UL_renderlayers", "", scene, "render_layers", scene.render_layers, "active_index", rows=2)
67
68         col = row.column()
69         sub = col.column(align=True)
70         sub.operator("scene.render_layer_add", icon='ZOOMIN', text="")
71         sub.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
72         col.prop(rd, "use_single_layer", icon_only=True)
73
74
75 class RENDERLAYER_UL_renderviews(UIList):
76     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
77         # assert(isinstance(item, bpy.types.SceneRenderView)
78         view = item
79         if self.layout_type in {'DEFAULT', 'COMPACT'}:
80             if view.name in {'left', 'right'}:
81                 layout.label(view.name, icon_value=icon + (not view.use))
82             else:
83                 layout.prop(view, "name", text="", index=index, icon_value=icon, emboss=False)
84             layout.prop(view, "use", text="", index=index)
85
86         elif self.layout_type == 'GRID':
87             layout.alignment = 'CENTER'
88             layout.label("", icon_value=icon + (not view.use))
89
90
91 class RENDERLAYER_PT_views(RenderLayerButtonsPanel, Panel):
92     bl_label = "Views"
93     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
94     bl_options = {'DEFAULT_CLOSED'}
95
96     def draw_header(self, context):
97         rd = context.scene.render
98         self.layout.prop(rd, "use_multiview", text="")
99
100     def draw(self, context):
101         layout = self.layout
102
103         scene = context.scene
104         rd = scene.render
105         rv = rd.views.active
106
107         layout.active = rd.use_multiview
108         basic_stereo = rd.views_format == 'STEREO_3D'
109
110         row = layout.row()
111         row.prop(rd, "views_format", expand=True)
112
113         if basic_stereo:
114             row = layout.row()
115             row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
116
117             row = layout.row()
118             row.label(text="File Suffix:")
119             row.prop(rv, "file_suffix", text="")
120
121         else:
122             row = layout.row()
123             row.template_list("RENDERLAYER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
124
125             col = row.column(align=True)
126             col.operator("scene.render_view_add", icon='ZOOMIN', text="")
127             col.operator("scene.render_view_remove", icon='ZOOMOUT', text="")
128
129             row = layout.row()
130             row.label(text="Camera Suffix:")
131             row.prop(rv, "camera_suffix", text="")
132
133
134 class RENDERLAYER_PT_clay_settings(RenderLayerButtonsPanel, Panel):
135     bl_label = "Render Settings"
136     COMPAT_ENGINES = {'BLENDER_CLAY'}
137
138     @classmethod
139     def poll(cls, context):
140         scene = context.scene
141         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
142
143     def draw(self, context):
144         layout = self.layout
145         scene = context.scene
146         scene_props = scene.layer_properties['BLENDER_CLAY']
147         layer = bpy.context.render_layer
148         layer_props = layer.engine_overrides['BLENDER_CLAY']
149
150         col = layout.column()
151         col.template_override_property(layer_props, scene_props, "ssao_samples")
152
153
154 class RENDERLAYER_PT_eevee_ambient_occlusion(RenderLayerButtonsPanel, Panel):
155     bl_label = "Ambient Occlusion"
156     bl_options = {'DEFAULT_CLOSED'}
157     COMPAT_ENGINES = {'BLENDER_EEVEE'}
158
159     @classmethod
160     def poll(cls, context):
161         scene = context.scene
162         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
163
164     def draw_header(self, context):
165         scene = context.scene
166         scene_props = scene.layer_properties['BLENDER_EEVEE']
167         layer = bpy.context.render_layer
168         layer_props = layer.engine_overrides['BLENDER_EEVEE']
169
170         self.layout.template_override_property(layer_props, scene_props, "gtao_enable", text="")
171
172     def draw(self, context):
173         layout = self.layout
174         scene = context.scene
175         scene_props = scene.layer_properties['BLENDER_EEVEE']
176         layer = bpy.context.render_layer
177         layer_props = layer.engine_overrides['BLENDER_EEVEE']
178
179         col = layout.column()
180         col.template_override_property(layer_props, scene_props, "gtao_use_bent_normals")
181         col.template_override_property(layer_props, scene_props, "gtao_denoise")
182         col.template_override_property(layer_props, scene_props, "gtao_bounce")
183         col.template_override_property(layer_props, scene_props, "gtao_samples")
184         col.template_override_property(layer_props, scene_props, "gtao_distance")
185         col.template_override_property(layer_props, scene_props, "gtao_factor")
186         col.template_override_property(layer_props, scene_props, "gtao_quality")
187
188
189 class RENDERLAYER_PT_eevee_motion_blur(RenderLayerButtonsPanel, Panel):
190     bl_label = "Motion Blur"
191     bl_options = {'DEFAULT_CLOSED'}
192     COMPAT_ENGINES = {'BLENDER_EEVEE'}
193
194     @classmethod
195     def poll(cls, context):
196         scene = context.scene
197         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
198
199     def draw_header(self, context):
200         scene = context.scene
201         scene_props = scene.layer_properties['BLENDER_EEVEE']
202         layer = bpy.context.render_layer
203         layer_props = layer.engine_overrides['BLENDER_EEVEE']
204
205         self.layout.template_override_property(layer_props, scene_props, "motion_blur_enable", text="")
206
207     def draw(self, context):
208         layout = self.layout
209         scene = context.scene
210         scene_props = scene.layer_properties['BLENDER_EEVEE']
211         layer = bpy.context.render_layer
212         layer_props = layer.engine_overrides['BLENDER_EEVEE']
213
214         col = layout.column()
215         col.template_override_property(layer_props, scene_props, "motion_blur_samples")
216         col.template_override_property(layer_props, scene_props, "motion_blur_shutter")
217
218
219 class RENDERLAYER_PT_eevee_depth_of_field(RenderLayerButtonsPanel, Panel):
220     bl_label = "Depth Of Field"
221     bl_options = {'DEFAULT_CLOSED'}
222     COMPAT_ENGINES = {'BLENDER_EEVEE'}
223
224     @classmethod
225     def poll(cls, context):
226         scene = context.scene
227         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
228
229     def draw_header(self, context):
230         scene = context.scene
231         scene_props = scene.layer_properties['BLENDER_EEVEE']
232         layer = bpy.context.render_layer
233         layer_props = layer.engine_overrides['BLENDER_EEVEE']
234
235         self.layout.template_override_property(layer_props, scene_props, "dof_enable", text="")
236
237     def draw(self, context):
238         layout = self.layout
239         scene = context.scene
240         scene_props = scene.layer_properties['BLENDER_EEVEE']
241         layer = bpy.context.render_layer
242         layer_props = layer.engine_overrides['BLENDER_EEVEE']
243
244         col = layout.column()
245         col.template_override_property(layer_props, scene_props, "bokeh_max_size")
246         col.template_override_property(layer_props, scene_props, "bokeh_threshold")
247
248
249 class RENDERLAYER_PT_eevee_bloom(RenderLayerButtonsPanel, Panel):
250     bl_label = "Bloom"
251     bl_options = {'DEFAULT_CLOSED'}
252     COMPAT_ENGINES = {'BLENDER_EEVEE'}
253
254     @classmethod
255     def poll(cls, context):
256         scene = context.scene
257         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
258
259     def draw_header(self, context):
260         scene = context.scene
261         scene_props = scene.layer_properties['BLENDER_EEVEE']
262         layer = bpy.context.render_layer
263         layer_props = layer.engine_overrides['BLENDER_EEVEE']
264
265         self.layout.template_override_property(layer_props, scene_props, "bloom_enable", text="")
266
267     def draw(self, context):
268         layout = self.layout
269         scene = context.scene
270         scene_props = scene.layer_properties['BLENDER_EEVEE']
271         layer = bpy.context.render_layer
272         layer_props = layer.engine_overrides['BLENDER_EEVEE']
273
274         col = layout.column()
275         col.template_override_property(layer_props, scene_props, "bloom_threshold")
276         col.template_override_property(layer_props, scene_props, "bloom_knee")
277         col.template_override_property(layer_props, scene_props, "bloom_radius")
278         col.template_override_property(layer_props, scene_props, "bloom_color")
279         col.template_override_property(layer_props, scene_props, "bloom_intensity")
280         col.template_override_property(layer_props, scene_props, "bloom_clamp")
281
282
283 class RENDERLAYER_PT_eevee_volumetric(RenderLayerButtonsPanel, Panel):
284     bl_label = "Volumetric"
285     bl_options = {'DEFAULT_CLOSED'}
286     COMPAT_ENGINES = {'BLENDER_EEVEE'}
287
288     @classmethod
289     def poll(cls, context):
290         scene = context.scene
291         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
292
293     def draw_header(self, context):
294         scene = context.scene
295         scene_props = scene.layer_properties['BLENDER_EEVEE']
296         layer = bpy.context.render_layer
297         layer_props = layer.engine_overrides['BLENDER_EEVEE']
298
299         self.layout.template_override_property(layer_props, scene_props, "volumetric_enable", text="")
300
301     def draw(self, context):
302         layout = self.layout
303         scene = context.scene
304         scene_props = scene.layer_properties['BLENDER_EEVEE']
305         layer = bpy.context.render_layer
306         layer_props = layer.engine_overrides['BLENDER_EEVEE']
307
308         col = layout.column()
309         col.template_override_property(layer_props, scene_props, "volumetric_start")
310         col.template_override_property(layer_props, scene_props, "volumetric_end")
311         col.template_override_property(layer_props, scene_props, "volumetric_tile_size")
312         col.template_override_property(layer_props, scene_props, "volumetric_samples")
313         col.template_override_property(layer_props, scene_props, "volumetric_sample_distribution")
314         col.template_override_property(layer_props, scene_props, "volumetric_lights")
315         col.template_override_property(layer_props, scene_props, "volumetric_light_clamp")
316         col.template_override_property(layer_props, scene_props, "volumetric_shadows")
317         col.template_override_property(layer_props, scene_props, "volumetric_shadow_samples")
318         col.template_override_property(layer_props, scene_props, "volumetric_colored_transmittance")
319
320
321 class RENDERLAYER_PT_eevee_subsurface_scattering(RenderLayerButtonsPanel, Panel):
322     bl_label = "Subsurface Scattering"
323     bl_options = {'DEFAULT_CLOSED'}
324     COMPAT_ENGINES = {'BLENDER_EEVEE'}
325
326     @classmethod
327     def poll(cls, context):
328         scene = context.scene
329         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
330
331     def draw_header(self, context):
332         scene = context.scene
333         scene_props = scene.layer_properties['BLENDER_EEVEE']
334         layer = bpy.context.render_layer
335         layer_props = layer.engine_overrides['BLENDER_EEVEE']
336
337         self.layout.template_override_property(layer_props, scene_props, "sss_enable", text="")
338
339     def draw(self, context):
340         layout = self.layout
341         scene = context.scene
342         scene_props = scene.layer_properties['BLENDER_EEVEE']
343         layer = bpy.context.render_layer
344         layer_props = layer.engine_overrides['BLENDER_EEVEE']
345
346         col = layout.column()
347         col.template_override_property(layer_props, scene_props, "sss_samples")
348         col.template_override_property(layer_props, scene_props, "sss_jitter_threshold")
349
350
351 class RENDERLAYER_PT_eevee_screen_space_reflections(RenderLayerButtonsPanel, Panel):
352     bl_label = "Screen Space Reflections"
353     bl_options = {'DEFAULT_CLOSED'}
354     COMPAT_ENGINES = {'BLENDER_EEVEE'}
355
356     @classmethod
357     def poll(cls, context):
358         scene = context.scene
359         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
360
361     def draw_header(self, context):
362         scene = context.scene
363         scene_props = scene.layer_properties['BLENDER_EEVEE']
364         layer = bpy.context.render_layer
365         layer_props = layer.engine_overrides['BLENDER_EEVEE']
366
367         self.layout.template_override_property(layer_props, scene_props, "ssr_enable", text="")
368
369     def draw(self, context):
370         layout = self.layout
371         scene = context.scene
372         scene_props = scene.layer_properties['BLENDER_EEVEE']
373         layer = bpy.context.render_layer
374         layer_props = layer.engine_overrides['BLENDER_EEVEE']
375
376         col = layout.column()
377         col.template_override_property(layer_props, scene_props, "ssr_halfres")
378         col.template_override_property(layer_props, scene_props, "ssr_refraction")
379         col.template_override_property(layer_props, scene_props, "ssr_ray_count")
380         col.template_override_property(layer_props, scene_props, "ssr_quality")
381         col.template_override_property(layer_props, scene_props, "ssr_max_roughness")
382         col.template_override_property(layer_props, scene_props, "ssr_thickness")
383         col.template_override_property(layer_props, scene_props, "ssr_border_fade")
384         col.template_override_property(layer_props, scene_props, "ssr_firefly_fac")
385
386
387 class RENDERLAYER_PT_eevee_shadows(RenderLayerButtonsPanel, Panel):
388     bl_label = "Shadows"
389     bl_options = {'DEFAULT_CLOSED'}
390     COMPAT_ENGINES = {'BLENDER_EEVEE'}
391
392     @classmethod
393     def poll(cls, context):
394         scene = context.scene
395         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
396
397     def draw(self, context):
398         layout = self.layout
399         scene = context.scene
400         scene_props = scene.layer_properties['BLENDER_EEVEE']
401         layer = bpy.context.render_layer
402         layer_props = layer.engine_overrides['BLENDER_EEVEE']
403
404         col = layout.column()
405         col.template_override_property(layer_props, scene_props, "shadow_method")
406         col.template_override_property(layer_props, scene_props, "shadow_size")
407         col.template_override_property(layer_props, scene_props, "shadow_high_bitdepth")
408
409
410 class RENDERLAYER_PT_eevee_sampling(RenderLayerButtonsPanel, Panel):
411     bl_label = "Sampling"
412     bl_options = {'DEFAULT_CLOSED'}
413     COMPAT_ENGINES = {'BLENDER_EEVEE'}
414
415     @classmethod
416     def poll(cls, context):
417         scene = context.scene
418         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
419
420     def draw(self, context):
421         layout = self.layout
422         scene = context.scene
423         scene_props = scene.layer_properties['BLENDER_EEVEE']
424         layer = bpy.context.render_layer
425         layer_props = layer.engine_overrides['BLENDER_EEVEE']
426
427         col = layout.column()
428         col.template_override_property(layer_props, scene_props, "taa_samples")
429
430
431 class RENDERLAYER_PT_eevee_indirect_lighting(RenderLayerButtonsPanel, Panel):
432     bl_label = "Indirect Lighting"
433     bl_options = {'DEFAULT_CLOSED'}
434     COMPAT_ENGINES = {'BLENDER_EEVEE'}
435
436     @classmethod
437     def poll(cls, context):
438         scene = context.scene
439         return scene and (scene.view_render.engine in cls.COMPAT_ENGINES)
440
441     def draw(self, context):
442         layout = self.layout
443         scene = context.scene
444         scene_props = scene.layer_properties['BLENDER_EEVEE']
445         layer = bpy.context.render_layer
446         layer_props = layer.engine_overrides['BLENDER_EEVEE']
447
448         col = layout.column()
449         col.template_override_property(layer_props, scene_props, "gi_diffuse_bounces")
450
451
452 classes = (
453     RENDERLAYER_UL_renderlayers,
454     RENDERLAYER_PT_layers,
455     RENDERLAYER_UL_renderviews,
456     RENDERLAYER_PT_views,
457     RENDERLAYER_PT_clay_settings,
458     RENDERLAYER_PT_eevee_sampling,
459     RENDERLAYER_PT_eevee_shadows,
460     RENDERLAYER_PT_eevee_indirect_lighting,
461     RENDERLAYER_PT_eevee_subsurface_scattering,
462     RENDERLAYER_PT_eevee_screen_space_reflections,
463     RENDERLAYER_PT_eevee_ambient_occlusion,
464     RENDERLAYER_PT_eevee_volumetric,
465     RENDERLAYER_PT_eevee_motion_blur,
466     RENDERLAYER_PT_eevee_depth_of_field,
467     RENDERLAYER_PT_eevee_bloom,
468 )
469
470 if __name__ == "__main__":  # only for live edit.
471     from bpy.utils import register_class
472     for cls in classes:
473         register_class(cls)