<p>Short answer, set the precision of the image to a higher value.</p>

<p>Long answer,</p>

<p>When looking at a gamma correction curve, you can see that the lower values get changed much more, this means that the difference between lower values will get greater and that causes this effect. You have a limited amount of values for a color channel and this means that when it rounds the number down to the 8 bit value, it makes some neighboring pixels the same color. You don't notice this in a normal image, but after gamma correcting it this effect comes out, because you lose that bit of change in the color that later on can become a much bigger difference in color.</p>

<p>To fix this, you just give the gamma correction more precision to also get that small color change it would've else rounded away.</p>

<p>In the actual shader, it has floating point color information and that means that it has more precision and thus not the weird artifact.</p>

<p>So when making the frame buffer, you can use for example GL_RGBA16F or GL_RGBA32F. This would increase the precision and remove the artifact.</p>

<p>I hope that this can help you fix the problem, good luck and have a great day!</p>

CC BY-SA 3.0
2017-02-12T20:46:53.437Z
I was suspicious of precision problems, only I was looking at compression until I got overwhelmed. Thank you so much, this helped me fix it.
V.M.
CC BY-SA 3.0
2017-02-12T19:46:23.880Z
2017-02-12T19:46:23.880Z
bram0101
<p>Doing post-process gamma correction is showing texture artifacts, here is a small example on a skybox:</p>

<p><a href="https://i.sstatic.net/HAqRT.jpg"><img src="https://i.sstatic.net/HAqRT.jpg" alt="Correction on Skybox vs Post Process"></a></p>

<p>The first image is gamma correcting on the skybox shader and seems correct, the lower is doing it in post-process and has terrible artifacts near the edges of the clouds, however both versions do it the same usual way:</p>

<pre><code>Color.rgb = pow(Color.rgb, vec3(1.0/2.2));
Color.a = 1.0;
</code></pre>

<p>So that makes me believe there's something wrong with the way I'm creating and using frame buffers, here's sort of how I'm doing it:</p>

<pre><code>// Generate FirstFBO, specify this as the color attachment
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, FramebufferSize.x, FramebufferSize.y, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); 

// ...

while (true) {
    glBindFramebuffer(GL_FRAMEBUFFER, FirstFBO.ID);
    DrawStuff();

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glBindTexture(GL_TEXTURE_2D, FirstFBO.ColorTexture);
    DrawFullscreenQuad();
}
</code></pre>

CC BY-SA 3.0
2017-02-13T09:53:15.420Z
I actually posted a relevant answer on a more general SO question. http://stackoverflow.com/questions/12524623/what-are-the-practical-differences-when-working-with-colors-in-a-linear-vs-a-no/12894053#12894053
Dan Hulme
<c++><gamma><artifacts><post-processing><frame-buffer>
Artifacts when gamma correcting
V.M.
# Artifacts when gamma correcting

(Asked by: username_0 on 2017-02-12)

Doing post-process gamma correction is showing texture artifacts, here is a small example on a skybox:

[![Correction on Skybox vs Post Process](https://i.sstatic.net/HAqRT.jpg)](https://i.sstatic.net/HAqRT.jpg)

The first image is gamma correcting on the skybox shader and seems correct, the lower is doing it in post-process and has terrible artifacts near the edges of the clouds, however both versions do it the same usual way:

```
Color.rgb = pow(Color.rgb, vec3(1.0/2.2));
Color.a = 1.0;

```

So that makes me believe there's something wrong with the way I'm creating and using frame buffers, here's sort of how I'm doing it:

```
// Generate FirstFBO, specify this as the color attachment
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, FramebufferSize.x, FramebufferSize.y, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); 

// ...

while (true) {
    glBindFramebuffer(GL_FRAMEBUFFER, FirstFBO.ID);
    DrawStuff();

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glBindTexture(GL_TEXTURE_2D, FirstFBO.ColorTexture);
    DrawFullscreenQuad();
}

```

**Tags:** c++, gamma, artifacts, post-processing, frame-buffer

> **Comments:**
> **username_1**: I actually posted a relevant answer on a more general SO question. http://stackoverflow.com/questions/12524623/what-are-the-practical-differences-when-working-with-colors-in-a-linear-vs-a-no/12894053#12894053  

---

## 1 answers

### Answer by username_2 on 2017-02-12. Score: 6 | Accepted answer

Short answer, set the precision of the image to a higher value.

Long answer,

When looking at a gamma correction curve, you can see that the lower values get changed much more, this means that the difference between lower values will get greater and that causes this effect. You have a limited amount of values for a color channel and this means that when it rounds the number down to the 8 bit value, it makes some neighboring pixels the same color. You don't notice this in a normal image, but after gamma correcting it this effect comes out, because you lose that bit of change in the color that later on can become a much bigger difference in color.

To fix this, you just give the gamma correction more precision to also get that small color change it would've else rounded away.

In the actual shader, it has floating point color information and that means that it has more precision and thus not the weird artifact.

So when making the frame buffer, you can use for example GL\_RGBA16F or GL\_RGBA32F. This would increase the precision and remove the artifact.

I hope that this can help you fix the problem, good luck and have a great day!

> **Comments:**
> **username_0**: I was suspicious of precision problems, only I was looking at compression until I got overwhelmed. Thank you so much, this helped me fix it.  

---

