From 7b97bc48d82f5a5bd5370be6db39e79dc9266aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 20 Oct 2023 16:59:20 +0200 Subject: [PATCH] EEVEE-Next: Rework the material panel - Adds the missing new RNA definitions - Split settings panel into surface and volume - Expose displacement and volume nodetree panels - Rename `Cull Backfaces` to `Backface Culling` for consistency - Rename `use_backface_culling_probe` to `lightprobe_volume_single_sided` for accuracy and avoiding confusion as it is not a real backface culling. - Rename `Screen Space Refraction` to `Raytrace Refraction` for accuracy. Motivation is to make it closer to cycles now that EEVEE is compatible with more features. Pull Request: https://projects.blender.org/blender/blender/pulls/113971 --- scripts/startup/bl_ui/properties_material.py | 82 +++++++++++++++---- .../draw/engines/eevee_next/eevee_pipeline.cc | 2 +- source/blender/makesdna/DNA_material_types.h | 6 +- .../blender/makesrna/intern/rna_material.cc | 57 +++++++++++-- 4 files changed, 121 insertions(+), 26 deletions(-) diff --git a/scripts/startup/bl_ui/properties_material.py b/scripts/startup/bl_ui/properties_material.py index fd5d5208b60..14a56d1b4b9 100644 --- a/scripts/startup/bl_ui/properties_material.py +++ b/scripts/startup/bl_ui/properties_material.py @@ -183,7 +183,7 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel): bl_translation_context = i18n_contexts.id_id bl_context = "material" bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_EEVEE'} + COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'} @classmethod def poll(cls, context): @@ -201,6 +201,29 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel): panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Volume") +class EEVEE_MATERIAL_PT_displacement(MaterialButtonsPanel, Panel): + bl_label = "Displacement" + bl_translation_context = i18n_contexts.id_id + bl_context = "material" + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'} + + @classmethod + def poll(cls, context): + engine = context.engine + mat = context.material + return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) and not mat.grease_pencil + + def draw(self, context): + layout = self.layout + + layout.use_property_split = True + + mat = context.material + + panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Displacement") + + def draw_material_settings(self, context): layout = self.layout layout.use_property_split = True @@ -256,26 +279,54 @@ class EEVEE_NEXT_MATERIAL_PT_settings(MaterialButtonsPanel, Panel): mat = context.material - col = layout.column(heading="Cull Backfaces") + layout.prop(mat, "pass_index") + + +class EEVEE_NEXT_MATERIAL_PT_settings_surface(MaterialButtonsPanel, Panel): + bl_label = "Surface" + bl_context = "material" + bl_parent_id = "EEVEE_NEXT_MATERIAL_PT_settings" + COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + mat = context.material + + col = layout.column(heading="Backface Culling") col.prop(mat, "use_backface_culling", text="Camera") col.prop(mat, "use_backface_culling_shadow", text="Shadow") - col.prop(mat, "use_backface_culling_probe", text="Probe Capture") - layout.separator() + #TODO(fclem): Displacement option + #TODO(fclem): Transparent shadow option - layout.prop(mat, "blend_method") - layout.prop(mat, "shadow_method") + col = layout.column() + col.prop(mat, "surface_render_method", text="Render Method") + if mat.surface_render_method == 'BLENDED': + col.prop(mat, "show_transparent_back", text="Transparency Overlap") + elif mat.surface_render_method == 'DITHERED': + col.prop(mat, "use_screen_refraction", text="Raytraced Refraction") - row = layout.row() - row.active = ((mat.blend_method == 'CLIP') or (mat.shadow_method == 'CLIP')) - row.prop(mat, "alpha_threshold") + col = layout.column(heading="Light Probe Volume") + col.prop(mat, "lightprobe_volume_single_sided", text="Single Sided") - if mat.blend_method not in {'OPAQUE', 'CLIP', 'HASHED'}: - layout.prop(mat, "show_transparent_back") - layout.prop(mat, "use_screen_refraction") - layout.prop(mat, "volume_intersection_method") - layout.prop(mat, "pass_index") +class EEVEE_NEXT_MATERIAL_PT_settings_volume(MaterialButtonsPanel, Panel): + bl_label = "Volume" + bl_context = "material" + bl_parent_id = "EEVEE_NEXT_MATERIAL_PT_settings" + COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + mat = context.material + + layout.prop(mat, "volume_intersection_method", text="Intersection") class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel): @@ -345,8 +396,11 @@ classes = ( EEVEE_MATERIAL_PT_context_material, EEVEE_MATERIAL_PT_surface, EEVEE_MATERIAL_PT_volume, + EEVEE_MATERIAL_PT_displacement, EEVEE_MATERIAL_PT_settings, EEVEE_NEXT_MATERIAL_PT_settings, + EEVEE_NEXT_MATERIAL_PT_settings_surface, + EEVEE_NEXT_MATERIAL_PT_settings_volume, MATERIAL_PT_lineart, MATERIAL_PT_viewport, EEVEE_MATERIAL_PT_viewport_settings, diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc index cb8ea9e0ad4..3350e700042 100644 --- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc +++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc @@ -1301,7 +1301,7 @@ PassMain::Sub *CapturePipeline::surface_material_add(::Material *blender_mat, GP GPUPass *gpupass = GPU_material_get_pass(gpumat); sub_pass.shader_set(GPU_pass_shader_get(gpupass)); sub_pass.push_constant("is_double_sided", - !(blender_mat->blend_flag & MA_BL_CULL_BACKFACE_PROBE)); + !(blender_mat->blend_flag & MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED)); return &sub_pass; } diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index d07c1b980ba..57b3c5e0324 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -214,8 +214,8 @@ typedef struct Material { /* Transparency. */ float alpha_threshold; float refract_depth; - char blend_method; - char blend_shadow; + char blend_method; /* TODO(fclem): Deprecate once we remove legacy EEVEE. */ + char blend_shadow; /* TODO(fclem): Deprecate once we remove legacy EEVEE. */ char blend_flag; /* Volume. */ @@ -358,7 +358,7 @@ enum { MA_BL_SS_REFRACTION = (1 << 1), MA_BL_CULL_BACKFACE = (1 << 2), MA_BL_TRANSLUCENCY = (1 << 3), - MA_BL_CULL_BACKFACE_PROBE = (1 << 4), + MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED = (1 << 4), MA_BL_CULL_BACKFACE_SHADOW = (1 << 5), }; diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index 3dba8da17d4..a41401cabfc 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -793,10 +793,12 @@ void RNA_def_material(BlenderRNA *brna) 0, "Accurate", "Faces are considered as medium interface only when they have different consecutive " - "facing. Gives correct results as long as the max ray depth is not exceeded"}, + "facing. Gives correct results as long as the max ray depth is not exceeded. Have " + "significant memory overhead compared to the fast method"}, {0, nullptr, 0, nullptr, nullptr}, }; +# if 1 /* Delete this section once we remove old eevee. */ static EnumPropertyItem prop_eevee_blend_items[] = { {MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"}, {MA_BM_CLIP, @@ -832,6 +834,23 @@ void RNA_def_material(BlenderRNA *brna) "Use noise to dither the binary visibility and use filtering to reduce the noise"}, {0, nullptr, 0, nullptr, nullptr}, }; +# endif + + static EnumPropertyItem prop_eevee_surface_render_method_items[] = { + {MA_SURFACE_METHOD_DEFERRED, + "DITHERED", + 0, + "Dithered", + "Allows for grayscale hashed transparency, and compatible with render passes and " + "raytracing. Also known as deferred rendering"}, + {MA_SURFACE_METHOD_FORWARD, + "BLENDED", + 0, + "Blended", + "Allows for colored transparency, but incompatible with render passes and raytracing. Also " + "known as forward rendering"}, + {0, nullptr, 0, nullptr, nullptr}, + }; srna = RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text( @@ -840,6 +859,14 @@ void RNA_def_material(BlenderRNA *brna) "Material data-block to define the appearance of geometric objects for rendering"); RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA); + prop = RNA_def_property(srna, "surface_render_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_eevee_surface_render_method_items); + RNA_def_property_ui_text(prop, + "Surface Render Method", + "Controls the blending and the compatibility with certain features"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + +# if 1 /* Delete this section once we remove old eevee. */ /* Blending (only Eevee for now) */ prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_eevee_blend_items); @@ -859,7 +886,9 @@ void RNA_def_material(BlenderRNA *brna) "Clip Threshold", "A pixel is rendered only if its alpha value is above this threshold"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +# endif + /* TODO(fclem): Should be renamed to use_transparency_overlap. */ prop = RNA_def_property(srna, "show_transparent_back", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, nullptr, "blend_flag", MA_BL_HIDE_BACKFACE); RNA_def_property_ui_text(prop, @@ -876,21 +905,32 @@ void RNA_def_material(BlenderRNA *brna) prop = RNA_def_property(srna, "use_backface_culling_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE_SHADOW); - RNA_def_property_ui_text(prop, "Shadow Backface Culling", "Use back faces for casting shadows"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - - prop = RNA_def_property(srna, "use_backface_culling_probe", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE_PROBE); RNA_def_property_ui_text( - prop, "Probe Capture Backface Culling", "Use back faces for probe captures"); + prop, "Shadow Backface Culling", "Use back face culling when casting shadows"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + prop = RNA_def_property(srna, "lightprobe_volume_single_sided", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, nullptr, "blend_flag", MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED); + RNA_def_property_ui_text( + prop, + "Light Probe Volume Single Sided", + "Consider material single sided for light probe volume capture. " + "Additionnaly helps rejecting probes inside the object to avoid light leaks"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + + /* TODO(fclem): Should be renamed to use_raytraced_refraction. */ prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION); RNA_def_property_ui_text( - prop, "Screen Space Refraction", "Use raytraced screen space refractions"); + prop, + "Raytrace Refraction", + "Use raytracing to determine refracted color instead of using only light probes. " + "This prevents the surface from contributing to the lighting of surfaces not using this " + "setting"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +# if 1 /* Delete this section once we remove old eevee. */ prop = RNA_def_property(srna, "use_sss_translucency", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSLUCENCY); RNA_def_property_ui_text( @@ -905,6 +945,7 @@ void RNA_def_material(BlenderRNA *brna) "Approximate the thickness of the object to compute two refraction " "events (0 is disabled)"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); +# endif prop = RNA_def_property(srna, "volume_intersection_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_eevee_volume_isect_method_items);