Cleanup: style
[blender.git] / release / scripts / startup / bl_ui / properties_render.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2
3 #
4 #  This program is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU General Public License
6 #  as published by the Free Software Foundation; either version 2
7 #  of the License, or (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software Foundation,
16 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # ##### END GPL LICENSE BLOCK #####
19
20 # <pep8 compliant>
21 import bpy
22 from bpy.types import Menu, Panel, UIList
23 from .space_view3d import (
24     VIEW3D_PT_shading_lighting,
25     VIEW3D_PT_shading_color,
26     VIEW3D_PT_shading_options,
27 )
28
29
30 class RenderButtonsPanel:
31     bl_space_type = 'PROPERTIES'
32     bl_region_type = 'WINDOW'
33     bl_context = "render"
34     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
35
36     @classmethod
37     def poll(cls, context):
38         return (context.engine in cls.COMPAT_ENGINES)
39
40
41 class RENDER_PT_context(Panel):
42     bl_space_type = 'PROPERTIES'
43     bl_region_type = 'WINDOW'
44     bl_context = "render"
45     bl_options = {'HIDE_HEADER'}
46     bl_label = ""
47
48     @classmethod
49     def poll(cls, context):
50         return context.scene
51
52     def draw(self, context):
53         layout = self.layout
54         layout.use_property_split = True
55         layout.use_property_decorate = False
56
57         scene = context.scene
58         rd = scene.render
59
60         if rd.has_multiple_engines:
61             layout.prop(rd, "engine", text="Render Engine")
62
63
64 class RENDER_PT_color_management(RenderButtonsPanel, Panel):
65     bl_label = "Color Management"
66     bl_options = {'DEFAULT_CLOSED'}
67     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
68
69     def draw(self, context):
70         layout = self.layout
71         layout.use_property_split = True
72         layout.use_property_decorate = False  # No animation.
73
74         scene = context.scene
75         view = scene.view_settings
76
77         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
78
79         col = flow.column()
80         col.prop(scene.display_settings, "display_device")
81
82         col.separator()
83
84         col.prop(view, "view_transform")
85         col.prop(view, "look")
86
87         col = flow.column()
88         col.prop(view, "exposure")
89         col.prop(view, "gamma")
90
91         col.separator()
92
93         col.prop(scene.sequencer_colorspace_settings, "name", text="Sequencer")
94
95
96 class RENDER_PT_color_management_curves(RenderButtonsPanel, Panel):
97     bl_label = "Use Curves"
98     bl_parent_id = "RENDER_PT_color_management"
99     bl_options = {'DEFAULT_CLOSED'}
100     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
101
102     def draw_header(self, context):
103
104         scene = context.scene
105         view = scene.view_settings
106
107         self.layout.prop(view, "use_curve_mapping", text="")
108
109     def draw(self, context):
110         layout = self.layout
111
112         scene = context.scene
113         view = scene.view_settings
114
115         layout.use_property_split = False
116         layout.use_property_decorate = False  # No animation.
117
118         layout.enabled = view.use_curve_mapping
119
120         layout.template_curve_mapping(view, "curve_mapping", levels=True)
121
122
123 class RENDER_PT_eevee_ambient_occlusion(RenderButtonsPanel, Panel):
124     bl_label = "Ambient Occlusion"
125     bl_options = {'DEFAULT_CLOSED'}
126     COMPAT_ENGINES = {'BLENDER_EEVEE'}
127
128     @classmethod
129     def poll(cls, context):
130         return (context.engine in cls.COMPAT_ENGINES)
131
132     def draw_header(self, context):
133         scene = context.scene
134         props = scene.eevee
135         self.layout.prop(props, "use_gtao", text="")
136
137     def draw(self, context):
138         layout = self.layout
139         layout.use_property_split = True
140         scene = context.scene
141         props = scene.eevee
142
143         layout.active = props.use_gtao
144         col = layout.column()
145         col.prop(props, "gtao_distance")
146         col.prop(props, "gtao_factor")
147         col.prop(props, "gtao_quality")
148         col.prop(props, "use_gtao_bent_normals")
149         col.prop(props, "use_gtao_bounce")
150
151
152 class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
153     bl_label = "Motion Blur"
154     bl_options = {'DEFAULT_CLOSED'}
155     COMPAT_ENGINES = {'BLENDER_EEVEE'}
156
157     @classmethod
158     def poll(cls, context):
159         return (context.engine in cls.COMPAT_ENGINES)
160
161     def draw_header(self, context):
162         scene = context.scene
163         props = scene.eevee
164         self.layout.prop(props, "use_motion_blur", text="")
165
166     def draw(self, context):
167         layout = self.layout
168         layout.use_property_split = True
169         scene = context.scene
170         props = scene.eevee
171
172         layout.active = props.use_motion_blur
173         col = layout.column()
174         col.prop(props, "motion_blur_samples")
175         col.prop(props, "motion_blur_shutter")
176
177
178 class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
179     bl_label = "Depth of Field"
180     bl_options = {'DEFAULT_CLOSED'}
181     COMPAT_ENGINES = {'BLENDER_EEVEE'}
182
183     @classmethod
184     def poll(cls, context):
185         return (context.engine in cls.COMPAT_ENGINES)
186
187     def draw_header(self, context):
188         scene = context.scene
189         props = scene.eevee
190         self.layout.prop(props, "use_dof", text="")
191
192     def draw(self, context):
193         layout = self.layout
194         layout.use_property_split = True
195         scene = context.scene
196         props = scene.eevee
197
198         layout.active = props.use_dof
199         col = layout.column()
200         col.prop(props, "bokeh_max_size")
201         # Not supported yet
202         # col.prop(props, "bokeh_threshold")
203
204
205 class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
206     bl_label = "Bloom"
207     bl_options = {'DEFAULT_CLOSED'}
208     COMPAT_ENGINES = {'BLENDER_EEVEE'}
209
210     @classmethod
211     def poll(cls, context):
212         return (context.engine in cls.COMPAT_ENGINES)
213
214     def draw_header(self, context):
215         scene = context.scene
216         props = scene.eevee
217         self.layout.prop(props, "use_bloom", text="")
218
219     def draw(self, context):
220         layout = self.layout
221         layout.use_property_split = True
222
223         scene = context.scene
224         props = scene.eevee
225
226         layout.active = props.use_bloom
227         col = layout.column()
228         col.prop(props, "bloom_threshold")
229         col.prop(props, "bloom_knee")
230         col.prop(props, "bloom_radius")
231         col.prop(props, "bloom_color")
232         col.prop(props, "bloom_intensity")
233         col.prop(props, "bloom_clamp")
234
235
236 class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
237     bl_label = "Volumetric"
238     bl_options = {'DEFAULT_CLOSED'}
239     COMPAT_ENGINES = {'BLENDER_EEVEE'}
240
241     @classmethod
242     def poll(cls, context):
243         return (context.engine in cls.COMPAT_ENGINES)
244
245     def draw_header(self, context):
246         scene = context.scene
247         props = scene.eevee
248         self.layout.prop(props, "use_volumetric", text="")
249
250     def draw(self, context):
251         layout = self.layout
252         layout.use_property_split = True
253
254         scene = context.scene
255         props = scene.eevee
256
257         layout.active = props.use_volumetric
258
259         col = layout.column(align=True)
260         col.prop(props, "volumetric_start")
261         col.prop(props, "volumetric_end")
262
263         col = layout.column()
264         col.prop(props, "volumetric_tile_size")
265         col.prop(props, "volumetric_samples")
266         col.prop(props, "volumetric_sample_distribution", text="Distribution")
267
268
269 class RENDER_PT_eevee_volumetric_lighting(RenderButtonsPanel, Panel):
270     bl_label = "Volumetric Lighting"
271     bl_parent_id = "RENDER_PT_eevee_volumetric"
272     COMPAT_ENGINES = {'BLENDER_EEVEE'}
273
274     def draw_header(self, context):
275         scene = context.scene
276         props = scene.eevee
277         self.layout.prop(props, "use_volumetric_lights", text="")
278
279     def draw(self, context):
280         layout = self.layout
281         layout.use_property_split = True
282
283         scene = context.scene
284         props = scene.eevee
285
286         layout.active = props.use_volumetric_lights
287         layout.prop(props, "volumetric_light_clamp", text="Light Clamping")
288
289
290 class RENDER_PT_eevee_volumetric_shadows(RenderButtonsPanel, Panel):
291     bl_label = "Volumetric Shadows"
292     bl_parent_id = "RENDER_PT_eevee_volumetric"
293     COMPAT_ENGINES = {'BLENDER_EEVEE'}
294
295     def draw_header(self, context):
296         scene = context.scene
297         props = scene.eevee
298         self.layout.prop(props, "use_volumetric_shadows", text="")
299
300     def draw(self, context):
301         layout = self.layout
302         layout.use_property_split = True
303
304         scene = context.scene
305         props = scene.eevee
306
307         layout.active = props.use_volumetric_shadows
308         layout.prop(props, "volumetric_shadow_samples", text="Shadow Samples")
309
310
311 class RENDER_PT_eevee_subsurface_scattering(RenderButtonsPanel, Panel):
312     bl_label = "Subsurface Scattering"
313     bl_options = {'DEFAULT_CLOSED'}
314     COMPAT_ENGINES = {'BLENDER_EEVEE'}
315
316     @classmethod
317     def poll(cls, context):
318         return (context.engine in cls.COMPAT_ENGINES)
319
320     def draw_header(self, context):
321         scene = context.scene
322         props = scene.eevee
323         self.layout.prop(props, "use_sss", text="")
324
325     def draw(self, context):
326         layout = self.layout
327         layout.use_property_split = True
328
329         scene = context.scene
330         props = scene.eevee
331
332         layout.active = props.use_sss
333
334         col = layout.column()
335         col.prop(props, "sss_samples")
336         col.prop(props, "sss_jitter_threshold")
337         col.prop(props, "use_sss_separate_albedo")
338
339
340 class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
341     bl_label = "Screen Space Reflections"
342     bl_options = {'DEFAULT_CLOSED'}
343     COMPAT_ENGINES = {'BLENDER_EEVEE'}
344
345     @classmethod
346     def poll(cls, context):
347         return (context.engine in cls.COMPAT_ENGINES)
348
349     def draw_header(self, context):
350         scene = context.scene
351         props = scene.eevee
352         self.layout.prop(props, "use_ssr", text="")
353
354     def draw(self, context):
355         layout = self.layout
356         layout.use_property_split = True
357
358         scene = context.scene
359         props = scene.eevee
360
361         col = layout.column()
362         col.active = props.use_ssr
363         col.prop(props, "use_ssr_refraction", text="Refraction")
364         col.prop(props, "use_ssr_halfres")
365         col.prop(props, "ssr_quality")
366         col.prop(props, "ssr_max_roughness")
367         col.prop(props, "ssr_thickness")
368         col.prop(props, "ssr_border_fade")
369         col.prop(props, "ssr_firefly_fac")
370
371
372 class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
373     bl_label = "Shadows"
374     bl_options = {'DEFAULT_CLOSED'}
375     COMPAT_ENGINES = {'BLENDER_EEVEE'}
376
377     @classmethod
378     def poll(cls, context):
379         return (context.engine in cls.COMPAT_ENGINES)
380
381     def draw(self, context):
382         layout = self.layout
383         layout.use_property_split = True
384
385         scene = context.scene
386         props = scene.eevee
387
388         col = layout.column()
389         col.prop(props, "shadow_method")
390         col.prop(props, "shadow_cube_size", text="Cube Size")
391         col.prop(props, "shadow_cascade_size", text="Cascade Size")
392         col.prop(props, "use_shadow_high_bitdepth")
393         col.prop(props, "use_soft_shadows")
394         col.prop(props, "light_threshold")
395
396
397 class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
398     bl_label = "Sampling"
399     COMPAT_ENGINES = {'BLENDER_EEVEE'}
400
401     @classmethod
402     def poll(cls, context):
403         return (context.engine in cls.COMPAT_ENGINES)
404
405     def draw(self, context):
406         layout = self.layout
407         layout.use_property_split = True
408         layout.use_property_decorate = False  # No animation.
409
410         scene = context.scene
411         props = scene.eevee
412
413         col = layout.column()
414         col.prop(props, "taa_samples")
415         col.prop(props, "taa_render_samples")
416         col.prop(props, "use_taa_reprojection")
417
418
419 class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
420     bl_label = "Indirect Lighting"
421     bl_options = {'DEFAULT_CLOSED'}
422     COMPAT_ENGINES = {'BLENDER_EEVEE'}
423
424     @classmethod
425     def poll(cls, context):
426         return (context.engine in cls.COMPAT_ENGINES)
427
428     def draw(self, context):
429         layout = self.layout
430         layout.use_property_split = True
431         layout.use_property_decorate = False  # No animation.
432
433         scene = context.scene
434         props = scene.eevee
435
436         col = layout.column()
437         col.operator("scene.light_cache_bake", text="Bake Indirect Lighting", icon='RENDER_STILL')
438         col.operator("scene.light_cache_bake", text="Bake Cubemap Only", icon='LIGHTPROBE_CUBEMAP').subset = 'CUBEMAPS'
439         col.operator("scene.light_cache_free", text="Free Lighting Cache")
440
441         cache_info = scene.eevee.gi_cache_info
442         if cache_info:
443             col.label(text=cache_info)
444
445         col.prop(props, "gi_auto_bake")
446
447         col.prop(props, "gi_diffuse_bounces")
448         col.prop(props, "gi_cubemap_resolution")
449         col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion")
450         col.prop(props, "gi_irradiance_smoothing")
451         col.prop(props, "gi_glossy_clamp")
452         col.prop(props, "gi_filter_quality")
453
454
455 class RENDER_PT_eevee_indirect_lighting_display(RenderButtonsPanel, Panel):
456     bl_label = "Display"
457     bl_parent_id = "RENDER_PT_eevee_indirect_lighting"
458     COMPAT_ENGINES = {'BLENDER_EEVEE'}
459
460     @classmethod
461     def poll(cls, context):
462         return (context.engine in cls.COMPAT_ENGINES)
463
464     def draw(self, context):
465         layout = self.layout
466         layout.use_property_split = True
467         layout.use_property_decorate = False  # No animation.
468
469         scene = context.scene
470         props = scene.eevee
471
472         row = layout.row(align=True)
473         row.prop(props, "gi_cubemap_display_size", text="Cubemap Size")
474         row.prop(props, "gi_show_cubemaps", text="", toggle=True)
475
476         row = layout.row(align=True)
477         row.prop(props, "gi_irradiance_display_size", text="Irradiance Size")
478         row.prop(props, "gi_show_irradiance", text="", toggle=True)
479
480
481 class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
482     bl_label = "Film"
483     bl_options = {'DEFAULT_CLOSED'}
484     COMPAT_ENGINES = {'BLENDER_EEVEE'}
485
486     @classmethod
487     def poll(cls, context):
488         return (context.engine in cls.COMPAT_ENGINES)
489
490     def draw(self, context):
491         layout = self.layout
492         layout.use_property_split = True
493
494         scene = context.scene
495         props = scene.eevee
496         rd = scene.render
497
498         split = layout.split()
499         split.prop(props, "use_overscan")
500         row = split.row()
501         row.active = props.use_overscan
502         row.prop(props, "overscan_size", text="")
503
504         col = layout.column()
505         col.prop(rd, "filter_size")
506         col.prop(rd, "alpha_mode", text="Alpha")
507
508
509 class RENDER_PT_eevee_hair(RenderButtonsPanel, Panel):
510     bl_label = "Hair"
511     bl_options = {'DEFAULT_CLOSED'}
512     COMPAT_ENGINES = {'BLENDER_EEVEE'}
513
514     @classmethod
515     def poll(cls, context):
516         return (context.engine in cls.COMPAT_ENGINES)
517
518     def draw(self, context):
519         layout = self.layout
520         scene = context.scene
521         rd = scene.render
522
523         layout.use_property_split = True
524
525         layout.prop(rd, "hair_type", expand=True)
526         layout.prop(rd, "hair_subdiv")
527
528
529 class RENDER_PT_opengl_film(RenderButtonsPanel, Panel):
530     bl_label = "Film"
531     bl_options = {'DEFAULT_CLOSED'}
532     COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
533
534     def draw(self, context):
535         layout = self.layout
536         layout.use_property_split = True
537         layout.use_property_decorate = False  # No animation.
538
539         rd = context.scene.render
540
541         layout.prop(rd, "use_antialiasing")
542
543         layout.prop(rd, "antialiasing_samples")
544         layout.prop(rd, "alpha_mode")
545
546
547 class RENDER_PT_opengl_lighting(RenderButtonsPanel, Panel):
548     bl_label = "Lighting"
549     COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
550
551     @classmethod
552     def poll(cls, context):
553         return (context.engine in cls.COMPAT_ENGINES)
554
555     def draw(self, context):
556         VIEW3D_PT_shading_lighting.draw(self, context)
557
558
559 class RENDER_PT_opengl_color(RenderButtonsPanel, Panel):
560     bl_label = "Color"
561     COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
562
563     @classmethod
564     def poll(cls, context):
565         return (context.engine in cls.COMPAT_ENGINES)
566
567     def draw(self, context):
568         VIEW3D_PT_shading_color._draw_color_type(self, context)
569
570
571 class RENDER_PT_opengl_options(RenderButtonsPanel, Panel):
572     bl_label = "Options"
573     COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
574
575     @classmethod
576     def poll(cls, context):
577         return (context.engine in cls.COMPAT_ENGINES)
578
579     def draw(self, context):
580         VIEW3D_PT_shading_options.draw(self, context)
581
582
583 class RENDER_PT_simplify(RenderButtonsPanel, Panel):
584     bl_label = "Simplify"
585     bl_options = {'DEFAULT_CLOSED'}
586     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
587
588     def draw_header(self, context):
589         rd = context.scene.render
590         self.layout.prop(rd, "use_simplify", text="")
591
592     def draw(self, context):
593         pass
594
595
596 class RENDER_PT_simplify_viewport(RenderButtonsPanel, Panel):
597     bl_label = "Viewport"
598     bl_parent_id = "RENDER_PT_simplify"
599     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
600
601     def draw(self, context):
602         layout = self.layout
603         layout.use_property_split = True
604
605         rd = context.scene.render
606
607         layout.active = rd.use_simplify
608
609         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
610
611         col = flow.column()
612         col.prop(rd, "simplify_subdivision", text="Max Subdivision")
613
614         col = flow.column()
615         col.prop(rd, "simplify_child_particles", text="Max Child Particles")
616
617
618 class RENDER_PT_simplify_render(RenderButtonsPanel, Panel):
619     bl_label = "Render"
620     bl_parent_id = "RENDER_PT_simplify"
621     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
622
623     def draw(self, context):
624         layout = self.layout
625         layout.use_property_split = True
626
627         rd = context.scene.render
628
629         layout.active = rd.use_simplify
630
631         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
632
633         col = flow.column()
634         col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
635
636         col = flow.column()
637         col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
638
639
640 class RENDER_PT_simplify_greasepencil(RenderButtonsPanel, Panel):
641     bl_label = "Grease Pencil"
642     bl_parent_id = "RENDER_PT_simplify"
643     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
644     bl_options = {'DEFAULT_CLOSED'}
645
646     def draw_header(self, context):
647         rd = context.scene.render
648         self.layout.prop(rd, "simplify_gpencil", text="")
649
650     def draw(self, context):
651         layout = self.layout
652         layout.use_property_split = True
653         layout.use_property_decorate = False
654
655         rd = context.scene.render
656
657         layout.active = rd.simplify_gpencil
658
659         col = layout.column()
660         col.prop(rd, "simplify_gpencil_onplay", text="Playback Only")
661         col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
662         col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
663         col.prop(rd, "simplify_gpencil_blend", text="Layers Blending")
664
665         col.prop(rd, "simplify_gpencil_view_fill")
666         sub = col.column()
667         sub.active = rd.simplify_gpencil_view_fill
668         sub.prop(rd, "simplify_gpencil_remove_lines", text="Lines")
669
670
671 classes = (
672     RENDER_PT_context,
673     RENDER_PT_eevee_sampling,
674     RENDER_PT_eevee_ambient_occlusion,
675     RENDER_PT_eevee_bloom,
676     RENDER_PT_eevee_depth_of_field,
677     RENDER_PT_eevee_subsurface_scattering,
678     RENDER_PT_eevee_screen_space_reflections,
679     RENDER_PT_eevee_motion_blur,
680     RENDER_PT_eevee_volumetric,
681     RENDER_PT_eevee_volumetric_lighting,
682     RENDER_PT_eevee_volumetric_shadows,
683     RENDER_PT_eevee_hair,
684     RENDER_PT_eevee_shadows,
685     RENDER_PT_eevee_indirect_lighting,
686     RENDER_PT_eevee_indirect_lighting_display,
687     RENDER_PT_eevee_film,
688     RENDER_PT_opengl_lighting,
689     RENDER_PT_opengl_color,
690     RENDER_PT_opengl_options,
691     RENDER_PT_opengl_film,
692     RENDER_PT_color_management,
693     RENDER_PT_color_management_curves,
694     RENDER_PT_simplify,
695     RENDER_PT_simplify_viewport,
696     RENDER_PT_simplify_render,
697     RENDER_PT_simplify_greasepencil,
698 )
699
700 if __name__ == "__main__":  # only for live edit.
701     from bpy.utils import register_class
702     for cls in classes:
703         register_class(cls)