Skip to content

Commit 50d38f2

Browse files
authored
Fix point light count limit (bevyengine#16062)
# Objective - I made a mistake in bevyengine#15902, specifically [this diff](bevyengine@e2faedb) -- the `point_light_count` variable is used for all point lights, not just shadow mapped ones, so I cannot add `.min(max_texture_cubes)` there. (Despite `spot_light_count` having `.min(..)`) It may have broken code like this (where `index` is index of `point_light` vec): https://github.com/bevyengine/bevy/blob/9930df83ed42008f7eb2c02cc7350040f0250c2e/crates/bevy_pbr/src/render/light.rs#L848-L850 and also causes panic here: https://github.com/bevyengine/bevy/blob/9930df83ed42008f7eb2c02cc7350040f0250c2e/crates/bevy_pbr/src/render/light.rs#L1173-L1174 ## Solution - Adds `.min(max_texture_cubes)` directly to the loop where texture views for point lights are created. ## Testing - `lighting` example (with the directional light removed; original example doesn't crash as only 1 directional-or-spot light in total is shadow-mapped on webgl) no longer crashes on webgl
1 parent 2223f6e commit 50d38f2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

crates/bevy_pbr/src/render/light.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,7 @@ pub fn prepare_lights(
749749
let point_light_count = point_lights
750750
.iter()
751751
.filter(|light| light.1.spot_light_angles.is_none())
752-
.count()
753-
.min(max_texture_cubes);
752+
.count();
754753

755754
let point_light_volumetric_enabled_count = point_lights
756755
.iter()
@@ -1060,7 +1059,7 @@ pub fn prepare_lights(
10601059
for &(light_entity, light, (point_light_frusta, _)) in point_lights
10611060
.iter()
10621061
// Lights are sorted, shadow enabled lights are first
1063-
.take(point_light_count)
1062+
.take(point_light_count.min(max_texture_cubes))
10641063
{
10651064
let Ok(mut light_view_entities) = light_view_entities.get_mut(light_entity) else {
10661065
continue;

0 commit comments

Comments
 (0)