Skip to content

Removing OIT component from main world doesn't remove all related components from render world #22863

@ashivaram23

Description

@ashivaram23

Bevy version and features

What you did

Tried running the OIT example and toggling OIT off

What went wrong

WGPU validation errors

Additional information

bbcc1e6 changed the logic in SyncComponentPlugin and entity_sync_system so that it no longer despawns and respawns the corresponding render world entity when a component is removed from the main world entity, and instead only removes the components specified in SyncComponent::Out. This means some components added elsewhere might remain and systems that assume those components always exist together will break.

For example if you remove OrderIndependentTransparancySettings, the extracted camera entity still has OitResolvePipelineId and OrderIndependentTransparencySettingsOffset (these were added by calling EntityCommands::insert), which means oit_resolve still tries to run the OIT resolve pass and the SetMeshViewBindGroup render command adds a dynamic offset that does not match the bind group layout since it thinks OIT is still being used.

In the OIT case those two functions could be changed to check Has<OrderIndependentTransparancySettings> and it would work again, but I think there may be many other other cases where render world logic assumes certain components exist together without checking because that was fine before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions