0
$\begingroup$

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

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

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

enter image description here

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – lightxbulb Feb 24 at 12:20
  • $\begingroup$ 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 $\endgroup$ – gallickgunner Feb 24 at 12:29
  • $\begingroup$ 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. $\endgroup$ – lightxbulb Feb 24 at 13:26
  • 1
    $\begingroup$ 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. $\endgroup$ – Sebastián Mestre Feb 24 at 15:11
  • 1
    $\begingroup$ Yes, that is correct. Colors you feed into you equations need to be converted to linear first. $\endgroup$ – user1118321 Feb 24 at 17:06

Your Answer

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

Browse other questions tagged or ask your own question.