pixels
pixels copied to clipboard
Draw on a transparent window
I created a transparent window bu as soon as I call the render function the background turns black
I believe this is https://github.com/gfx-rs/wgpu/issues/687
We have supported the alpha channel since version 0.9.0 in #236 and it was made configurable in #260.
so basically it's impossible draw transparent pixels
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.
ah so i just have to wait ok....
Any workarounds?
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.
Transparent draw works fine here

winit window builder:
WindowBuilder::new()
.with_decorations(false)
.with_transparent(true)
...
pixels clear color:
pixels.set_clear_color(pixels::wgpu::Color::TRANSPARENT);
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.
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: https://github.com/gfx-rs/wgpu/issues/5150
Thanks heaps Fotis
I think what's missing is a way to override the CompositeAlphaMode. As you can see in https://github.com/parasyte/pixels/blob/befb84aea80179377554e22fa9350f02b0b2aad6/src/builder.rs#L322 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.
I also tried a local fork of pixels where I hardcode the
alpha_modeto various values. The modesPreMultiplied,PostMultipliedandInheritall lead to a validation error on Windows.
Ah, yes this is the problem I had when I wrote https://github.com/parasyte/pixels/issues/274#issuecomment-1482344584. Only Opaque is supported on my setup, too.
Tracking upstream: https://github.com/gfx-rs/wgpu/issues/3486
I also tried a local fork of pixels where I hardcode the
alpha_modeto various values. The modesPreMultiplied,PostMultipliedandInheritall 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