Skip to content

Commit

Permalink
bevy_pbr: Limit directional light shadow map texture to max texture size
Browse files Browse the repository at this point in the history
  • Loading branch information
superdump committed Jan 4, 2022
1 parent aeb1565 commit 549cc35
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use bevy_render::{
camera::{Camera, CameraProjection},
color::Color,
mesh::Mesh,
options::WgpuOptions,
render_asset::RenderAssets,
render_graph::{Node, NodeRunError, RenderGraphContext, SlotInfo, SlotType},
render_phase::{
Expand Down Expand Up @@ -576,6 +577,7 @@ pub fn prepare_lights(
directional_light_shadow_map: Res<ExtractedDirectionalLightShadowMap>,
point_lights: Query<(Entity, &ExtractedPointLight)>,
directional_lights: Query<(Entity, &ExtractedDirectionalLight)>,
wgpu_options: Res<WgpuOptions>,
) {
light_meta.view_gpu_lights.clear();

Expand Down Expand Up @@ -664,8 +666,10 @@ pub fn prepare_lights(
&render_device,
TextureDescriptor {
size: Extent3d {
width: directional_light_shadow_map.size as u32,
height: directional_light_shadow_map.size as u32,
width: (directional_light_shadow_map.size as u32)
.min(wgpu_options.limits.max_texture_dimension_2d),
height: (directional_light_shadow_map.size as u32)
.min(wgpu_options.limits.max_texture_dimension_2d),
depth_or_array_layers: DIRECTIONAL_SHADOW_LAYERS,
},
mip_level_count: 1,
Expand Down

0 comments on commit 549cc35

Please sign in to comment.