Fix: EEVEE: Avoid assert from empty volume object material
Also avoid drawing them at all if the material has no volume shader.
This commit is contained in:
parent
1e6161759e
commit
4d2fcc5716
@ -1018,7 +1018,7 @@ PassMain::Sub *VolumeLayer::occupancy_add(const Object *ob,
|
||||
const ::Material *blender_mat,
|
||||
GPUMaterial *gpumat)
|
||||
{
|
||||
BLI_assert_msg(GPU_material_has_volume_output(gpumat) == true,
|
||||
BLI_assert_msg((ob->type == OB_VOLUME) || GPU_material_has_volume_output(gpumat),
|
||||
"Only volume material should be added here");
|
||||
bool use_fast_occupancy = (ob->type == OB_VOLUME) ||
|
||||
(blender_mat->volume_intersection_method == MA_VOLUME_ISECT_FAST);
|
||||
@ -1031,12 +1031,14 @@ PassMain::Sub *VolumeLayer::occupancy_add(const Object *ob,
|
||||
return pass;
|
||||
}
|
||||
|
||||
PassMain::Sub *VolumeLayer::material_add(const Object * /*ob*/,
|
||||
PassMain::Sub *VolumeLayer::material_add(const Object *ob,
|
||||
const ::Material * /*blender_mat*/,
|
||||
GPUMaterial *gpumat)
|
||||
{
|
||||
BLI_assert_msg(GPU_material_has_volume_output(gpumat) == true,
|
||||
BLI_assert_msg((ob->type == OB_VOLUME) || GPU_material_has_volume_output(gpumat),
|
||||
"Only volume material should be added here");
|
||||
UNUSED_VARS_NDEBUG(ob);
|
||||
|
||||
PassMain::Sub *pass = &material_ps_->sub(GPU_material_get_name(gpumat));
|
||||
pass->material_set(*inst_.manager, gpumat);
|
||||
if (GPU_material_flag_get(gpumat, GPU_MATFLAG_VOLUME_SCATTER)) {
|
||||
|
@ -367,8 +367,9 @@ void SyncModule::sync_volume(Object *ob,
|
||||
Material &material = inst_.materials.material_get(
|
||||
ob, has_motion, material_slot - 1, MAT_GEOM_VOLUME);
|
||||
|
||||
/* Use bounding box tag empty spaces. */
|
||||
gpu::Batch *geom = DRW_cache_cube_get();
|
||||
if (!GPU_material_has_volume_output(material.volume_material.gpumat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto drawcall_add = [&](MaterialPass &matpass, gpu::Batch *geom, ResourceHandle res_handle) {
|
||||
if (matpass.sub_pass == nullptr) {
|
||||
@ -381,11 +382,13 @@ void SyncModule::sync_volume(Object *ob,
|
||||
}
|
||||
};
|
||||
|
||||
inst_.manager->extract_object_attributes(res_handle, ob_ref, material.volume_material.gpumat);
|
||||
|
||||
/* Use bounding box tag empty spaces. */
|
||||
gpu::Batch *geom = DRW_cache_cube_get();
|
||||
drawcall_add(material.volume_occupancy, geom, res_handle);
|
||||
drawcall_add(material.volume_material, geom, res_handle);
|
||||
|
||||
inst_.manager->extract_object_attributes(res_handle, ob_ref, material.volume_material.gpumat);
|
||||
|
||||
inst_.volume.object_sync(ob_handle);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user