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

Can't take transparent screenshots #18229

Open
amytimed opened this issue Mar 10, 2025 · 0 comments
Open

Can't take transparent screenshots #18229

amytimed opened this issue Mar 10, 2025 · 0 comments
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@amytimed
Copy link

Bevy version

0.15.0

What you did

I have this system:

fn add_icon_camera(
    mut commands: Commands,
    mut images: ResMut<Assets<Image>>,
) {
    let size = Extent3d {
        width: 512,
        height: 512,
        ..default()
    };

    // This is the texture that will be rendered to.
    let mut image = Image::new_fill(
        size,
        TextureDimension::D2,
        &[0, 0, 0, 0],
        TextureFormat::Bgra8UnormSrgb,
        //TextureFormat::Rgba8UnormSrgb,
        RenderAssetUsages::default(),
    );
    // You need to set these texture usage flags in order to use the image as a render target
    image.texture_descriptor.usage =
        TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST | TextureUsages::RENDER_ATTACHMENT;

    let image_handle = images.add(image);

    let first_pass_layer = RenderLayers::layer(2);

    commands.spawn((
        Camera2d,
        Camera {
            hdr: false,
            target: image_handle.clone().into(),
            clear_color: bevy::render::camera::ClearColorConfig::None,
            viewport: None,
            ..Default::default()
        },

        OrthographicProjection {
            far: 1.,
            near: -10000000.,
            ..OrthographicProjection::default_2d()
        },
        //first_pass_layer.clone(),
        Msaa::Sample4,
        IconCamera,
    ));

    commands.insert_resource(IconCameraImage(image_handle));
}

Then I try screenshot with the image as the target

What went wrong

In the screenshot it always has a black background. I tried ClearColorConfig::Custom(Color::NONE) too, but that just had pitch black screen (wouldn't even show foreground anymore)

I would've expected it to be transparent because there's an alpha channel to the format and because of the clear color

@amytimed amytimed added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 10, 2025
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Triage This issue needs to be labelled labels Mar 10, 2025
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 A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

2 participants