fix(pcss ex / light despawning): add shadow maps and extracted lights to SyncComponent for lights#23790
Open
kfc35 wants to merge 1 commit intobevyengine:mainfrom
Open
fix(pcss ex / light despawning): add shadow maps and extracted lights to SyncComponent for lights#23790kfc35 wants to merge 1 commit intobevyengine:mainfrom
kfc35 wants to merge 1 commit intobevyengine:mainfrom
Conversation
8d5b5c4 to
77f4125
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Solution
I
git bisect’d the issue to bbcc1e6 which has to do withSyncComponents.I noticed that some manual extraction of lights happens in
bevy_pbr/src/render/light.rs. I figured that maybe more render components should be sync’d with the main world of component of lights. The behavior before that commit was that the render entity would be despawned and then recreated anew for syncing, so I think there’s something happening with lingering components on the render entity.Adding the
Extracted*Lightcomponents to each respective Light’s sync component only fixed it when toggling from DirectionalLight -> Another light. All other toggles were still broken.After adding the ShadowMap components, the toggles are pretty much 99% fixed. The shadow can rarely disappear if switching between Spot and Point light very quickly in succession, but I haven’t had it happen in a while.
I suspect this fix is suboptimal because the shadow disappears and then comes back in when switching for the first time to the new light source, which doesn’t seem happen on the last good commit (b22e71f)? Might just be me.
I’ll also say that the example reuses the same main world entity for all 3 lights and toggles between the three (it removes all three light components on toggle and then adds one back). Part of me wonders if the example should also be restructured because of that / if this example might be broken because of this structuring. At the very least, this fix is not complete once #23790 is merged, so #23802 should be considered.
Testing
cargo run --example pcss --features=“experimental_pbr_pcss”