9f24945573b054dc40a9f05b7de9345fcec6bdc9
[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 class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
152     bl_label = "Motion Blur"
153     bl_options = {'DEFAULT_CLOSED'}
154     COMPAT_ENGINES = {'BLENDER_EEVEE'}
155
156     @classmethod
157     def poll(cls, context):
158         return (context.engine in cls.COMPAT_ENGINES)
159
160     def draw_header(self, context):
161         scene = context.scene
162         props = scene.eevee
163         self.layout.prop(props, "use_motion_blur", text="")
164
165     def draw(self, context):
166         layout = self.layout
167         layout.use_property_split = True
168         scene = context.scene
169         props = scene.eevee
170
171         layout.active = props.use_motion_blur
172         col = layout.column()
173         col.prop(props, "motion_blur_samples")
174         col.prop(props, "motion_blur_shutter")
175
176
177 class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
178     bl_label = "Depth of Field"
179     bl_options = {'DEFAULT_CLOSED'}
180     COMPAT_ENGINES = {'BLENDER_EEVEE'}
181
182     @classmethod
183     def poll(cls, context):
184         return (context.engine in cls.COMPAT_ENGINES)
185
186     def draw_header(self, context):
187         scene = context.scene
188         props = scene.eevee
189         self.layout.prop(props, "use_dof", text="")
190
191     def draw(self, context):
192         layout = self.layout
193         layout.use_property_split = True
194         scene = context.scene
195         props = scene.eevee
196
197         layout.active = props.use_dof
198         col = layout.column()
199         col.prop(props, "bokeh_max_size")
200         # Not supported yet
201         # col.prop(props, "bokeh_threshold")
202
203
204 class RENDER_PT_eevee_bloom(RenderButtonsPanel, Panel):
205     bl_label = "Bloom"
206     bl_options = {'DEFAULT_CLOSED'}
207     COMPAT_ENGINES = {'BLENDER_EEVEE'}
208
209     @classmethod
210     def poll(cls, context):
211         return (context.engine in cls.COMPAT_ENGINES)
212
213     def draw_header(self, context):
214         scene = context.scene
215         props = scene.eevee
216         self.layout.prop(props, "use_bloom", text="")
217
218     def draw(self, context):
219         layout = self.layout
220         layout.use_property_split = True
221
222         scene = context.scene
223         props = scene.eevee
224
225         layout.active = props.use_bloom
226         col = layout.column()
227         col.prop(props, "bloom_threshold")
228         col.prop(props, "bloom_knee")
229         col.prop(props, "bloom_radius")
230         col.prop(props, "bloom_color")
231         col.prop(props, "bloom_intensity")
232         col.prop(props, "bloom_clamp")
233
234
235 class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):
236     bl_label = "Volumetric"
237     bl_options = {'DEFAULT_CLOSED'}
238     COMPAT_ENGINES = {'BLENDER_EEVEE'}
239
240     @classmethod
241     def poll(cls, context):
242         return (context.engine in cls.COMPAT_ENGINES)
243
244     def draw_header(self, context):
245         scene = context.scene
246         props = scene.eevee
247         self.layout.prop(props, "use_volumetric", text="")
248
249     def draw(self, context):
250         layout = self.layout
251         layout.use_property_split = True
252
253         scene = context.scene
254         props = scene.eevee
255
256         layout.active = props.use_volumetric
257
258         col = layout.column(align=True)
259         col.prop(props, "volumetric_start")
260         col.prop(props, "volumetric_end")
261
262         col = layout.column()
263         col.prop(props, "volumetric_tile_size")
264         col.prop(props, "volumetric_samples")
265         col.prop(props, "volumetric_sample_distribution", text="Distribution")
266
267
268 class RENDER_PT_eevee_volumetric_lighting(RenderButtonsPanel, Panel):
269     bl_label = "Volumetric Lighting"
270     bl_parent_id = "RENDER_PT_eevee_volumetric"
271     COMPAT_ENGINES = {'BLENDER_EEVEE'}
272
273     def draw_header(self, context):
274         scene = context.scene
275         props = scene.eevee
276         self.layout.prop(props, "use_volumetric_lights", text="")
277
278     def draw(self, context):
279         layout = self.layout
280         layout.use_property_split = True
281
282         scene = context.scene
283         props = scene.eevee
284
285         layout.active = props.use_volumetric_lights
286         layout.prop(props, "volumetric_light_clamp", text="Light Clamping")
287
288
289 class RENDER_PT_eevee_volumetric_shadows(RenderButtonsPanel, Panel):
290     bl_label = "Volumetric Shadows"
291     bl_parent_id = "RENDER_PT_eevee_volumetric"
292     COMPAT_ENGINES = {'BLENDER_EEVEE'}
293
294     def draw_header(self, context):
295         scene = context.scene
296         props = scene.eevee
297         self.layout.prop(props, "use_volumetric_shadows", text="")
298
299     def draw(self, context):
300         layout = self.layout
301         layout.use_property_split = True
302
303         scene = context.scene
304         props = scene.eevee
305
306         layout.active = props.use_volumetric_shadows
307         layout.prop(props, "volumetric_shadow_samples", text="Shadow Samples")
308
309
310 class RENDER_PT_eevee_subsurface_scattering(RenderButtonsPanel, Panel):
311     bl_label = "Subsurface Scattering"
312     bl_options = {'DEFAULT_CLOSED'}
313     COMPAT_ENGINES = {'BLENDER_EEVEE'}
314
315     @classmethod
316     def poll(cls, context):
317         return (context.engine in cls.COMPAT_ENGINES)
318
319     def draw_header(self, context):
320         scene = context.scene
321         props = scene.eevee
322         self.layout.prop(props, "use_sss", text="")
323
324     def draw(self, context):
325         layout = self.layout
326         layout.use_property_split = True
327
328         scene = context.scene
329         props = scene.eevee
330
331         layout.active = props.use_sss
332
333         col = layout.column()
334         col.prop(props, "sss_samples")
335         col.prop(props, "sss_jitter_threshold")
336         col.prop(props, "use_sss_separate_albedo")
337
338
339 class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
340     bl_label = "Screen Space Reflections"
341     bl_options = {'DEFAULT_CLOSED'}
342     COMPAT_ENGINES = {'BLENDER_EEVEE'}
343
344     @classmethod
345     def poll(cls, context):
346         return (context.engine in cls.COMPAT_ENGINES)
347
348     def draw_header(self, context):
349         scene = context.scene
350         props = scene.eevee
351         self.layout.prop(props, "use_ssr", text="")
352
353     def draw(self, context):
354         layout = self.layout
355         layout.use_property_split = True
356
357         scene = context.scene
358         props = scene.eevee
359
360         col = layout.column()
361         col.active = props.use_ssr
362         col.prop(props, "use_ssr_refraction", text="Refraction")
363         col.prop(props, "use_ssr_halfres")
364         col.prop(props, "ssr_quality")
365         col.prop(props, "ssr_max_roughness")
366         col.prop(props, "ssr_thickness")
367         col.prop(props, "ssr_border_fade")
368         col.prop(props, "ssr_firefly_fac")
369
370
371 class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
372     bl_label = "Shadows"
373     bl_options = {'DEFAULT_CLOSED'}
374     COMPAT_ENGINES = {'BLENDER_EEVEE'}
375
376     @classmethod
377     def poll(cls, context):
378         return (context.engine in cls.COMPAT_ENGINES)
379
380     def draw(self, context):
381         layout = self.layout
382         layout.use_property_split = True
383
384         scene = context.scene
385         props = scene.eevee
386
387         col = layout.column()
388         col.prop(props, "shadow_method")
389         col.prop(props, "shadow_cube_size", text="Cube Size")
390         col.prop(props, "shadow_cascade_size", text="Cascade Size")
391         col.prop(props, "use_shadow_high_bitdepth")
392         col.prop(props, "use_soft_shadows")
393         col.prop(props, "light_threshold")
394
395
396 class RENDER_PT_eevee_sampling(RenderButtonsPanel, Panel):
397     bl_label = "Sampling"
398     COMPAT_ENGINES = {'BLENDER_EEVEE'}
399
400     @classmethod
401     def poll(cls, context):
402         return (context.engine in cls.COMPAT_ENGINES)
403
404     def draw(self, context):
405         layout = self.layout
406         layout.use_property_split = True
407         layout.use_property_decorate = False  # No animation.
408
409         scene = context.scene
410         props = scene.eevee
411
412         col = layout.column()
413         col.prop(props, "taa_samples")
414         col.prop(props, "taa_render_samples")
415         col.prop(props, "use_taa_reprojection")
416
417
418 class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
419     bl_label = "Indirect Lighting"
420     bl_options = {'DEFAULT_CLOSED'}
421     COMPAT_ENGINES = {'BLENDER_EEVEE'}
422
423     @classmethod
424     def poll(cls, context):
425         return (context.engine in cls.COMPAT_ENGINES)
426
427     def draw(self, context):
428         layout = self.layout
429         layout.use_property_split = True
430         layout.use_property_decorate = False  # No animation.
431
432         scene = context.scene
433         props = scene.eevee
434
435         col = layout.column()
436         col.operator("scene.light_cache_bake", text="Bake Indirect Lighting", icon='RENDER_STILL')
437         col.operator("scene.light_cache_bake", text="Bake Cubemap Only", icon='LIGHTPROBE_CUBEMAP').subset = 'CUBEMAPS'
438         col.operator("scene.light_cache_free", text="Free Lighting Cache")
439
440         cache_info = scene.eevee.gi_cache_info
441         if cache_info:
442             col.label(text=cache_info)
443
444         col.prop(props, "gi_auto_bake")
445
446         col.prop(props, "gi_diffuse_bounces")
447         col.prop(props, "gi_cubemap_resolution")
448         col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion")
449         col.prop(props, "gi_irradiance_smoothing")
450         col.prop(props, "gi_glossy_clamp")
451         col.prop(props, "gi_filter_quality")
452
453
454 class RENDER_PT_eevee_indirect_lighting_display(RenderButtonsPanel, Panel):
455     bl_label = "Display"
456     bl_parent_id = "RENDER_PT_eevee_indirect_lighting"
457     COMPAT_ENGINES = {'BLENDER_EEVEE'}
458
459     @classmethod
460     def poll(cls, context):
461         return (context.engine in cls.COMPAT_ENGINES)
462
463     def draw(self, context):
464         layout = self.layout
465         layout.use_property_split = True
466         layout.use_property_decorate = False  # No animation.
467
468         scene = context.scene
469         props = scene.eevee
470
471         row = layout.row(align=True)
472         row.prop(props, "gi_cubemap_display_size", text="Cubemap Size")
473         row.prop(props, "gi_show_cubemaps", text="", toggle=True)
474
475         row = layout.row(align=True)
476         row.prop(props, "gi_irradiance_display_size", text="Irradiance Size")
477         row.prop(props, "gi_show_irradiance", text="", toggle=True)
478
479
480 class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
481     bl_label = "Film"
482     bl_options = {'DEFAULT_CLOSED'}
483     COMPAT_ENGINES = {'BLENDER_EEVEE'}
484
485     @classmethod
486     def poll(cls, context):
487         return (context.engine in cls.COMPAT_ENGINES)
488
489     def draw(self, context):
490         layout = self.layout
491         layout.use_property_split = True
492
493         scene = context.scene
494         props = scene.eevee
495         rd = scene.render
496
497         split = layout.split()
498         split.prop(props, "use_overscan")
499         row = split.row()
500         row.active = props.use_overscan
501         row.prop(props, "overscan_size", text="")
502
503         col = layout.column()
504         col.prop(rd, "filter_size")
505         col.prop(rd, "alpha_mode", text="Alpha")
506
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)