0
$\begingroup$

I am following https://vulkan-tutorial.com/Introduction to get myself familiar with the Vulkan API. I have gotten to the point where my application is able to draw a triangle. But for some reason the clear color is way brighter than the RGB value that i specified in my code. I am setting the color like this:

    VkClearValue clearColor = {0.2f, 0.2f, 0.2f, 1.0f};

    VkRenderPassBeginInfo renderPassBeginInfo = {
        .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
        .renderPass = renderPass,
        .framebuffer = swapChainFramebuffers[i],
        .renderArea = {
            .offset = {
                .x = 0,
                .y = 0
            },
            .extent = swapChainExtent
        },
        .clearValueCount = 1,
        .pClearValues = &clearColor
    };

An RGB value of [0.2, 0.2, 0.2, 1.0] or [50, 50, 50, 255] should be a very dark gray, almost black. Instead i am getting is this:

enter image description here

This looks more like an RGB value of [150,150,150,255]. To get a color close to what i want i have to instead go with something like this:

VkClearValue clearColor = {0.02f, 0.02f, 0.02f, 1.0f};

So it almost seems like everything is shifted by a decimal. Any idea what might cause this issue?

$\endgroup$
1
$\begingroup$

This looks like the VkFormat being selected for the VkSurfaceFormat, most likekly VK_FORMAT_R8G8B8A8_SRGB. Try VK_FORMAT_R8G8B8A8_UNORM for the VkFormat with a corresponding colorspace (like VK_COLOR_SPACE_SRGB_NONLINEAR_KHR). That should give the dark color you are expecting.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.