Skip to content

Commit d55b20c

Browse files
committed
Rendering: Skip shadow rendering for inactive particles
1 parent 1c8cc9e commit d55b20c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

servers/rendering/renderer_scene_cull.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,8 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
24202420

24212421
for (int j = 0; j < (int)instance_shadow_cull_result.size(); j++) {
24222422
Instance *instance = instance_shadow_cull_result[j];
2423-
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base))) {
2423+
const bool is_inactive_particle = (instance->base_type == RSE::INSTANCE_PARTICLES) && RSG::particles_storage->particles_is_inactive(instance->base);
2424+
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base)) || is_inactive_particle) {
24242425
continue;
24252426
} else {
24262427
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
@@ -2503,7 +2504,8 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
25032504

25042505
for (int j = 0; j < (int)instance_shadow_cull_result.size(); j++) {
25052506
Instance *instance = instance_shadow_cull_result[j];
2506-
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base))) {
2507+
const bool is_inactive_particle = (instance->base_type == RSE::INSTANCE_PARTICLES) && RSG::particles_storage->particles_is_inactive(instance->base);
2508+
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base)) || is_inactive_particle) {
25072509
continue;
25082510
} else {
25092511
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
@@ -2571,7 +2573,8 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
25712573

25722574
for (int j = 0; j < (int)instance_shadow_cull_result.size(); j++) {
25732575
Instance *instance = instance_shadow_cull_result[j];
2574-
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base))) {
2576+
const bool is_inactive_particle = (instance->base_type == RSE::INSTANCE_PARTICLES) && RSG::particles_storage->particles_is_inactive(instance->base);
2577+
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base)) || is_inactive_particle) {
25752578
continue;
25762579
} else {
25772580
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
@@ -2637,7 +2640,8 @@ bool RendererSceneCull::_light_instance_update_shadow(Instance *p_instance, cons
26372640

26382641
for (int j = 0; j < (int)instance_shadow_cull_result.size(); j++) {
26392642
Instance *instance = instance_shadow_cull_result[j];
2640-
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base))) {
2643+
const bool is_inactive_particle = (instance->base_type == RSE::INSTANCE_PARTICLES) && RSG::particles_storage->particles_is_inactive(instance->base);
2644+
if (!instance->visible || !((1 << instance->base_type) & RSE::INSTANCE_GEOMETRY_MASK) || !static_cast<InstanceGeometryData *>(instance->base_data)->can_cast_shadows || !(p_visible_layers & instance->layer_mask & RSG::light_storage->light_get_shadow_caster_mask(p_instance->base)) || is_inactive_particle) {
26412645
continue;
26422646
} else {
26432647
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
@@ -3241,7 +3245,8 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul
32413245
if (IN_FRUSTUM(cull_data.cull->shadows[j].cascades[k].frustum) && VIS_CHECK) {
32423246
uint32_t base_type = idata.flags & InstanceData::FLAG_BASE_TYPE_MASK;
32433247

3244-
if (((1 << base_type) & RSE::INSTANCE_GEOMETRY_MASK) && idata.flags & InstanceData::FLAG_CAST_SHADOWS && (LAYER_CHECK & cull_data.cull->shadows[j].caster_mask)) {
3248+
const bool is_inactive_particle = (base_type == RSE::INSTANCE_PARTICLES) && RSG::particles_storage->particles_is_inactive(idata.base_rid);
3249+
if (((1 << base_type) & RSE::INSTANCE_GEOMETRY_MASK) && idata.flags & InstanceData::FLAG_CAST_SHADOWS && (LAYER_CHECK & cull_data.cull->shadows[j].caster_mask) && !is_inactive_particle) {
32453250
cull_result.directional_shadows[j].cascade_geometry_instances[k].push_back(idata.instance_geometry);
32463251
mesh_visible = true;
32473252
}

0 commit comments

Comments
 (0)