<p>So I read about tonemapping and Gamma Correction recently and have implemented it in my path tracer. </p>

<p>For the time being I'm using Reinhard tonemapping operator as described in his paper</p>

<p><span class="math-container">$L_d = L_w * (1+L_w/L^2_{white})/(1+L_w)$</span></p>

<p>and applying it on the luminance channel and scaling it effectively so the colors wouldn't change. I'm applying a Gamma correction of 2.2. Here is the snippet.</p>

<pre><code>float lum_world = getYluminance(hdr_col); //Find the Y channel of XYZ from RGB
float lum_display = lum_world * (1 + lum_world/(lum_white * lum_white) ) / (1+lum_world);
float4 ldr_color = lum_display *(hdr_col/lum_world); 
ldr_color = pow(ldr_color, (float4) (1/2.2) );  // Gamma correction
</code></pre>

<p>So apparently if I leave out the last step of Gamma Correction I feel I get more aesthetically pleasing images. If anybody can confirm if it's working as intended or there's something wrong. Note that I'm using OpenGL to display Images but nowhere am I using <code>GL_FRAMEBUFFER_SRGB</code> so there's no implicit gamma correction being done.</p>

<p>This is gamma corrected (Light intensities are set to 8.0f)
<a href="https://i.sstatic.net/8y7wH.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8y7wH.jpg" alt="enter image description here"></a></p>

<p>This is with tonemapping but without gamma correction. Light intensities were scaled to 18.0f. At 8.0f the image was very dark.
<a href="https://i.sstatic.net/06S7D.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/06S7D.jpg" alt="enter image description here"></a></p>

<p>For comparison here is the gamma-corrected image at 18.0f. It's just the whole image got whiter/brighter.</p>

<p><a href="https://i.sstatic.net/KwWiK.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KwWiK.jpg" alt="enter image description here"></a></p>

<p>We can see that Gamma corrected one looks washed out, shadows are much much lighter and the back wall looks outright bad. I don't know what to call it but the GI in the un-corrected image looks better.</p>

CC BY-SA 4.0
2019-02-24T12:20:36.007Z
You are supposed to use gamma correction if that is your question. You are free to play with $L_{white}$, and the scene materials/lights but if that doesn't yield the results you are looking for, then I would recommend trying a different operator.
lightxbulb
CC BY-SA 4.0
2019-02-24T12:29:15.117Z
No I know that I'm supposed to use it, it's just the result look better without it. Doing Gamma Correction just makes it too whitish. It feels unnatural. That's what confuses me
gallickgunner
CC BY-SA 4.0
2019-02-24T13:26:11.227Z
I do not understand why it confuses you. Applying gamma obviously brightens up the image, due to $a^{\gamma}\geq a^1, a \in [0,1], \gamma \in [0,1]$, for example $\sqrt{1/100}=1/10 > 1/100$. That leaves more precision for darker regions, while lighter regions get compressed, this is done in order to compensate for our imperfect monitors. If you do not apply gamma your falloff would in general look wrong (non-quadratic), and you'll have a number of other issues. If you're unhappy with the image, you should tweak materials/lighting, $L_{white}$, or just use a different operator.
lightxbulb
CC BY-SA 4.0
2019-02-24T13:28:38.640Z
On an unrelated note, do use brdf sampling + NEE MIS, if you aren't already doing so, in order to reduce the fireflies.
lightxbulb
CC BY-SA 4.0
2019-02-24T13:55:19.807Z
I'm actually using NEE but having some issues with MIS check my other question on it. https://computergraphics.stackexchange.com/questions/8444/multiple-importance-sampling-in-path-tracer-produces-dark-images

I'm gonna study about Gamma in detail in the meantime, I don't understand it correctly enough I guess.
gallickgunner
CC BY-SA 4.0
2019-02-24T15:11:31.990Z
I would recommend comparing your results with some real world images. I have a bright red wall next to a white wall in my room and i can tell that your non gamma corrected image LOOKS WRONG. It might look better to you but it does not look natural. It really comes down to whether you want physically accurate results or you prefer going with some other aesthetic.
Sebastián Mestre
CC BY-SA 4.0
2019-02-24T16:04:03.727Z
Ok, supposing I use color information from an RGB color picker online to set the values for my red/green wall. Then this means I need to un-correct them first before using in my calculations right? Since the colors I'm picking are actually Gamma-corrected?
gallickgunner
CC BY-SA 4.0
2019-02-24T17:06:01.620Z
Yes, that is correct. Colors you feed into you equations need to be converted to linear first.
user1118321
<pathtracing><color><gamma>
Path tracing - Better images without Gamma correction?
gallickgunner
# Path tracing - Better images without Gamma correction?

(Asked by: username_0 on 2019-02-24)

So I read about tonemapping and Gamma Correction recently and have implemented it in my path tracer.

For the time being I'm using Reinhard tonemapping operator as described in his paper

$L\_d = L\_w \* (1+L\_w/L^2\_{white})/(1+L\_w)$

and applying it on the luminance channel and scaling it effectively so the colors wouldn't change. I'm applying a Gamma correction of 2.2. Here is the snippet.

```
float lum_world = getYluminance(hdr_col); //Find the Y channel of XYZ from RGB
float lum_display = lum_world * (1 + lum_world/(lum_white * lum_white) ) / (1+lum_world);
float4 ldr_color = lum_display *(hdr_col/lum_world); 
ldr_color = pow(ldr_color, (float4) (1/2.2) );  // Gamma correction

```

So apparently if I leave out the last step of Gamma Correction I feel I get more aesthetically pleasing images. If anybody can confirm if it's working as intended or there's something wrong. Note that I'm using OpenGL to display Images but nowhere am I using `GL_FRAMEBUFFER_SRGB` so there's no implicit gamma correction being done.

This is gamma corrected (Light intensities are set to 8.0f)
[![enter image description here](https://i.sstatic.net/8y7wH.jpg)](https://i.sstatic.net/8y7wH.jpg)

This is with tonemapping but without gamma correction. Light intensities were scaled to 18.0f. At 8.0f the image was very dark.
[![enter image description here](https://i.sstatic.net/06S7D.jpg)](https://i.sstatic.net/06S7D.jpg)

For comparison here is the gamma-corrected image at 18.0f. It's just the whole image got whiter/brighter.

[![enter image description here](https://i.sstatic.net/KwWiK.jpg)](https://i.sstatic.net/KwWiK.jpg)

We can see that Gamma corrected one looks washed out, shadows are much much lighter and the back wall looks outright bad. I don't know what to call it but the GI in the un-corrected image looks better.

**Tags:** pathtracing, color, gamma

> **Comments:**
> **username_1**: You are supposed to use gamma correction if that is your question. You are free to play with $L_{white}$, and the scene materials/lights but if that doesn't yield the results you are looking for, then I would recommend trying a different operator.  
> **username_0**: No I know that I'm supposed to use it, it's just the result look better without it. Doing Gamma Correction just makes it too whitish. It feels unnatural. That's what confuses me  
> **username_1**: I do not understand why it confuses you. Applying gamma obviously brightens up the image, due to $a^{\gamma}\geq a^1, a \in [0,1], \gamma \in [0,1]$, for example $\sqrt{1/100}=1/10 > 1/100$. That leaves more precision for darker regions, while lighter regions get compressed, this is done in order to compensate for our imperfect monitors. If you do not apply gamma your falloff would in general look wrong (non-quadratic), and you'll have a number of other issues. If you're unhappy with the image, you should tweak materials/lighting, $L_{white}$, or just use a different operator.  
> **username_1**: On an unrelated note, do use brdf sampling + NEE MIS, if you aren't already doing so, in order to reduce the fireflies.  
> **username_0**: I'm actually using NEE but having some issues with MIS check my other question on it. https://computergraphics.stackexchange.com/questions/8444/multiple-importance-sampling-in-path-tracer-produces-dark-images  I'm gonna study about Gamma in detail in the meantime, I don't understand it correctly enough I guess.  
> **username_2**: I would recommend comparing your results with some real world images. I have a bright red wall next to a white wall in my room and i can tell that your non gamma corrected image LOOKS WRONG. It might look better to you but it does not look natural. It really comes down to whether you want physically accurate results or you prefer going with some other aesthetic.  
> **username_0**: Ok, supposing I use color information from an RGB color picker online to set the values for my red/green wall. Then this means I need to un-correct them first before using in my calculations right? Since the colors I'm picking are actually Gamma-corrected?  
> **username_3**: Yes, that is correct. Colors you feed into you equations need to be converted to linear first.  

---

## 0 answers

