bevyengine / bevyengine/bevy

SpotLight + Camera on the same entity causes incorrect culling

Open
#19,593 4 comments 0 reactions 0 assignees View on GitHub
A-Rendering C-Bug C-Docs S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

v0.16.1
(Cargo.toml stated `>=0.16`, noticeable in both 0.16.0 and 0.16.1)

## Relevant system information

Adapter Info:

```ignore
`AdapterInfo { name: "NVIDIA GeForce RTX 4060 Laptop GPU", vendor: 4318, device: 10464, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "561.09", backend: Vulkan }`
```

## What you did

I attempted to try to add a `SpotLight` component (with `shadows_enabled: true`) to an entity that had a `Camera3d` component after the Camera was initially spawned. I added the component to the same entity as the camera, not to a child.

## What went wrong

I was expecting everything (but the spot light) to remain the same after adding the component.

What actually happened was the objects would disappear when camera rotated correctly, the amount of error where objects would disappear changing when closer or further.

## Additional information

Code: https://github.com/NickTheFox99/bill-boards-bevy/tree/985506e56053e864438870a3440341d8ce8aca96
Relevant Files (in src/): `lighting.rs`, `player.rs`, `cube.rs`

Correct / Expected behaviour
![Image](https://github.com/user-attachments/assets/ab52d757-76ad-4b87-af39-a9fee45874c1)

Unexpected / Observed behaviour
![Image](https://github.com/user-attachments/assets/8e5f77d5-f3ed-4b2e-9334-6bd1907237ca)

I'm thinking that somehow the SpotLight may be triggering the Camera culling more actively when placed on the Camera, but I don't know how much of the components work under the hood and I may be wrong.

To work around this, I've added a child entity to the Camera and added the SpotLight to that. I've also noticed that **setting the shadows_enabled field on the SpotLight to false fixes the issue.**

I've looked, and do not think there are any similar issues noticed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.