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

transparency has a 1 frame lag between sprites that are not siblings #1506

Closed
mockersf opened this issue Feb 23, 2021 · 3 comments
Closed

transparency has a 1 frame lag between sprites that are not siblings #1506

mockersf opened this issue Feb 23, 2021 · 3 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@mockersf
Copy link
Member

mockersf commented Feb 23, 2021

Bevy version

current main (bc4fe9b)

Operating system & version

MacOS 10.15.7

What you did

  • Set the clear color to red
  • Display a sprite that covers everything black as a children of another entity
  • Display a sprite from a transparent png
use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .insert_resource(ClearColor(Color::RED))
        .add_startup_system(setup.system())
        .add_system(cycle.system())
        .run();
}

fn setup(commands: &mut Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
    commands
        .spawn(OrthographicCameraBundle::new_2d())
        .spawn((GlobalTransform::default(), Transform::default()))
        .with_children(|p| {
            p.spawn(SpriteBundle {
                material: materials.add(Color::BLACK.into()),
                sprite: Sprite {
                    size: Vec2::new(10000., 10000.),
                    ..Default::default()
                },
                ..Default::default()
            });
        });
}

struct ShouldTransparent;
fn cycle(
    commands: &mut Commands,
    mut cycle: Local<u32>,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    *cycle = (*cycle + 1) % 20;
    if *cycle == 0 {
        let texture_handle = asset_server.load("branding/icon.png");
        for x in -1..=1 {
            for y in -1..=1 {
                commands.spawn(SpriteBundle {
                    material: materials.add(texture_handle.clone().into()),
                    transform: Transform {
                        translation: Vec3::new(x as f32 * 256., y as f32 * 256., 0.1),
                        scale: Vec3::one(),
                        rotation: Quat::default(),
                    },
                    ..Default::default()
                });
                // .with(ShouldTransparent);
            }
        }
    }
}

What you expected to happen

No transparency issue

What actually happened

The red clear color leaks through for a frame
ezgif-2-3c12a37e0f23

Additional information

If I remove the hierarchy for the black background, there are no transparency issue.
If I add the tag component ShouldTransparent to my sprites, there are no transparency issue.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Feb 23, 2021
@mockersf
Copy link
Member Author

as it was working on 0.4, I checked commits, and it started failing with d5a7330

@alice-i-cecile
Copy link
Member

This is probably caused by #1466 and should be checked once it's tentatively solved.

@mockersf
Copy link
Member Author

fixed by #1606

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

No branches or pull requests

2 participants