Skip to content

fix(light despawn / pcss example): add extracted lights and shadow related components to SyncComponent for lights#23790

Merged
alice-i-cecile merged 4 commits intobevyengine:mainfrom
kfc35:23769_pcss_fix
Apr 29, 2026
Merged

fix(light despawn / pcss example): add extracted lights and shadow related components to SyncComponent for lights#23790
alice-i-cecile merged 4 commits 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. The problem was that not all the relevant components were being despawned when toggling an entity between different Light components within the example. Expanding SyncComponents for each light ensures that the lights clean up properly between toggling.

I also had to review #23713 and I connected the dots that de-spawning the light should also despawn the light view entity. Duh!

Testing

  • cargo run --example pcss --features=“experimental_pbr_pcss”: toggling works!

@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
@kfc35 kfc35 changed the title fix(pcss ex / light despawning): add shadow maps and extracted lights to SyncComponent for lights fix(light despawning): add shadow maps and extracted lights to SyncComponent for lights Apr 16, 2026
@kfc35 kfc35 force-pushed the 23769_pcss_fix branch 2 times, most recently from 70401e5 to 77ecdb0 Compare April 25, 2026 01:04
@Zeophlite Zeophlite added this to the 0.19 milestone Apr 25, 2026
@JMS55
Copy link
Copy Markdown
Contributor

JMS55 commented Apr 25, 2026

I think this overlaps with the observers, e.g. extracted_light_removed. We should probably remove the observers in favor of this?

@kfc35
Copy link
Copy Markdown
Contributor Author

kfc35 commented Apr 25, 2026

I think this overlaps with the observers, e.g. extracted_light_removed. We should probably remove the observers in favor of this?

I removed that specific observer extracted_light_removed and added DirectionalLightViewEntities to the SyncComponent Target for DirectionalLight. However, I kept the remove_light_view_entities observer around since that one despawns the individual entities within the DirectionalLightViewEntities component (which SyncComponent does not cover)

I also removed some (I think?) redundant code in extract_lights that kept the main and render world sync’d with respect to Lights and their Extracted equivalents since SyncComponents should do that job now, and it actually improved the example — it removed the one frame blip of darkness between toggles of point and spot (although the shadows are still broken toggling between the two)! Hopefully the code is truly redundant, it seemed well documented for a specific reason...

@kfc35 kfc35 changed the title fix(light despawning): add shadow maps and extracted lights to SyncComponent for lights fix(light despawn / pcss example): add shadow maps and extracted lights to SyncComponent for lights Apr 29, 2026
@kfc35
Copy link
Copy Markdown
Contributor Author

kfc35 commented Apr 29, 2026

I figured it out after reading #23713 a little more deeply!!! I’m confident this is a full fix now, and it fixes the pcss example completely 😄

@kfc35 kfc35 requested a review from JMS55 April 29, 2026 05:13
@kfc35 kfc35 changed the title fix(light despawn / pcss example): add shadow maps and extracted lights to SyncComponent for lights fix(light despawn / pcss example): add extracted lights and shadow related components to SyncComponent for lights Apr 29, 2026
Copy link
Copy Markdown
Contributor

@Zeophlite Zeophlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 29, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 29, 2026
Merged via the queue into bevyengine:main with commit 53b79bb Apr 29, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in Rendering Apr 29, 2026
tychedelia pushed a commit to processing/bevy that referenced this pull request Apr 30, 2026
…lated components to SyncComponent for lights (bevyengine#23790)

# Objective

- Fixes bevyengine#23769 !

## Solution

I `git bisect`’d the issue to bbcc1e6
which has to do with `SyncComponent`s. The problem was that not all the
relevant components were being despawned when toggling an entity between
different Light components within the example. Expanding
`SyncComponents` for each light ensures that the lights clean up
properly between toggling.

I also had to review bevyengine#23713 and I connected the dots that de-spawning
the light should also despawn the light view entity. Duh!

## Testing

- `cargo run --example pcss --features=“experimental_pbr_pcss”`:
toggling works!
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-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Pcss example is broken

4 participants