Fix: Support RenderLayers filtering for Lights (Adoption of #23265)#23925
Fix: Support RenderLayers filtering for Lights (Adoption of #23265)#23925kfc35 wants to merge 16 commits intobevyengine:mainfrom
Conversation
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
1 similar comment
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
RE PixelEagle: it was an expected change and c71c870 changes it back to normal. |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
Looks great, thanks @kfc35 for taking this on |
tychedelia
left a comment
There was a problem hiding this comment.
I'm not sure we should land this without also landing per-camera shadow maps as it may be confusing to users trying to make use of this feature.
| pub local_from_world_transpose_b: f32, | ||
| pub flags: u32, | ||
| /// Packed render layer mask used for per-mesh light filtering in shaders. | ||
| pub render_layers: u32, |
There was a problem hiding this comment.
Am confused why we don't need padding here
| /// If the mesh has no morph targets, this is `u32::MAX`. | ||
| pub morph_descriptor_index: u32, | ||
| /// Padding to preserve 16-byte alignment for POD casts. | ||
| pub pad: [u32; 3], |
There was a problem hiding this comment.
these can usually be gated with #[cfg(feature = "webgl2")] and SIXTEEN_BYTE_ALIGNMENT in teh shader.
Objective
Solution
Copied and Pasted from original PR:
With this implementation, per-mesh/per-light filtering supports layers 0..=25 (26 layers total).
Additional Note from Me: Updating to main was mostly painless. All the conflicts were in
crates/bevy_pbr/src/render/light.rs, and I resolved to the best of my ability and understanding since mucking around in that same file for another rendering issue.I’m not as well versed in the rendering side of things, so if you have a comment, you might have to explain it like I’m five. Hopefully there isn’t much to fix up… but if there is, lean towards being very specific for my sake please 🙏
Testing
from original author: Tested and confirmed working with:
cargo run --example light_render_layersfrom me: I double checked the example and it works the same as it did before I merged main and resolved conflicts.
Showcase
Video of `light_render_layers ` example
Screen.Recording.2026-04-23.at.5.27.27.PM.mov