mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
Window alpha blend issue when using GLFW_TRANSPARENT_FRAMEBUFFER (OpenGl3) #2764
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#2764
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version: 1.73 (
cb538fadfe)Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw3.cpp
Compiler: Visual Studio 2019 (MSVC)
Operating System: Windows 10 Pro (1809)
My Issue/Question:
When transparent framebuffers are enabled in GLFW (via GLFW_TRANSPARENT_FRAMEBUFFER window hint), imgui backgrounds do not properly alpha blend, and the underlying windows will bleed through the imgui windows, even when the backbuffer transparency is 1.
Expected result:

Actual result:

Suggested Resolution:
Change line 186 of imgui_impl_opengl3.cpp from:
to
This fixes the issue, but I have not tested the potential side effects of this. In theory additive blending of alpha should work, there is probably something that I'm missing. Looking at the docs, the only way to go from 255 alpha to something lower is if As or sA is < 0). When doing a pixel debug in nsight, things start to make even less sense.
If you look at event 50, the alpha actually drops from 255 down to 241
Compare that to what the docs say, we should be getting:
I have the feeling that this is less of an ImGui issue and more of an issue with how GLFW or OpenGL handle transparent framebuffers (there's also an issue where a=0 does not blend properly with the underlying screen if any of the other channels are non-zero), but I need to do more digging.
As for the visual difference between additive and max, it looks OK to me, but then again I don't have any content underneath it yet:

I feel like I may be missing something else here, any suggestions?
Standalone, minimal, complete and verifiable example:
On further messing around, I think it would make more sense to change the blend function instead of equation, so:
and keep
glBlendEquation(GL_ADD)This appears to have the same effect, and should have minimal impact on the appearance of UI's.
On another note, it looks like there is some more internal work to do to support transparent framebuffers. I may try my hand at a PR later, once I have some of the current issues resolved (biggest one is creating transparent windows and clearing properly for multiple viewports).
Sorry @ShawnM427 for the late answer.
Went through a bunch of backends and examples yesterday.
Fixed this with
bda12e5fddand6a161b8789(had seven related issues).We will still need to work on better Backends and Multi-viewports support, so will keep #2766 open as current change don't fulfill all the ideas suggested by #2766. Will add more details there.