diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 9b2bd0880c..683ce0cbb2 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -590,7 +590,7 @@ fn calculate_cascade( // It is critical for `world_to_cascade` to be stable. So rather than forming `cascade_to_world` // and inverting it, which risks instability due to numerical precision, we directly form - // `world_to_cascde` as the reference material suggests. + // `world_to_cascade` as the reference material suggests. let light_to_world_transpose = light_to_world.transpose(); let world_to_cascade = Mat4::from_cols( light_to_world_transpose.x_axis, diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 46616e4765..f6b6464535 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -6,7 +6,7 @@ use bevy_render::{ camera::Camera, color::Color, mesh::Mesh, - primitives::{CascadesFrusta, CubemapFrusta, Frustum}, + primitives::{CascadesFrusta, CubemapFrusta, Frustum, HalfSpace}, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext}, render_phase::*, @@ -1145,7 +1145,7 @@ pub fn prepare_lights( .unwrap() .iter() .take(MAX_CASCADES_PER_LIGHT); - for (cascade_index, ((cascade, frusta), bound)) in cascades + for (cascade_index, ((cascade, frustum), bound)) in cascades .zip(frusta) .zip(&light.cascade_shadow_config.bounds) .enumerate() @@ -1172,6 +1172,11 @@ pub fn prepare_lights( }); directional_depth_texture_array_index += 1; + let mut frustum = *frustum; + // Push the near clip plane out to infinity for directional lights + frustum.half_spaces[4] = + HalfSpace::new(frustum.half_spaces[4].normal().extend(f32::INFINITY)); + let view_light_entity = commands .spawn(( ShadowView { @@ -1192,7 +1197,7 @@ pub fn prepare_lights( hdr: false, color_grading: Default::default(), }, - *frusta, + frustum, RenderPhase::::default(), LightEntity::Directional { light_entity,