From d8102a0a04e8e5484f6eaffd491b458d0ecb3894 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Thu, 20 Apr 2023 03:43:24 +0200 Subject: [PATCH] bevy_pbr: Do not cull meshes without Aabbs from cascades (#8444) # Objective - Mesh entities should cast shadows when not having Aabbs and having NoFrustumCulling - Fixes #8442 ## Solution - Mesh entities with NoFrustumCulling get no automatic Aabbs added - Point and spot lights do not cull mesh entities for their shadow mapping if they do not have an Aabb, but directional lights do - Make directional lights not cull mesh entities from cascades if the do not have Aabbs. So no Aabb as a consequence of a NoFrustumCulling component will mean that those mesh entities are not culled and so are visible to the light. --- ## Changelog - Fixed: Mesh entities with NoFrustumCulling will cast shadows for directional light shadow maps --- crates/bevy_pbr/src/light.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 8922a42e81..4e73b7b24c 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -2029,6 +2029,18 @@ pub fn check_light_mesh_visibility( frustum_visible_entities.entities.push(entity); } } + } else { + computed_visibility.set_visible_in_view(); + for view in frusta.frusta.keys() { + let view_visible_entities = visible_entities + .entities + .get_mut(view) + .expect("Per-view visible entities should have been inserted already"); + + for frustum_visible_entities in view_visible_entities { + frustum_visible_entities.entities.push(entity); + } + } } }