godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.56k stars 21.09k forks source link

Vulkan: Background sky is still partially visible with transparent background enabled #67101

Open Calinou opened 2 years ago

Calinou commented 2 years ago

Godot version

4.0.beta2

System information

Fedora 36, Vulkan Forward Plus, AMD Radeon RX 6900 XT, KDE + KWin

Issue description

Note: This might be a KWin bug (or design decision), but I'm filing it here just in case. One possible cause is that KDE uses premultiplied alpha, while Godot doesn't. The background sky is not black, so even if it's fully transparent, its color is added instead of mixed.


This is what I see on the window (compositing is enabled). I can partially see the background sky:

image

Same window, but overlaid on a pure black background:

image

If I use KDE's screenshot tool to take a screenshot of the window, I get this:

image

The image outputted by MovieWriter (i.e. what Godot "sees") looks like this:

movie00000000

Steps to reproduce

Minimal reproduction project

test_movie_maker_png_transparent.zip

Calinou commented 1 year ago

I've noticed that there is a bit of code to clear alpha in OpenGL every frame when per-pixel transparency is enabled, but not in Vulkan:

https://github.com/godotengine/godot/blob/2a04b18d37de6c6e621db5a9dfd1cd0da5ccb015/platform/linuxbsd/x11/gl_manager_x11.cpp#L311-L319

cc @bruvzg