-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Fix transparent viewport backgrounds with custom clear color #79876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
If you want you can do the same fix for OpenGL (either in this PR or a followup). Clear color is set here:
godot/drivers/gles3/rasterizer_scene_gles3.cpp
Lines 1982 to 1984 in 0c2144d
if (!keep_color) { | |
glClearBufferfv(GL_COLOR, 0, clear_color.components); | |
} |
I went ahead and made the change to the PR for the Compatibility renderer. I tested it, and it is working, but with a caveat: The viewport's transparency doesn't seem to update until you reload the scene. I'm not sure why, but I'll look into it. |
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
3febf88
to
dad6ed1
Compare
For the Compatibility renderer, I changed I also made another change to force consistency between the renderers. Right now, setting an alpha on the custom clear color is ignored by the Forward+ and Mobile renderers. However, the alpha of the clear color was used when clearing the viewport in the Compatibility renderer, even with the viewport set to use an opaque background. I decided to force the alpha of the clear color to be 1 when the render target is not transparent to make the Compatibility renderer's behavior match the other renderers. |
From what I can tell, |
Thanks for looking into that more deeply. Indeed it makes sense to remove Go ahead and squash the commits together, then we can merge this! |
Also needs a rebase now :) |
Thanks! |
Cherry-picked for 4.1.4. |
This fixes #79778. This code change zeroes out the alpha component of the clear color. This basically just ports a change made in #61109 from the Forward+ renderer to the Mobile renderer, as well as an equivalent change to the Compatibility renderer.