Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-frame rendering flashes when changing the scene #18332

Closed
JMS55 opened this issue Mar 15, 2025 · 6 comments · Fixed by #18412
Closed

1-frame rendering flashes when changing the scene #18332

JMS55 opened this issue Mar 15, 2025 · 6 comments · Fixed by #18412
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Milestone

Comments

@JMS55
Copy link
Contributor

JMS55 commented Mar 15, 2025

Bevy version

0.16-dev since 5e569af.

What you did

Run cargo run --example anti_aliasing, and toggle back and forth between the different AA methods (give the first few times a few seconds to compile the pipelines).

What went wrong

Switching the AA method causes a 1-frame flash where the mesh doesn't render properly.

@JMS55 JMS55 added A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior labels Mar 15, 2025
@JMS55 JMS55 added this to the 0.16 milestone Mar 15, 2025
@hukasu
Copy link
Contributor

hukasu commented Mar 15, 2025

messing with the anti_aliasing example i noticed this, the flash happens when changing out of FXAA, SMAA, and TAA

To \ From No AA MSAA FXAA SMAA TAA
No AA X O O O
MSAA X O O O
FXAA X X O O
SMAA X X O O
TAA X X O O

@superdump
Copy link
Contributor

Does X mean the flash happens and O means it doesn't?

@hukasu
Copy link
Contributor

hukasu commented Mar 16, 2025

@superdump the opposite, X no flash, O flash

@JMS55
Copy link
Contributor Author

JMS55 commented Mar 18, 2025

I did a little more debugging.

The issue is specifically with shadows not rendering for 1(?) frame when something with the view changes (not sure exactly what yet).

If I comment out this line, the bug goes away.

specialized_material_pipeline_cache.retain(|view, _| all_shadow_views.contains(view));

@JMS55
Copy link
Contributor Author

JMS55 commented Mar 18, 2025

Even more debugging: it happens for exactly 1 frame, and it's due to this query:

view_lights: Query<(Entity, &ViewLightEntities), With<ExtractedView>>,

matching 0 entities.

This causes all_shadow_views to be empty, so the pipeline cache gets entirely emptied out.

@JMS55
Copy link
Contributor Author

JMS55 commented Mar 19, 2025

Ah ok so it's a system ordering issue.

specialize_shadows::<M>.in_set(RenderSet::PrepareMeshes);
prepare_lights.in_set(RenderSet::ManageViews);

PrepareMeshes runs before ManageViews, but specialize_shadows needs to run after prepare_lights.

github-merge-queue bot pushed a commit that referenced this issue Mar 19, 2025
# Objective
- Fixes #18332

## Solution

- Move specialize_shadows to ManageViews so that it can run after
prepare_lights, so that shadow views exist for specialization.
- Unfortunately this means that specialize_shadows is no longer in
PrepareMeshes like the rest of the specialization systems.

## Testing
- Ran anti_aliasing example, switched between the different AA options,
observed no glitches.
mockersf pushed a commit that referenced this issue Mar 19, 2025
# Objective
- Fixes #18332

## Solution

- Move specialize_shadows to ManageViews so that it can run after
prepare_lights, so that shadow views exist for specialization.
- Unfortunately this means that specialize_shadows is no longer in
PrepareMeshes like the rest of the specialization systems.

## Testing
- Ran anti_aliasing example, switched between the different AA options,
observed no glitches.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants