bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.47k stars 3.6k forks source link

Window transparency broken on Windows #7544

Open aevyrie opened 1 year ago

aevyrie commented 1 year ago

Bevy version

main

The transparent_window example appears to have broken.

image

2023-02-07T09:15:10.694725Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3050 Ti Laptop GPU", vendor: 4318, device: 9632, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "527.56", backend: Vulkan }
2023-02-07T09:15:10.985257Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22621", cpu: "11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz", core_count: "8", memory: "63.7 GiB" }
Aceeri commented 1 year ago

Can't seem to repro this myself, going to try updating my drivers. Maybe should try a cargo clean/cargo run --example transparent_window

minstrel1 commented 1 year ago

Same issue occurred on Mac OS on Metal. SystemInfo { os: "MacOS 12.1 ", kernel: "21.2.0", cpu: "Apple M1", core_count: "8", memory: "8.0 GiB" }

mockersf commented 1 year ago

This is known, see the docs on https://dev-docs.bevyengine.org/bevy/prelude/struct.Window.html#structfield.transparent

I opened a PR to improve the situation on macOS: https://github.com/bevyengine/bevy/pull/7617

On windows, it should be fixed by latest winit update, but I can't confirm it myself.

james7132 commented 1 year ago

Can confirm that the latest winit update has fixed this on Windows.

mockersf commented 1 year ago

Doc should be updated to remove mention of issues on windows: https://github.com/bevyengine/bevy/blob/2344b943a2f65031200a19d314b328a2eea320ae/crates/bevy_window/src/window.rs#L130-L135

aevyrie commented 1 year ago

This appears to be broken on main again. I've tried a cargo clean and running in release with no luck.

morfert commented 1 year ago

transparent_window example not working for me either. image

cargo run --example transparent_window
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target\debug\examples\transparent_window.exe`
2023-06-14T07:43:02.479588Z  INFO bevy_winit::system: Creating new window "Bevy App" (0v0)
2023-06-14T07:43:02.769532Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1660 Ti", vendor: 4318, device: 8593, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "528.79", backend: Vulkan }
2023-06-14T07:43:04.046657Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 10 Home", kernel: "19045", cpu:
"Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz", core_count: "6", memory: "15.8 GiB" }
Aceeri commented 1 year ago

@aevyrie @morfert Could you try running the winit example here? https://github.com/rust-windowing/winit/blob/master/examples/transparent.rs

Will see if I can repro again this week.

morfert commented 1 year ago

I cloned winit and ran cargo run --example transprent but the window was not transparent. image This may be a winit problem.

Aceeri commented 1 year ago

Investigating a bit and it seems like that might just be an issue with their example not drawing anything?

https://github.com/rust-windowing/winit/issues/2502

SecretPocketCat commented 1 year ago

This might be a red herring, but blur and similar decorators were broken in the tauri-adjacent crate on Win 11 22H2 https://github.com/tauri-apps/window-vibrancy/issues/45

SecretPocketCat commented 1 year ago

This might be a red herring, but blur and similar decorators were broken in the tauri-adjacent crate on Win 11 22H2 tauri-apps/window-vibrancy#45

My bad, the bevy example is actually fine on Win 11 22H2.

morfert commented 1 year ago

Yeah, winit is probably fine I tried drawing something.

Transparent

With:

        WindowBuilder::new()
            .with_decorations(false)
            .with_transparent(true)
            .with_inner_size(size)
            .with_min_inner_size(size)
            .build(&event_loop)
            .unwrap()

Result: image

Not transparent

With:

        WindowBuilder::new()
            .with_title("Hello Pixels")
            .with_inner_size(size)
            .with_min_inner_size(size)
            .build(&event_loop)
            .unwrap()

Result: image

Conclusion

As long as something is drawn, winit seems to properly become transparent.

Addendum

The Not transparent test is the unmodified minimal winit example from pixels.

stefnotch commented 1 year ago

@morfert

Pixels might not be the best library to test this, because of https://github.com/parasyte/pixels/issues/370 That leads to it being either "fully transparent" or "fully opaque".

transparent-pixels-winit.zip

morfert commented 1 year ago

Using the following code:

    let window = WindowBuilder::new()
        .with_title("A simple window")
        .with_transparent(true)
        .build(&event_loop)
        .expect("Builing window failed");

    let instance = wgpu::Instance::default();

    let surface = unsafe { instance.create_surface(&window) }.expect("Could not create surface");

    for ad in instance.enumerate_adapters(wgpu::Backends::all()) {
        info!(
            "Adapter : {:?}\n Supported Alpha : {:?}",
            ad.get_info(),
            surface.get_capabilities(&ad).alpha_modes
        );
    }

I enumerate to see all supported alpha_modes for all adapters on my laptop. The results are as follows:

2023-08-30T08:05:50.081235Z  INFO gapoo:
 Adapter : AdapterInfo { name: "NVIDIA GeForce GTX 1660 Ti", vendor: 4318, device: 8593, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "532.09", backend: Vulkan }
 Supported Alpha : [Opaque]
    at src\main.rs:29

2023-08-30T08:05:50.081668Z  INFO gapoo:
 Adapter : AdapterInfo { name: "Intel(R) UHD Graphics 630", vendor: 32902, device: 16027, device_type: IntegratedGpu, driver: "Intel Corporation", driver_info: "Intel driver", backend: Vulkan }
 Supported Alpha : [Opaque, Inherit]
    at src\main.rs:29

2023-08-30T08:05:50.081924Z  INFO gapoo:
 Adapter : AdapterInfo { name: "NVIDIA GeForce GTX 1660 Ti", vendor: 4318, device: 8593, device_type: DiscreteGpu, driver: "", driver_info: "", backend: Dx12 }
 Supported Alpha : [Opaque]
    at src\main.rs:29

2023-08-30T08:05:50.114292Z  INFO gapoo:
 Adapter : AdapterInfo { name: "Intel(R) UHD Graphics 630", vendor: 32902, device: 16027, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Dx12 }
 Supported Alpha : [Opaque]
    at src\main.rs:29

2023-08-30T08:05:50.123944Z  INFO gapoo:
 Adapter : AdapterInfo { name: "Microsoft Basic Render Driver", vendor: 5140, device: 140, device_type: Cpu, driver: "", driver_info: "", backend: Dx12 }
 Supported Alpha : [Opaque]
    at src\main.rs:29

Only Opaque and Inherit are available. This might be the problem.

CoryRobertson commented 1 year ago

I also have transparency not working as well, are there any active workarounds?

edraze commented 8 months ago

Hi, are there any updates on this problem? Looks like transparency still not working(#10929), even with winit latest versions.

bradmesserle commented 7 months ago

How do we find gpu's that support PostMultiplied Apha Mode?

lunarcleint commented 6 months ago

Has they're been any update on this? transparency is still not working and now I'm noticing the examples just missing from the winit repo

bradmesserle commented 6 months ago

No updates.. I have been out of town for the last month..  thanksSent from my iPhoneOn May 23, 2024, at 11:55 PM, lunarcleint @.***> wrote: Has they're been any update on this? transparency is still not working and now I'm noticing the examples just missing from the winit repo

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

KernelKrusha commented 5 months ago

I also have this problem with AMD Radeon 680M on Win 11, only getting Opaque in the list of supported alpha modes. Not sure if that is related or not, but the transparency example on master does not work.

lunarcleint commented 5 months ago

This has been fixed on the latest bevy 0.14 testing, try it out :D

On Wed, Jun 26, 2024 at 2:13 PM KernelKrusha @.***> wrote:

I also have this problem with AMD Radeon 680M, only getting Opaque in the list of supported alpha modes. Not sure if that is related or not, but the transparency example on master does not work.

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192635689, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVFSDXX6PSQY7POCYW7JUKLZJMVFZAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGYZTKNRYHE . You are receiving this because you commented.Message ID: @.***>

bradmesserle commented 5 months ago

This will be fantastic is so. I will update and retest…Thank you Sent from my iPhoneOn Jun 26, 2024, at 8:38 PM, lunarcleint @.***> wrote: This has been fixed on the latest bevy 0.14 testing, try it out :D

On Wed, Jun 26, 2024 at 2:13 PM KernelKrusha @.***>

wrote:

I also have this problem with AMD Radeon 680M, only getting Opaque in the

list of supported alpha modes. Not sure if that is related or not, but the

transparency example on master does not work.

Reply to this email directly, view it on GitHub

https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192635689,

or unsubscribe

https://github.com/notifications/unsubscribe-auth/AVFSDXX6PSQY7POCYW7JUKLZJMVFZAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGYZTKNRYHE

.

You are receiving this because you commented.Message ID:

@.***>

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

bradmesserle commented 5 months ago

Off topic but why is there not a most current version number on the bevy website? I had to look in github. The getting started or the front page should have the most current version displayed.

IMHO.. :)

Thanks

On Wed, Jun 26, 2024 at 11:07 PM Brad Messerle @.***> wrote:

This will be fantastic is so. I will update and retest…

Thank you Sent from my iPhone

On Jun 26, 2024, at 8:38 PM, lunarcleint @.***> wrote:



This has been fixed on the latest bevy 0.14 testing, try it out :D

On Wed, Jun 26, 2024 at 2:13 PM KernelKrusha @.***> wrote:

I also have this problem with AMD Radeon 680M, only getting Opaque in the list of supported alpha modes. Not sure if that is related or not, but the transparency example on master does not work.

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192635689,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AVFSDXX6PSQY7POCYW7JUKLZJMVFZAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGYZTKNRYHE>

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192847352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABX2FUOSJ42N75E36CRW2DZJNNJDAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSHA2DOMZVGI . You are receiving this because you commented.Message ID: @.***>

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

bradmesserle commented 5 months ago

updated my little sample app to bevy 0.14-rc3.

Still getting errors on Windows.

This is error log... warning: trader-seth-event-calendar (bin "trader-seth-event-calendar") generated 3 warnings Finished dev profile [unoptimized + debuginfo] target(s) in 1m 53s Running target\debug\trader-seth-event-calendar.exe 2024-06-27T20:04:30.672264Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "12th Gen Intel(R) Core(TM) i7-12700H", core_count: "14", memory: "15.7 GiB" } 2024-06-27T20:04:32.601736Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3060 Laptop GPU", vendor: 4318, device: 9568, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.86", backend: Vulkan } 2024-06-27T20:04:33.752522Z INFO bevy_winit::system: Creating new window "Trader Seth - Event Calendar" (Entity { index: 0, generation: 1 }) thread 'Compute Task Pool (7)' panicked at C:\Users\bradm.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\backend\wgpu_core.rs:751 :18: Error in Surface::configure: Validation Error

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

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Encountered a panic in system bevy_render::view::window::create_surfaces!

Thank You

On Thu, Jun 27, 2024 at 10:05 AM Brad Messerle @.***> wrote:

Off topic but why is there not a most current version number on the bevy website? I had to look in github. The getting started or the front page should have the most current version displayed.

IMHO.. :)

Thanks

On Wed, Jun 26, 2024 at 11:07 PM Brad Messerle @.***> wrote:

This will be fantastic is so. I will update and retest…

Thank you Sent from my iPhone

On Jun 26, 2024, at 8:38 PM, lunarcleint @.***> wrote:



This has been fixed on the latest bevy 0.14 testing, try it out :D

On Wed, Jun 26, 2024 at 2:13 PM KernelKrusha @.***> wrote:

I also have this problem with AMD Radeon 680M, only getting Opaque in the list of supported alpha modes. Not sure if that is related or not, but the transparency example on master does not work.

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192635689,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AVFSDXX6PSQY7POCYW7JUKLZJMVFZAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGYZTKNRYHE>

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192847352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABX2FUOSJ42N75E36CRW2DZJNNJDAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSHA2DOMZVGI . You are receiving this because you commented.Message ID: @.***>

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

bradmesserle commented 5 months ago

sorry i had to update to Opaque mode.. and it works.

Thank You for the support !!!

On Thu, Jun 27, 2024 at 4:07 PM Brad Messerle @.***> wrote:

updated my little sample app to bevy 0.14-rc3.

Still getting errors on Windows.

This is error log... warning: trader-seth-event-calendar (bin "trader-seth-event-calendar") generated 3 warnings Finished dev profile [unoptimized + debuginfo] target(s) in 1m 53s Running target\debug\trader-seth-event-calendar.exe 2024-06-27T20:04:30.672264Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Home", kernel: "22631", cpu: "12th Gen Intel(R) Core(TM) i7-12700H", core_count: "14", memory: "15.7 GiB" } 2024-06-27T20:04:32.601736Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3060 Laptop GPU", vendor: 4318, device: 9568, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.86", backend: Vulkan } 2024-06-27T20:04:33.752522Z INFO bevy_winit::system: Creating new window "Trader Seth - Event Calendar" (Entity { index: 0, generation: 1 }) thread 'Compute Task Pool (7)' panicked at C:\Users\bradm.cargo\registry\src\index.crates.io-6f17d22bba15001f\wgpu-0.20.1\src\backend\wgpu_core.rs:751 :18: Error in Surface::configure: Validation Error

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

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Encountered a panic in system bevy_render::view::window::create_surfaces!

Thank You

On Thu, Jun 27, 2024 at 10:05 AM Brad Messerle @.***> wrote:

Off topic but why is there not a most current version number on the bevy website? I had to look in github. The getting started or the front page should have the most current version displayed.

IMHO.. :)

Thanks

On Wed, Jun 26, 2024 at 11:07 PM Brad Messerle @.***> wrote:

This will be fantastic is so. I will update and retest…

Thank you Sent from my iPhone

On Jun 26, 2024, at 8:38 PM, lunarcleint @.***> wrote:



This has been fixed on the latest bevy 0.14 testing, try it out :D

On Wed, Jun 26, 2024 at 2:13 PM KernelKrusha @.***> wrote:

I also have this problem with AMD Radeon 680M, only getting Opaque in the list of supported alpha modes. Not sure if that is related or not, but the transparency example on master does not work.

— Reply to this email directly, view it on GitHub < https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192635689>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AVFSDXX6PSQY7POCYW7JUKLZJMVFZAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSGYZTKNRYHE>

. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/bevyengine/bevy/issues/7544#issuecomment-2192847352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABX2FUOSJ42N75E36CRW2DZJNNJDAVCNFSM6AAAAAAUTWL7ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSHA2DOMZVGI . You are receiving this because you commented.Message ID: @.***>

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

-- Reminder to all what it means to be an American. 1969.. https://www.youtube.com/watch?v=TZBTyTWOZCM

Arrekin commented 3 months ago

The example from https://github.com/bevyengine/bevy/blob/release-0.14.0/examples/window/transparent_window.rs does not work for me. I'm getting a black background.

Bevy 0.14, Windows 10, Vulkan, [Opaque]

SystemInfo { os: "Windows 10 Pro", kernel: "19045", cpu: "Intel(R) Core(TM) i7-6800K CPU @ 3.40GHz", core_count: "6", memory: "15.9 GiB" }
AdapterInfo { name: "NVIDIA GeForce GTX 1080", vendor: 4318, device: 7040, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "556.12", backend: Vulkan }
iamthuypham commented 2 months ago

I had the same problem. I have to update NVIDIA graphic card version to get it working.

Before: NVIDIA RTX 3500 Ada Generation v538.18

After: NVIDIA RTX 3500 Ada Generation v552.86

Arrekin commented 2 months ago

561.09 for NVIDIA GeForce GTX 1080 - the newest available driver - still doesn't work. The background is still black 😞

alice-i-cecile commented 1 week ago

This largely appears to be a winit bug: https://github.com/rust-windowing/winit/issues/2502. That said, the comments suggest a workaround that's worth investigating. It's a bit hacky to try and fix this at the Bevy level but maybe it's worth it?