Skip to content

Commit b124d94

Browse files
kfc35tychedelia
authored andcommitted
fix(Rect Lights): rect_lights should be written out to GpuLights (bevyengine#24024)
# Objective - The `rect_light` half of bevyengine#23997 ## Solution - Move the statement that writes `gpu_lights` *after* the code block that sets rect_light information within `gpu_lights`. If only all the rendering bugs were this easy... ## Testing - `cargo run --example rect_light --features=“free_camera”` works again <img width="1271" height="744" alt="Screenshot 2026-04-28 at 11 08 32 PM" src="https://github.com/user-attachments/assets/84018902-1f70-4a8c-9e16-982d156fb8b4" />
1 parent ada1d75 commit b124d94

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

crates/bevy_pbr/src/render/light.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,21 +2078,6 @@ pub fn prepare_lights(
20782078
}
20792079
}
20802080

2081-
commands.entity(entity).insert((
2082-
ViewShadowBindings {
2083-
point_light_depth_texture: point_light_depth_texture.texture.clone(),
2084-
point_light_depth_texture_view: point_light_depth_texture_view.clone(),
2085-
directional_light_depth_texture: directional_light_depth_texture.texture.clone(),
2086-
directional_light_depth_texture_view: directional_light_depth_texture_view.clone(),
2087-
},
2088-
ViewLightEntities {
2089-
lights: view_lights,
2090-
},
2091-
ViewLightsUniformOffset {
2092-
offset: view_gpu_lights_writer.write(&gpu_lights),
2093-
},
2094-
));
2095-
20962081
// Make a link from the camera to all shadow cascades with occlusion
20972082
// culling enabled.
20982083
if !view_occlusion_culling_lights.is_empty() {
@@ -2125,6 +2110,21 @@ pub fn prepare_lights(
21252110
};
21262111
gpu_lights.n_rect_lights += 1;
21272112
}
2113+
2114+
commands.entity(entity).insert((
2115+
ViewShadowBindings {
2116+
point_light_depth_texture: point_light_depth_texture.texture.clone(),
2117+
point_light_depth_texture_view: point_light_depth_texture_view.clone(),
2118+
directional_light_depth_texture: directional_light_depth_texture.texture.clone(),
2119+
directional_light_depth_texture_view: directional_light_depth_texture_view.clone(),
2120+
},
2121+
ViewLightEntities {
2122+
lights: view_lights,
2123+
},
2124+
ViewLightsUniformOffset {
2125+
offset: view_gpu_lights_writer.write(&gpu_lights),
2126+
},
2127+
));
21282128
}
21292129

21302130
// Mark the existing shadow maps as unused this frame so that the first

0 commit comments

Comments
 (0)