Skip to content
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

SRGB framebuffer issue #6583

Open
gui2one opened this issue Jul 8, 2023 · 1 comment
Open

SRGB framebuffer issue #6583

gui2one opened this issue Jul 8, 2023 · 1 comment

Comments

@gui2one
Copy link

gui2one commented Jul 8, 2023

Config/Build Information (copied from Demo Window)

Dear ImGui 1.87 WIP (18602)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1929
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00100041
 NavEnableKeyboard
 DockingEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Version/Branch of Dear ImGui:

Version: 1.87 WIP
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler: MSVC
Operating System: Windows10

My Issue/Question:

I am building a small OpenGL Renderer. I struggled a lot with linear/sRGB workflow, and finally settle on using

glEnable(GL_FRAMEBUFFER_SRGB)

witch is apparently pretty much free, and means I don't have to do all the work in fragment shaders. So it's a no brainer.
But once in ImGui, the viewport where I renderer my scene is OK, but ImGui colors are too bright.

And trying to enable and disable GL_FRAMEBUFFER_SRGB before and after the ImGui window creation doesn't work.
I either have ImGui colors to bright and viewport OK,
or ImGui colors OK but viewport too dark;

The scene is rendererd to a framebuffer, which I then display in ImGui window using ImGui::Image() display the scene

Is there a way apply a fragment shader to the image displayed by ImGui::Image ?
(to apply a final gamma correction just for the viewport )

Screenshots/Video

ImGui_SRGB_issue2

@PathogenDavid
Copy link
Contributor

Dear ImGui currently doesn't play nice with sRGB backbuffers. #578 #1724 #2943 #4890

Unfortunately no consensus has been reached on what the appropriate fix should be.

The maybe-good-enough bandaid fix is to add a sRGB->linear conversion to the end of the pixel shader in the backend to counter-act the implicit linear->sRGB conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants