forked from bartvdbraak/blender
Eevee: Transparency: Add transparent Shadow method UI.
This commit is contained in:
parent
ec9330d206
commit
c0f2cbab4e
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user