You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quite a wordy title, but should be reproducible by:
Creating an entity with a SpriteBundle component, rendering a sprite
Attaching a PointLight2d to it (with a radius larger than the sprite)
Either moving the sprite off-camera, or the camera away from the sprite until the sprite is just outside the screen, which should cause the light not to be rendered.
As an example, I've moved the PointLight2d component in the dungeon example into the sprite entity:
This might be a non-issue as lights shouldn't be added to a Sprite'd component which I think is fine if that's the case. It did however make me delve a bit into why this happened and I'm pretty sure it's due to the ViewVisibility of the entity being set to false when the sprite is off-screen, which is then filtered out in the extraction step:
So I think that if a light doesn't have a sprite component, it also doesn't get its aabb computed in bevy's internal visibility computation step, which should mean that the light will always be rendered, even if it's far off screen. I might be wrong here though as I'm not certain if this library (or bevy) handles visibility in some other smart way.
I think that if my assumptions are correct, it would probably be good to figure out a way to filter out non-visible lights in the extraction step based on their radius and transform. If that is by creating a new Visibility component and then copying what bevy does (e.g set a ComputedLightVisibility to false initially, and then going through each light, checking its aabb against visible cameras and setting any visible lights to true), or by smartly hooking into bevy's existing visibility calculation system somehow. Maybe there is a possibility to add a aabb struct which bevy can use?
The text was updated successfully, but these errors were encountered:
Thanks for the write up! I haven't delved into this myself, but I'm fairly confident your analysis is correct.
I consider this something we should address. There are workarounds, as you've mentioned, but from a pure usability standpoint, this behaviour will likely catch many off guard.
Quite a wordy title, but should be reproducible by:
As an example, I've moved the PointLight2d component in the dungeon example into the sprite entity:
And then add the following as a separate system in order to slowly move the camera away from the light
This might be a non-issue as lights shouldn't be added to a Sprite'd component which I think is fine if that's the case. It did however make me delve a bit into why this happened and I'm pretty sure it's due to the ViewVisibility of the entity being set to false when the sprite is off-screen, which is then filtered out in the extraction step:
So I think that if a light doesn't have a sprite component, it also doesn't get its aabb computed in bevy's internal visibility computation step, which should mean that the light will always be rendered, even if it's far off screen. I might be wrong here though as I'm not certain if this library (or bevy) handles visibility in some other smart way.
I think that if my assumptions are correct, it would probably be good to figure out a way to filter out non-visible lights in the extraction step based on their radius and transform. If that is by creating a new Visibility component and then copying what bevy does (e.g set a
ComputedLightVisibility
to false initially, and then going through each light, checking its aabb against visible cameras and setting any visible lights to true), or by smartly hooking into bevy's existing visibility calculation system somehow. Maybe there is a possibility to add a aabb struct which bevy can use?The text was updated successfully, but these errors were encountered: