Skip to content

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
kfc35:23769_pcss_fix
Open

fix(pcss ex / light despawning): add shadow maps and extracted lights to SyncComponent for lights#23790
kfc35 wants to merge 1 commit intobevyengine:mainfrom
kfc35:23769_pcss_fix

Conversation

@kfc35
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 commented Apr 13, 2026

Objective

Solution

I git bisect’d the issue to bbcc1e6 which has to do with SyncComponents.
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*Light components 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

  • You can toggle between the lights and the shadows stay mostly in tact except for the described scenario between spot and point: cargo run --example pcss --features=“experimental_pbr_pcss”

@kfc35 kfc35 added A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 13, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering Apr 13, 2026
@kfc35 kfc35 added S-Needs-Help The author needs help finishing this PR. C-Bug An unexpected or incorrect behavior and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 13, 2026
@kfc35 kfc35 changed the title mostly fix(pcss): add shadow maps and extracted lights to SyncComponent for lights mostly fix(pcss example): add shadow maps and extracted lights to SyncComponent for lights Apr 13, 2026
@kfc35 kfc35 force-pushed the 23769_pcss_fix branch 2 times, most recently from 8d5b5c4 to 77f4125 Compare April 14, 2026 04:41
@kfc35 kfc35 changed the title mostly fix(pcss example): add shadow maps and extracted lights to SyncComponent for lights fix(pcss example): add shadow maps and extracted lights to SyncComponent for lights Apr 14, 2026
@kfc35 kfc35 marked this pull request as ready for review April 14, 2026 17:43
@kfc35 kfc35 added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Needs-Help The author needs help finishing this PR. labels Apr 14, 2026
@kfc35 kfc35 changed the title fix(pcss example): add shadow maps and extracted lights to SyncComponent for lights fix(pcss ex / light despawning): add shadow maps and extracted lights to SyncComponent for lights Apr 14, 2026
@kfc35 kfc35 added D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes and removed D-Straightforward Simple bug fixes and API improvements, docs, test and examples labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

Pcss example is broken

1 participant