You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been hacking away at trying to get alpha compositing on viewports working in a custom backend (platform and renderer) for a bit, but I thought I'd try to implement it into the win32 example impl first in order to be able to port it over.
Using the existing ImGui_ImplWin32_EnableAlphaCompositing function, I can set any window to enable alpha compositing. Setting the clear color to the WindowBg style color in the renderer backend and disabling NoRendererClear like in #2766 was all I assumed I'd need past that. However, even if WindowBg alpha was below 255 and that change was reflected in other windows in the main viewport, it would not change the alpha of windows in other viewports. It seems as though this segment
if (window->ViewportOwned)
{
// No alpha
bg_col = (bg_col | IM_COL32_A_MASK);
if (is_docking_transparent_payload)
window->Viewport->Alpha *= DOCKING_TRANSPARENT_PAYLOAD_ALPHA;
}
prevents WindowBg alpha from ever affecting non main-viewport windows.
I understand alpha compositing is experimental - but I wanted to point this out in case others encounter it or so it does not get overlooked in further implementation.
Screenshots/Video
With the above lines present in imgui.cpp:
The same implementation, but with the line bg_col = (bg_col | IM_COL32_A_MASK); commented out:
Standalone, minimal, complete and verifiable example:
In imgui_impl_dx11.cpp, in ImGui_ImplDX11_RenderWindow():
Set the clear color ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
in my case, I also had to comment the NoRendererClear check.
In imgui_impl_win32.cpp, in ImGui_Impl32_CreateWindow():
After calling CreateWindowEx, call ImGui_ImplWin32_EnableAlphaCompositing(data->Hwnd);
In this state, if you run the demo, remove a window from the main viewport to create a new viewport, even though we are enabling alpha compositing and clearing our render target with the correct alpha, the window is not transparent when reducing the alpha of WindowBg in the style editor.
Comment out the line mentioned earlier, bg_col = (bg_col | IM_COL32_A_MASK); and run again. The WindowBg alpha value will be reflected as expected in viewport windows.
Thanks!
The text was updated successfully, but these errors were encountered:
You are correct! It seems I missed that since it uses a config flag that hasn't been implemented yet. Hopefully that will be implemented eventually in one way or another. Thank you!
I'll close this as "sort of duplicate" of #2766 but having the thread linked and index I'll be able to go back to this when we eventually decide of a design. I think we may be able to provide just enough in the core library to facilitate this, even if we don't immediately support all of it in our backends.
Version/Branch of Dear ImGui:
Version: 1.82
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_dx11.cpp + imgui_impl_win32.cpp
Compiler: MSVC
Operating System: win10
My Issue/Question:
I've been hacking away at trying to get alpha compositing on viewports working in a custom backend (platform and renderer) for a bit, but I thought I'd try to implement it into the win32 example impl first in order to be able to port it over.
Using the existing
ImGui_ImplWin32_EnableAlphaCompositing
function, I can set any window to enable alpha compositing. Setting the clear color to the WindowBg style color in the renderer backend and disabling NoRendererClear like in #2766 was all I assumed I'd need past that. However, even if WindowBg alpha was below 255 and that change was reflected in other windows in the main viewport, it would not change the alpha of windows in other viewports. It seems as though this segmentprevents WindowBg alpha from ever affecting non main-viewport windows.
I understand alpha compositing is experimental - but I wanted to point this out in case others encounter it or so it does not get overlooked in further implementation.
Screenshots/Video
With the above lines present in imgui.cpp:
The same implementation, but with the line
bg_col = (bg_col | IM_COL32_A_MASK);
commented out:Standalone, minimal, complete and verifiable example:
In
imgui_impl_dx11.cpp
, inImGui_ImplDX11_RenderWindow()
:Set the clear color
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
in my case, I also had to comment the NoRendererClear check.
In
imgui_impl_win32.cpp
, inImGui_Impl32_CreateWindow()
:After calling
CreateWindowEx
, callImGui_ImplWin32_EnableAlphaCompositing(data->Hwnd);
In this state, if you run the demo, remove a window from the main viewport to create a new viewport, even though we are enabling alpha compositing and clearing our render target with the correct alpha, the window is not transparent when reducing the alpha of WindowBg in the style editor.
Comment out the line mentioned earlier,
bg_col = (bg_col | IM_COL32_A_MASK);
and run again. The WindowBg alpha value will be reflected as expected in viewport windows.Thanks!
The text was updated successfully, but these errors were encountered: