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

Draw on a transparent window #274

Open
Proxtx opened this issue May 8, 2022 · 13 comments
Open

Draw on a transparent window #274

Proxtx opened this issue May 8, 2022 · 13 comments
Labels
upstream bug Bug appears to originate in an upstream dependency

Comments

@Proxtx
Copy link

Proxtx commented May 8, 2022

I created a transparent window bu as soon as I call the render function the background turns black

@parasyte parasyte added the upstream bug Bug appears to originate in an upstream dependency label May 8, 2022
@parasyte
Copy link
Owner

parasyte commented May 8, 2022

I believe this is gfx-rs/wgpu#687

We have supported the alpha channel since version 0.9.0 in #236 and it was made configurable in #260.

@Proxtx
Copy link
Author

Proxtx commented May 8, 2022

so basically it's impossible draw transparent pixels

@parasyte
Copy link
Owner

parasyte commented May 8, 2022

No, it is not impossible. Read the linked wgpu thread. It is awaiting a PR to make the composite mode configurable. Once that is released, I can upgrade it and configure the composite mode to fully support alpha blending on all environments.

@Proxtx
Copy link
Author

Proxtx commented May 8, 2022

ah so i just have to wait ok....

@DevAlone
Copy link

Any workarounds?

@parasyte
Copy link
Owner

The tasks for the wgpu side are described in the linked ticket. We can't do anything here until that is solved. Until these issues are taken care of, transparency in a transparent window may work depending on the exact environment due to various existing bugs in different levels of the graphics stack.

@nathanosoares
Copy link

nathanosoares commented Jun 8, 2022

Transparent draw works fine here
image

winit window builder:

 WindowBuilder::new()
            .with_decorations(false)
            .with_transparent(true)
            ...

pixels clear color:

pixels.set_clear_color(pixels::wgpu::Color::TRANSPARENT);

@parasyte
Copy link
Owner

Doing some cleanup on old tickets. This one can probably be closed since the upstream issue has been resolved.

Also, according to the docs, CompositeAlphaMode with support for blending is not guaranteed to be available on every surface. And indeed on Windows 11 I only have CompositeAlphaMode::Opaque available.

@fgimian
Copy link

fgimian commented Feb 7, 2024

I'm sorry to comment on a closed issue, but has anyone had success getting transparency to work on a Windows system? I haven't had luck getting it to work I'm afraid.

I have tried setting the clear_color to TRANSPARENT and the wgpu issue seems to be closed as though it was resolved.

I also tried a local fork of pixels where I hardcode the alpha_mode to various values. The modes PreMultiplied, PostMultiplied and Inherit all lead to a validation error on Windows.

Caused by:
    Requested alpha mode Inherit is not in the list of supported alpha modes: [Opaque]

This issue appears to be related: gfx-rs/wgpu#5150

Thanks heaps
Fotis

@parasyte
Copy link
Owner

parasyte commented Feb 7, 2024

I think what's missing is a way to override the CompositeAlphaMode. As you can see in

let alpha_mode = surface_capabilities.alpha_modes[0];
it always uses the surface's preferred mode. One thing that can be done is adding a builder method to set an override, and as long as the surface is capable of using the override, it should take precedence.

@parasyte parasyte reopened this Feb 7, 2024
@parasyte
Copy link
Owner

parasyte commented Feb 7, 2024

I also tried a local fork of pixels where I hardcode the alpha_mode to various values. The modes PreMultiplied, PostMultiplied and Inherit all lead to a validation error on Windows.

Ah, yes this is the problem I had when I wrote #274 (comment). Only Opaque is supported on my setup, too.

@parasyte
Copy link
Owner

parasyte commented Feb 7, 2024

Tracking upstream: gfx-rs/wgpu#3486

@fgimian
Copy link

fgimian commented Feb 7, 2024

I also tried a local fork of pixels where I hardcode the alpha_mode to various values. The modes PreMultiplied, PostMultiplied and Inherit all lead to a validation error on Windows.

Ah, yes this is the problem I had when I wrote #274 (comment). Only Opaque is supported on my setup, too.

Yep, I think that's really the root cause of this one. It likely is more of a wgpu problem, but would be great if we could track it here too.

Thanks so much for the reply and help 😄
Fotis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream bug Bug appears to originate in an upstream dependency
Projects
None yet
Development

No branches or pull requests

5 participants