-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Per Pixel Transparency / DisplayServer.window_set_mode sets the background to transparent. #83131
Comments
I can reproduce this in 4.2.dev4 and later (but not in 4.2.dev2 and earlier) on Linux. I haven't managed to bisect this as the project fails to render in 4.2.dev3 (black screen for 3D rendering). A minimal project without 3D rendering doesn't exhibit the issue. My bisect left me on 715ebcc which I'm not sure is the cause. |
CC @bruvzg |
I can't reproduce the issue on my Linux system, though Per Pixel Transparency doesn't seem to work at all for me, neither in 4.1.2 nor 4.2-beta4. I do see a visual difference in this demo between 4.2-beta4 (top left) and 4.1.2 (bottom right):
|
Per Pixel Transparency active or deactivated? @akien-mga if "Per Pixel Transparency" is disabled and also "Transparent", then the background is black. |
It was activated, I tested both the window management demo, and a new project with this setting + Transparent enabled. |
Is compositing enabled in your window manager? Window transparency requires it to be enabled (try Alt + Shift + F12 in KWin). |
Good call, that was the issue. After enabling compositing with Alt+Shift+F12, I can reproduce the issue. For me the bug doesn't even require enabling fullscreen, the demo is wrongly transparent out of the box, in a semi-transparent manner. For each version tested, I show screenshots of the windowed mode with transparency off, then on. In 4.1.3-stable: In 4.2-dev1 and dev2: In 4.2-dev3, rendering seems broken: 4.2-dev4 and later: |
So I had a look too, 715ebcc is the first commit that exhibits the broken transparency because it's the first commit that fixes rendering. Before it, the project fails to render as you point out. So it hides the real culprit. #80502 was a fixup to #80311, so I tried a local revert of both PRs, and that solves the black screen rendering, but still exhibits the broken transparency: That's with current So that means they're not related to the bug, the real culprit must be another commit between 4.2.dev2 and 715ebcc. To bisect further, you'd have to apply 715ebcc manually whenever building a commit that includes #80311 but not #80502. |
I see what's wrong with macOS code, but not sure about Linux. I think there's no way to switch transparency for the window except at window creation time on X11. If |
#79876 just exposes the problem. Before it It seems like the problem is further up the pipeline. I.e. for some reason per-pixel transparency is force enabling transparent_bg in the viewport. What is the intended user experience for per-pixel window transparency? |
Worth noting that #80933 is also involved, to revert #79876 on top of current If I revert only #79876 and keep the inverse luminance multiplier from #80933, I still get a bug: i.e. with this diff: commit a72ca646a918951bdb81e4c4325e7b9f8caf60b8
Author: Rémi Verschelde <[email protected]>
Date: Thu Nov 9 22:19:00 2023 +0100
Revert "Fix transparent viewport backgrounds with custom clear color"
This reverts commit 6effd3cde7a481b57226cf5d03c97aa5728ff7e7.
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index 462fc4b524..71410bd752 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -931,19 +931,13 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
{
// regular forward for now
Vector<Color> c;
- {
- Color cc = clear_color.srgb_to_linear() * inverse_luminance_multiplier;
- if (rb_data.is_valid()) {
- cc.a = 0; // For transparent viewport backgrounds.
+ c.push_back(clear_color.srgb_to_linear() * inverse_luminance_multiplier); // our render buffer
+ if (rb_data.is_valid()) {
+ if (p_render_data->render_buffers->get_msaa_3d() != RS::VIEWPORT_MSAA_DISABLED) {
+ c.push_back(clear_color.srgb_to_linear() * inverse_luminance_multiplier); // our resolve buffer
}
- c.push_back(cc); // Our render buffer.
- if (rb_data.is_valid()) {
- if (p_render_data->render_buffers->get_msaa_3d() != RS::VIEWPORT_MSAA_DISABLED) {
- c.push_back(clear_color.srgb_to_linear() * inverse_luminance_multiplier); // Our resolve buffer.
- }
- if (using_subpass_post_process) {
- c.push_back(Color()); // Our 2D buffer we're copying into.
- }
+ if (using_subpass_post_process) {
+ c.push_back(Color()); // our 2D buffer we're copying into
}
}
|
I think I know what is going on on the rendering side now. It seems to be a duplicate of #61969 Which is caused by #61109. We write to alpha even when using opaque shaders, but alpha should be ignored when we copy the 3D buffer to the 2D buffer unless using transparent background. In 3.x we solved this with an |
Submitted a fix for the rendering side. Indeed the RD renderers were totally broken in multiple ways. #79876 made transparent background work, but it wasn't a full solution and wasn't fine grained enough. The fix needs some testing in more complex projects, but works in the MRP here and in the MRP from #61969 |
The macOS part (original bug report) is fixed by #84683, so we can close this. The Linux regression (not sure why it wouldn't affect other platforms, maybe it does) will be fixed by #84684, but it's a bit late to finalize it for 4.2 so that will likely be merged for 4.3 and cherry-picked for a 4.2.x release. |
Godot version
v4.2.dev6.official [57a6813]
System information
Godot v4.2.dev6 - macOS 13.6.0 - Vulkan (Forward+) - integrated Apple M1 - Apple M1 (8 Threads)
Issue description
Status: the demo is fully ported and working.
godotengine/godot-demo-projects#697
Renderer: Forward+ and Mobile. With 'Compatibility' everything seems to be ok.
I have already tried other 2D and 3D demos in the last weeks, such graphical problems did not occur there.
Note: when I use the system buttons to maximize the window (fullscreen), the background does not become transparent.
Screen-2023-10-11-011133.mp4
Debug:
get_viewport().transparent_bg = false
output:
Steps to reproduce
Fullscreen
buttonFullscreen
button againMinimal reproduction project
window_management demo
The text was updated successfully, but these errors were encountered: