Search code examples
vulkanimgui

Imgui text appears as white rectangles on my custom Vulkan renderer


I am following Sascha Willems example on how to integrate imgui with a Vulkan renderer.

Trying to render this simple window:

    ImGui::NewFrame();
    ImGui::SetNextWindowSize(ImVec2(128, 64), ImGuiCond_FirstUseEver);
    ImGui::Begin("Test Window", nullptr);
    ImGui::Text("Test Text");
    ImGui::End();
    ImGui::Render();
    

Yields the following:

image

Unfortunately text appears as white rectangles. I examined the rendering process against Sascha Willem code using Renderdoc but haven't yet found what went wrong.

Here is a link to the renderdoc file and relevant code files.

From my examination, it seems that vertex data and textures are loaded correctly. but the two samples have a slightly different font texture and as a result, slightly different uv coordinates per vertex. But nothing to explain why the textured text quads appear completely white. I guess the difference in the font texture emanate from the fact that I use a different imgui version (latest docking branch from vcpkg).

Does anyone have an idea what could lead to such result?

I would be happy to share more info if you think it is relevant (code, renderdoc files) but I wish to avoid clutter this post with too much code.


Solution

  • The issue was caused due to disabled blending.

    Apparently, the imgui font texture has the value (1.0f, 1.0f, 1.0f, 0.0f) where the text quad should be blank (and not (0.0f, 0.0f, 0.0f, 0.0f). If blending is not enabled, then the alpha channel will be ignored which will cause the text quad to appear white.