diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material.py | 12 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_materials.c | 28 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 20 |
4 files changed, 56 insertions, 15 deletions
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 88fc2a42734..e7e92000723 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -1172,12 +1172,18 @@ class EEVEE_MATERIAL_PT_options(MaterialButtonsPanel, Panel): layout.prop(mat, "blend_method") - if mat.blend_method not in {"CLIP", "HASHED"}: - layout.prop(mat, "blend_hide_backside") + if mat.blend_method != "OPAQUE": + layout.prop(mat, "transparent_shadow_method") - if mat.blend_method == "CLIP": + row = layout.row() + row.active = ((mat.blend_method == "CLIP") or (mat.transparent_shadow_method == "CLIP")) layout.prop(mat, "alpha_threshold") + if mat.blend_method not in {"OPAQUE", "CLIP", "HASHED"}: + layout.prop(mat, "transparent_hide_backside") + + + classes = ( MATERIAL_MT_sss_presets, MATERIAL_MT_specials, diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index ab56b908416..b635b128520 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -997,15 +997,27 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl ADD_SHGROUP_CALL_SAFE(shgrp_depth_clip_array[i], ob, mat_geom[i]); /* Shadow Pass */ - if (ma->blend_method == MA_BM_SOLID) - EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); - else if (ma->blend_method == MA_BM_HASHED) { - struct GPUMaterial *gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true); - EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob->obmat, NULL); + if (ma->blend_method != MA_BM_SOLID) { + struct GPUMaterial *gpumat; + switch (ma->blend_shadow) { + case MA_BS_SOLID: + EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); + break; + case MA_BS_CLIP: + gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true); + EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob->obmat, &ma->alpha_threshold); + break; + case MA_BS_HASHED: + gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true); + EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob->obmat, NULL); + break; + case MA_BS_NONE: + default: + break; + } } - else if (ma->blend_method == MA_BM_CLIP) { - struct GPUMaterial *gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true); - EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob->obmat, &ma->alpha_threshold); + else { + EEVEE_lights_cache_shcaster_add(sldata, psl, mat_geom[i], ob->obmat); } } } diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 4af8ec70b8d..41ad12e63f2 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -214,8 +214,9 @@ typedef struct Material { /* Transparency */ float alpha_threshold; char blend_method; + char blend_shadow; char blend_flag; - char pad6[2]; + char pad6; /* image to use for image/uv space, also bake target * (not to be used shading/rendering pipeline, this is editor featyure only!). */ @@ -512,5 +513,13 @@ enum { MA_BL_HIDE_BACKSIDE = (1 << 0), }; +/* blend_shadow */ +enum { + MA_BS_NONE = 0, + MA_BS_SOLID, + MA_BS_CLIP, + MA_BS_HASHED, +}; + #endif diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 1d9302f5d37..d01ce407815 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1815,6 +1815,14 @@ void RNA_def_material(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem prop_eevee_blend_shadow_items[] = { + {MA_BS_NONE, "NONE", 0, "None", "Material will cast no shadow"}, + {MA_BS_SOLID, "OPAQUE", 0, "Opaque", "Material will cast shadows without transparency"}, + {MA_BS_CLIP, "CLIP", 0, "Clip", "Use the alpha threshold to clip the visibility (binary visibility)"}, + {MA_BS_HASHED, "HASHED", 0, "Hashed", "Use noise to dither the binary visibility and use filtering to reduce the noise"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material data-block to define the appearance of geometric objects for rendering"); @@ -1844,16 +1852,22 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + prop = RNA_def_property(srna, "transparent_shadow_method", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "blend_shadow"); + RNA_def_property_enum_items(prop, prop_eevee_blend_shadow_items); + RNA_def_property_ui_text(prop, "Transparent Shadow", "Shadow method for transparent material"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Clip Threshold", "A pixel is rendered only if its alpha value is above this threshold"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "blend_hide_backside", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "transparent_hide_backside", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "blend_flag", MA_BL_HIDE_BACKSIDE); RNA_def_property_ui_text(prop, "Hide Backside" , "Limit transparency to a single layer " "(avoids transparency sorting problems)"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); /* For Preview Render */ prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE); |