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 cannot seem to figure out how to switch the surface format from UNORM to SRGB or some other format when using Vulkan in ImGui. This means that all my colours for ImGui appear washed out and exploring issues and examples has not made it clearer unfortunately. Thanks so much for any help!
Screenshots/Video:
Surface is in VK_FORMAT_B8G8R8A8_SRGB
Surface is VK_FORMAT_B8G8R8A8_UNORM
Minimal, Complete and Verifiable Example code:
// If you were to want to use SRGB in your application like so:// It seems undocumented how to switch colour spaces if it is possible
VkSurfaceFormatKHR App::ChooseSwapSurfaceFormat(
const std::vector<VkSurfaceFormatKHR> &availableFormats) {
for (constauto &availableFormat : availableFormats) {
if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB &&
availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) {
return availableFormat;
}
}
return availableFormats[0];
}
I have explored other issues but they do not seem to have any solutions apart from modifying the backend files, I would like not to resort to this, or is there simply no other way in the current API. Any help is greatly appreciated!
The text was updated successfully, but these errors were encountered:
It is far from a solution and is at best a hack, but this at least makes the UI look correct:
ImGuiStyle &style = ImGui::GetStyle();
// Go through every colour and convert it to linear// This is because ImGui uses linear colours but we are using sRGB// This is a simple approximation of the conversionfor (int i = 0; i < ImGuiCol_COUNT; i++) {
/*float linear = (srgb <= 0.04045f) ? srgb / 12.92f : pow((srgb + 0.055f) * / 1.055f, 2.4f);*/
ImVec4 &col = style.Colors[i];
col.x = col.x <= 0.04045f ? col.x / 12.92f
: pow((col.x + 0.055f) / 1.055f, 2.4f);
col.y = col.y <= 0.04045f ? col.y / 12.92f
: pow((col.y + 0.055f) / 1.055f, 2.4f);
col.z = col.z <= 0.04045f ? col.z / 12.92f
: pow((col.z + 0.055f) / 1.055f, 2.4f);
}
I saw there were already some PRs to do with colour space in ImGui Vulkan, specifically #8053 but it seems to be a draft so I'm unsure and they are most likely more experienced than me, is it worth me attempting to make a PR?
Version/Branch of Dear ImGui:
Version 1.91.0, Branch: docking (master/docking/etc.)
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler, OS:
Linux + Clang
Full config/build information:
Details:
My Issue/Question:
I cannot seem to figure out how to switch the surface format from UNORM to SRGB or some other format when using Vulkan in ImGui. This means that all my colours for ImGui appear washed out and exploring issues and examples has not made it clearer unfortunately. Thanks so much for any help!
Screenshots/Video:
Surface is in
VK_FORMAT_B8G8R8A8_SRGB
Surface is
VK_FORMAT_B8G8R8A8_UNORM
Minimal, Complete and Verifiable Example code:
I have explored other issues but they do not seem to have any solutions apart from modifying the backend files, I would like not to resort to this, or is there simply no other way in the current API. Any help is greatly appreciated!
The text was updated successfully, but these errors were encountered: