Fix: EEVEE-Next: Object::visibility_flag in material_sync
Take `OB_HIDE_SHADOW` into account. (fix #115488) Include the relevant visibility flags into `MaterialKey`. Pull Request: https://projects.blender.org/blender/blender/pulls/115575
This commit is contained in:
@@ -236,7 +236,8 @@ Material &MaterialModule::material_sync(Object *ob,
|
||||
bool has_motion)
|
||||
{
|
||||
if (geometry_type == MAT_GEOM_VOLUME) {
|
||||
MaterialKey material_key(blender_mat, geometry_type, MAT_PIPE_VOLUME_MATERIAL);
|
||||
MaterialKey material_key(
|
||||
blender_mat, geometry_type, MAT_PIPE_VOLUME_MATERIAL, ob->visibility_flag);
|
||||
Material &mat = material_map_.lookup_or_add_cb(material_key, [&]() {
|
||||
Material mat = {};
|
||||
mat.volume_occupancy = material_pass_get(
|
||||
@@ -274,7 +275,7 @@ Material &MaterialModule::material_sync(Object *ob,
|
||||
prepass_pipe = has_motion ? MAT_PIPE_PREPASS_DEFERRED_VELOCITY : MAT_PIPE_PREPASS_DEFERRED;
|
||||
}
|
||||
|
||||
MaterialKey material_key(blender_mat, geometry_type, surface_pipe);
|
||||
MaterialKey material_key(blender_mat, geometry_type, surface_pipe, ob->visibility_flag);
|
||||
|
||||
Material &mat = material_map_.lookup_or_add_cb(material_key, [&]() {
|
||||
Material mat;
|
||||
@@ -337,9 +338,12 @@ Material &MaterialModule::material_sync(Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
if (true /* TODO: Ray visibility. */) {
|
||||
if (!(ob->visibility_flag & OB_HIDE_SHADOW)) {
|
||||
mat.shadow = material_pass_get(ob, blender_mat, MAT_PIPE_SHADOW, geometry_type);
|
||||
}
|
||||
else {
|
||||
mat.shadow = MaterialPass();
|
||||
}
|
||||
|
||||
mat.is_alpha_blend_transparent = use_forward_pipeline &&
|
||||
GPU_material_flag_get(mat.shading.gpumat,
|
||||
|
||||
@@ -170,10 +170,17 @@ struct MaterialKey {
|
||||
::Material *mat;
|
||||
uint64_t options;
|
||||
|
||||
MaterialKey(::Material *mat_, eMaterialGeometry geometry, eMaterialPipeline pipeline) : mat(mat_)
|
||||
MaterialKey(::Material *mat_,
|
||||
eMaterialGeometry geometry,
|
||||
eMaterialPipeline pipeline,
|
||||
short visibility_flags)
|
||||
: mat(mat_)
|
||||
{
|
||||
options = shader_uuid_from_material_type(
|
||||
pipeline, geometry, to_displacement_type(mat_->displacement_method), mat_->blend_flag);
|
||||
options = (options << 1) | (visibility_flags & OB_HIDE_SHADOW ? 0 : 1);
|
||||
options = (options << 1) | (visibility_flags & OB_HIDE_PROBE_CUBEMAP ? 0 : 1);
|
||||
options = (options << 1) | (visibility_flags & OB_HIDE_PROBE_PLANAR ? 0 : 1);
|
||||
}
|
||||
|
||||
uint64_t hash() const
|
||||
|
||||
Reference in New Issue
Block a user