bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.1k stars 3.56k forks source link

Shadows disabled when second camera is activated #14644

Open viridia opened 3 months ago

viridia commented 3 months ago

Bevy version

0.14.0

`AdapterInfo { name: "Apple M1 Pro", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }`

What went wrong

Two different scenarios, both of which exhibit the problem:

Scenario 1: Thumbnail generator

I have a main camera which is targeting the window; it's viewing a scene that has a directional light and various models. All of these items are on renderlayer 2.

I spawn a second camera to generate thumbnail images, which targets an Image. This camera also has a directional light and a model. These are all on renderlayer 1.

Whenever the second camera is active, the shadows on the first camera disappear. If I set the second camera is_active to false, then the first camera shadows re-appear. If I delete the directional light for the second camera, the shadows also re-appear.

Scenario 2: Portals

This scenario is similar to the first, except that there's only one render layer: camera 2 is the remote portal camera, but is viewing the same scene, with the same lights, as camera 1.

My portal system only spawns camera 2 when a portal is within the view frustum, and despawns it otherwise.

What I see is that when a portal comes on-screen, the shadows on the main camera disappear.

mrec commented 3 months ago

Sounds a bit like #14595 (though that was for WebGL)