<p>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.</p>

CC BY-SA 4.0
2021-01-22T02:27:42.860Z
2021-01-22T02:27:42.860Z
pmw1234
<p>I am following <a href="https://vulkan-tutorial.com/Introduction" rel="nofollow noreferrer">https://vulkan-tutorial.com/Introduction</a> 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:</p>
<pre><code>    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 = &amp;clearColor
    };
</code></pre>
<p>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:</p>
<p><a href="https://i.sstatic.net/IWHW1.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IWHW1.jpg" alt="enter image description here" /></a></p>
<p>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:</p>
<pre><code>VkClearValue clearColor = {0.02f, 0.02f, 0.02f, 1.0f};
</code></pre>
<p>So it almost seems like everything is shifted by a decimal. Any idea what might cause this issue?</p>

<c++><vulkan>
Vulkan clear color is wrong
Eric
# Vulkan clear color is wrong

(Asked by: username_0 on 2021-01-21)

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](https://i.sstatic.net/IWHW1.jpg)](https://i.sstatic.net/IWHW1.jpg)

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?

**Tags:** c++, vulkan


---

## 1 answers

### Answer by username_1 on 2021-01-22. Score: 3

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.


---

