Directional lights cascade shadows not working when using multiple render layers
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.15-rc.3
## Relevant system information
```
AdapterInfo { name: "Apple M2 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
```
## What you did
I've up to four viewports in my app, for each viewport I'm instantiating a ground, a directional light, a camera and 2x GLFT models. Each entity in the viewport has a render layer assigned. For GLTF models I [add render layers to all the scene meshes after instantiation following this hack](https://github.com/bevyengine/bevy/issues/12461#issuecomment-2439874485).
See the code: https://gist.github.com/doup/161a8269d78762bd16c2d3c1e5f5999a
## What went wrong
The shadows only appear in one of the viewports. Which viewport gets the shadows is random for each instantiation (is not changing every frame).

## Additional information
The same setup using point lights works fine:

I suppose `CascadeShadows` work only for one render layer?
Contributor guide
Research direction
Start with the linked gist and the CascadeShadows setup in Bevy 0.15-rc.3, reproducing the four-viewport configuration with separate render layers on the Metal adapter. Compare the directional-light shadow behavior with the working point-light setup; done means cascaded shadows appear correctly in every viewport rather than only one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100