<p>What the video is talking about is called <a href="https://en.wikipedia.org/wiki/Gamma_correction" rel="noreferrer">gamma correction</a> and it's a very familiar topic for graphics programmers. The first 30 minutes of John Hable's <a href="http://www.gdcvault.com/play/1012351/Uncharted-2-HDR" rel="noreferrer">talk on Uncharted 2 rendering</a> is my favorite introduction to &quot;why graphics programmers should care about gamma&quot;, as well as being a good introduction to HDR rendering. If you don't want to watch the talk (though I highly recommend it), <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html" rel="noreferrer">The Importance of Being Linear</a> is also a good article, and Charles Poynton has a <a href="http://www.poynton.com/notes/colour_and_gamma/GammaFAQ.html" rel="noreferrer">Gamma FAQ</a> that goes into more technical detail and explains the terminology used.</p>
<p>By the way, square/squareroot is only an approximation; the <a href="https://en.wikipedia.org/wiki/SRGB" rel="noreferrer">sRGB gamma curve</a> is what's most commonly used in practice (see the formulas there mentioning <span class="math-container">$C_\text{srgb}$</span> and <span class="math-container">$C_\text{linear}$</span>). See also <a href="https://computergraphics.stackexchange.com/questions/68/is-gamma-still-important-to-take-into-account">this related question</a> about gamma and color spaces. It's a bit more complicated of a topic than the video makes it sound. :)</p>
<p>To answer your specific questions:</p>
<ol>
<li><p>Yes, most image data is stored in gamma format, so the pixel values do <em>not</em> represent linear luminance. I wouldn't describe it as &quot;incorrect&quot;, since gamma encoding has the useful property of putting more values in the darks, which is better for perceptual precision (as mentioned in the video). Gamma encoding is absolutely necessary to make good-looking images with only 8 bits per RGB component; if you stored linear values you would need more like 12 bits per component to get enough precision in the darks.</p>
</li>
<li><p>To be more physically correct, when blurring an image, one should convert it to linear luminance, then do the blur (Gaussian or otherwise), then convert it back to the original color space.</p>
</li>
<li><p>The monitor accepts image data in gamma format. So the pixel values do not represent linear luminance, and the output brightness is not linearly proportional to the pixel values.</p>
<p>If it's a good-quality, calibrated monitor, then it accepts data in a specific color space such as sRGB or Adobe RGB and reproduces the colors accurately based on the definition of that color space. If it's a crap uncalibrated monitor, then who knows what you'll get, but it'll be something <em>kinda</em> like sRGB.</p>
</li>
<li><p>GPUs can be configured to do various things here. Modern GPUs have hardware support to automatically convert values between gamma and linear when sampling a texture, or storing a value out to the framebuffer, but the programmer has to explicitly enable that using an API such as Direct3D or OpenGL.</p>
</li>
<li><p>Computer graphics people certainly do know about this topic, and it's critical to get it right when building a realistic renderer for film, AAA games, and so on. However, a lot of more &quot;everyday&quot; apps like web browsers and image editors (even Photoshop, as the video mentions) don't really handle gamma correctly.</p>
<p>It's not an issue of processing power; maybe that was a problem 20 years ago, but today even mobile phones have ample processing power to convert images between gamma and linear. The reason why web browsers and image editors still don't get this right is some combination of (a) ignorance, (b) not believing that gamma is important enough to be worth getting right, and (c) simply being stuck with bad behavior because it's been that way for a long time and users have come to expect it, so they freak out if something changes.</p>
</li>
<li><p>As mentioned, we have to think a lot about gamma when building a renderer. Most computations (e.g. lighting) should be done in linear space, but the input textures and output image should be in gamma space. Also, maybe some parts of rendering such as UI compositing should happen in gamma space because it's more familiar to artists (it works more like Photoshop layer compositing and such). Also, we have to decide if internal render targets are going to be stored in linear or gamma space, as it will affect precision. And we have to get all the conversions right, so that data gets converted between linear and gamma at the right spots in the rendering process.</p>
</li>
</ol>

CC BY-SA 3.0
2016-04-04T07:12:00.370Z
You can actually turn Photoshop effects to be profile  aware its just not on by default because of backwards compatibility and least surprise for old users. Mind you though its not perfect. I would say that in general ALL of our color correction workflow is totally whacked because if the tacked on by later date nature. so for 5 i propose (d) because its hard and time consuming to rebuild a new all encompassing standard that can replace the old ones.
joojaa
CC BY-SA 3.0
2016-04-04T05:41:06.400Z
2016-04-04T05:41:06.400Z
2020-06-18T08:32:12.800Z
Nathan Reed
<p>I recently watched <a href="https://www.youtube.com/watch?v=LKnqECcg6Gw">this</a> video that talked from a physics perspective how most of the ways we deal with color on the computer is incorrect because brightness is on a logarithmic not linear scale.  Being a novice graphics programmer I want to know how to deal with the information to make my graphics even better. I figure ray-tracers but for rasterizing, blur, grading, and light adjusting like HDR what am I supposed to do with this information?</p>

<p>So I guess I have some questions. (sorry its a lot)</p>

<ol>
<li>Most texture data is stored in a format where the rgb brightness is incorrect because it has not been square rooted (right?) therefore if we want to display it correctly </li>
<li>When using textures is the gaussian formula technically incorrect? If so what would be the mathematically correct method.</li>
<li>What part of this problem is the monitor responsible for? Does it square or squareroot the values it gets?</li>
<li>What part of the problem is the GPU responsible for when you ask it to sample a color at a point? Does it square or squareroot the values it gets?</li>
<li>Do people know about this property and just not act on it because square rooting a number is an expensive computation? If so do we have a good way to quickly approximate the squareroot of numbers from 0-1?</li>
<li>How do you apply the knowledge from that video in your graphics?</li>
</ol>

<color-science><gamma>
How are we supposed to fix brightness with square roots?
J.Doe
# How are we supposed to fix brightness with square roots?

(Asked by: username_0 on 2016-04-03)

I recently watched [this](https://www.youtube.com/watch?v=LKnqECcg6Gw) video that talked from a physics perspective how most of the ways we deal with color on the computer is incorrect because brightness is on a logarithmic not linear scale. Being a novice graphics programmer I want to know how to deal with the information to make my graphics even better. I figure ray-tracers but for rasterizing, blur, grading, and light adjusting like HDR what am I supposed to do with this information?

So I guess I have some questions. (sorry its a lot)

1. Most texture data is stored in a format where the rgb brightness is incorrect because it has not been square rooted (right?) therefore if we want to display it correctly
2. When using textures is the gaussian formula technically incorrect? If so what would be the mathematically correct method.
3. What part of this problem is the monitor responsible for? Does it square or squareroot the values it gets?
4. What part of the problem is the GPU responsible for when you ask it to sample a color at a point? Does it square or squareroot the values it gets?
5. Do people know about this property and just not act on it because square rooting a number is an expensive computation? If so do we have a good way to quickly approximate the squareroot of numbers from 0-1?
6. How do you apply the knowledge from that video in your graphics?

**Tags:** color-science, gamma


---

## 1 answers

### Answer by username_1 on 2016-04-04. Score: 12 | Accepted answer

What the video is talking about is called [gamma correction](https://en.wikipedia.org/wiki/Gamma_correction) and it's a very familiar topic for graphics programmers. The first 30 minutes of John Hable's [talk on Uncharted 2 rendering](http://www.gdcvault.com/play/1012351/Uncharted-2-HDR) is my favorite introduction to "why graphics programmers should care about gamma", as well as being a good introduction to HDR rendering. If you don't want to watch the talk (though I highly recommend it), [The Importance of Being Linear](http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html) is also a good article, and Charles Poynton has a [Gamma FAQ](http://www.poynton.com/notes/colour_and_gamma/GammaFAQ.html) that goes into more technical detail and explains the terminology used.

By the way, square/squareroot is only an approximation; the [sRGB gamma curve](https://en.wikipedia.org/wiki/SRGB) is what's most commonly used in practice (see the formulas there mentioning $C\_\text{srgb}$ and $C\_\text{linear}$). See also [this related question](https://computergraphics.stackexchange.com/questions/68/is-gamma-still-important-to-take-into-account) about gamma and color spaces. It's a bit more complicated of a topic than the video makes it sound. :)

To answer your specific questions:

1. Yes, most image data is stored in gamma format, so the pixel values do *not* represent linear luminance. I wouldn't describe it as "incorrect", since gamma encoding has the useful property of putting more values in the darks, which is better for perceptual precision (as mentioned in the video). Gamma encoding is absolutely necessary to make good-looking images with only 8 bits per RGB component; if you stored linear values you would need more like 12 bits per component to get enough precision in the darks.
2. To be more physically correct, when blurring an image, one should convert it to linear luminance, then do the blur (Gaussian or otherwise), then convert it back to the original color space.
3. The monitor accepts image data in gamma format. So the pixel values do not represent linear luminance, and the output brightness is not linearly proportional to the pixel values.

   If it's a good-quality, calibrated monitor, then it accepts data in a specific color space such as sRGB or Adobe RGB and reproduces the colors accurately based on the definition of that color space. If it's a crap uncalibrated monitor, then who knows what you'll get, but it'll be something *kinda* like sRGB.
4. GPUs can be configured to do various things here. Modern GPUs have hardware support to automatically convert values between gamma and linear when sampling a texture, or storing a value out to the framebuffer, but the programmer has to explicitly enable that using an API such as Direct3D or OpenGL.
5. Computer graphics people certainly do know about this topic, and it's critical to get it right when building a realistic renderer for film, AAA games, and so on. However, a lot of more "everyday" apps like web browsers and image editors (even Photoshop, as the video mentions) don't really handle gamma correctly.

   It's not an issue of processing power; maybe that was a problem 20 years ago, but today even mobile phones have ample processing power to convert images between gamma and linear. The reason why web browsers and image editors still don't get this right is some combination of (a) ignorance, (b) not believing that gamma is important enough to be worth getting right, and (c) simply being stuck with bad behavior because it's been that way for a long time and users have come to expect it, so they freak out if something changes.
6. As mentioned, we have to think a lot about gamma when building a renderer. Most computations (e.g. lighting) should be done in linear space, but the input textures and output image should be in gamma space. Also, maybe some parts of rendering such as UI compositing should happen in gamma space because it's more familiar to artists (it works more like Photoshop layer compositing and such). Also, we have to decide if internal render targets are going to be stored in linear or gamma space, as it will affect precision. And we have to get all the conversions right, so that data gets converted between linear and gamma at the right spots in the rendering process.

> **Comments:**
> **username_2**: You can actually turn Photoshop effects to be profile  aware its just not on by default because of backwards compatibility and least surprise for old users. Mind you though its not perfect. I would say that in general ALL of our color correction workflow is totally whacked because if the tacked on by later date nature. so for 5 i propose (d) because its hard and time consuming to rebuild a new all encompassing standard that can replace the old ones.  

---

