bevyengine / bevyengine/bevy

Directional lights cascade shadows not working when using multiple render layers

Open
#16,658 1 comment 1 reaction 0 assignees View on GitHub
A-Rendering C-Bug D-Modest S-Ready-For-Implementation
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).

![Image](https://github.com/user-attachments/assets/9f94c7e5-5cfe-4e05-b172-263c30513274)

## Additional information

The same setup using point lights works fine:

![Image](https://github.com/user-attachments/assets/3bf02fbb-de65-443d-94cb-9e01f73ac71f)

I suppose `CascadeShadows` work only for one render layer?

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.