3

The data rendered outside the window get a correct color

The data rendered within the window get a lighter color

As the images described, does anyone know what caused the problem?

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
qsxw
  • 91
  • 6
  • FYI I get the same issue, to anyone who thinks this isn't reproducible, literally just following IMGUI's example results in this behavior. – Krupip Sep 27 '21 at 01:34
  • I got the issue fixed over the days ago. The problem is caused by the format that imgui used to created the swapchain is R8G8B8A8_UNORM, but I used R8G8B8A8_SRGB for my purpose. So I forked the imgui and updated the request format in imgui backends to enable the sRGB. [backends/impl_vulkan: set VK_FORMAT_R8G8B8A8_SRGB as default](https://github.com/QSXW/imgui/commit/65dcd277acc0b97ac76d6bcc051b28577d8d1a2a). Hope the information helpful to you if you want to resolve the issue on your project. – qsxw Sep 28 '21 at 16:45
  • that is almost certainly what I'm doing, could you self answer? I'd gladly upvote it. – Krupip Sep 29 '21 at 13:31
  • Sure I do. Thanks. – qsxw Sep 30 '21 at 13:39

1 Answers1

5

The reason for the color lighter is that sRGB has a higher range of color space.

The problem above was caused by the that Dear Imgui uses VK_FORMAT_R8G8B8A8_UNORM as the highest priority to create the Swapchain, but I use 'VK_FORMAT_R8G8B8A8_SRGB` for my purpose. To get the problem resolved. You could choose the two methods below.

  1. Use the VK_FORMAT_R8G8B8A8_UNORM to create your Swapchain as what Dear Imgui used in the backends/impl_vulkan.
  2. Or you could change the priority list to select the VK_FORMAT_R8G8B8A8_SRGB in the backends/impl_vulkan like what I did:backends/impl_vulkan: set VK_FORMAT_R8G8B8A8_SRGB as default
qsxw
  • 91
  • 6
  • a lil bit late to the party, but as you said, changing your swapchain to use unorm does indeed solve the problem, but that creates another issue, you have to explicitly apply gamma correction. so I think the second option is better, cause you get to use SRGB, which lets the driver do the gamma correction automatically, which may lead to better performance, but idk why that doesn't work for me, my GPU supports SRGB, that's for sure, but still changing the imgui's swapchain format priority doesn't work, u know why that could be? – Karlos Dec 11 '22 at 12:23
  • @Karlos, It is probably because you are not actually using that value. If you create your window with GLFW, this function is never executed and hence the values are never used. The graphics pipeline uses UNORM as well, so you might want to take a look at that. – nepp95 May 19 '23 at 12:25