what is Gamma Correction



  • SertorialSertorial Posts: 962
    edited December 1969

    Ok, many thanks everyone. I think I am more or less ok with this now.

  • SzarkSzark Posts: 10,633
    edited December 1969

    took me a long time to get me head around this and it still puzzles me sometimes as with my recent project I had to turn the lights down when GC was turned off and set to 1.00. I was expecting to turn the lights up. ;)

  • mark128mark128 Posts: 1,027
    edited July 2014

    Here is my understanding of the gamma. I may have some of this confused, so if there are real experts, let me know. This is based on my experience in photography and with DAZ Studio. I am now using gamma 2.2 for almost everything I render.

    The human eye is an amazing sensor with a very wide dynamic range. We perceive light brightness sort of on a logarithmic scale so we can accommodate such a wide range. High end digital cameras have sensors that record light intensity linearly and they use 14 bits to encode the linear intensity of each color. This can represent linear intensities from 0 to 16383 for each color. While this is good, it is not as good as the human eye. High end cameras have a RAW output option that allows you to save the data in this format without any manipulation, although most consumers do not use this format.

    The monitors that everyone uses today only have 8 bits per color per pixel. If this were interpreted linearly, then this would only allow intensities from 0 to 255 at each pixel and that would be very poor dynamic range. The jpg format also uses 8 bits per color per pixel. To avoid this poor dynamic range, jpg formats uses a non-linear intensity scale with a gamma of 2.2. This compresses a wider dynamic range of intensities into the range of numbers between 0 and 255.

    Your monitor is supposed to be calibrated to gamma 2.2 so it expands the dynamic range back out. Your eye then gets the full range of intensities that are intended.

    Rendering engines like 3Delight or LuxRender I think work internally in linear intensities when they do their computations. The gamma value is applied to the image at the end when it is converted to a graphics format. If you use gamma 1.0, then you will have a reduced dynamic range in your image. The difference is you are not taking a picture of the real world. You can make up for the reduced dynamic range of your output image by changing the lighting. If you increase the lighting in the shadows and less well lite portions of the image, the result can still look normal or even photographic.

    The render engines are trying to model how light behaves. Unbiased engines like LuxRender try to model the behavior of light in the real world very closely. 3Delight takes some shortcuts to speed up rendering, but it can be used to model how real lights behave. To make a gamma 1.0 scene look natural you need to add a lot of artificial light to compress the dynamic range of the lighting. Some of the old dream works light sets use a lot of distant lights coming from all different directions with shadows turned off to create this added environment lighting. UberEnv2 is the environment light that comes with DAZ Studio. It can do ambient occlusion which makes the fake environment lighting look less fake. The AoA Advanced Ambient light can do the same thing (only faster).

    When you use gamma 2.2 with 3Delight you do not need as much fake light because you now have more dynamic range. The shadows and less well lite parts of the image look brighter when only illuminated with raytraced lights and/or lights with real distance squared intensity fall off. You still need some fake lighting, because 3Delight does not raytrace exhaustively like an unbiased render engine, but you can use a lot less fake environment lighting.

    Because you need less fake environment lighting, it is easier at gamma 2.2 to get lighting that looks realistic. You need to use real raytraced lights for most of your lighting and of course you have to have good materials that render realistically.

    I believe this is why gamma 2.2 is preferred for rendering realistic images.

    Post edited by mark128 on
  • Takeo.KenseiTakeo.Kensei Posts: 1,303
    edited July 2014

    @Mark128 : You are making confusion. You have some parts right and some are wrong but all is mixed and not all is related to gamma

    Forget everything about 8/16 bit, dynamic range, fake light and render engines

    All render engine will calculate in linear space. No exception and no difference between 3delight, Luxrender or any other
    The main difference between 3delight implemented inside DS and Lux is that one is using Reyes/old raytrace methods and the other is a pathtracer with many different algorythm which make render calculations more accurate. But that is not true since 3delight v11 in the way it is implemented in Maya or Softimage. These 3D modelers now have access to path tracing with physically plausible shaders with 3delight

    Now for the topic
    The Gamma correction should only be done on color textures or data (Diffuse and eventually SSS color Map, Environment HDR map, reflection map ). You don't need to do it on Strength map or Control map (opacity for example). The goal is to get accurate colors out of the renderer, but you have to feed it correctly

    The pipeline is something like that :

    Color map -> Correction to linear space -> Calculation by the renderer
    The output of the Renderer is at Gamma 1 (linear space)

    From there you have two choice :

    1°/ You know that you will have other operations on the resulting image like tone mapping, special effects, combining with other pictures/video at gamma 1, etc...
    You keep the output image at Gamma 1 and do all theses operations and will only retrieve the final picture later on at the specific gamma of the display device

    2°/ The output image is your final render or you want to see the resulting picture
    Then you have to correct the gamma according to the display device (your monitor usually)

    The gamma is a way to correct the non linearity of capturing or display device. The REC709 and sRGB norms resulted from that. The 2.2 Gamma value is the standard which was chosen because LCD monitors and other device are built with a known deformation of light intensity which is a logarithm of 2.2 (not really but for the sake of simpleness we'll say that it is true). So Output Intensity = Log ( Input). Not all device have a gamma at 2.2

    So In practice what does it mean ?

    Example : I have two lights illuminating a scene with different intensities

    At a point P
    L1 = 0,5
    L2 = 0.1 (whatever unit)

    In linear space : the resulting light at this point is L1 + L2 = 0,6

    Let's say your camera has a gamma of A and the function is LogA
    Without the correction, your Camera will capture following intensities :

    L1 + L2 = LogA (L1 + L2)

    Let's say you further not correct your Gamma and you display it on a Monitor which has a gamma of B and thus displays intensities following a LogB functions,

    The displayed intensity at point P will be

    L1 + L2 = LogB ( LogA (L1+ L2) )

    => double error

    At this point it is clear that without gamma correction on the devices we wouldn't be able to see the same colors
    And without color correction, the color you pick (when choosing a light color for example) will not be the one given to the renderer for calculation
    The cameras can output RAW image which have no gamma correction but the output should be corrected later on specifically to the properties of the camera

    Finally, the 2.2 Gamma is not an absolute rule. You can choose to output to a chosen gamma for artistic purpose in order to get more or less contrast.
    So in DS, you can activate GC ON to get the correction. But then you choose the output gamma in the render settings according to YOUR taste or according to your pipeline if you want some post treatments. For example, I read somewhere that Mac have (or had) monitors with gamma 1.7-1.8. If you paint/postwork on such a monitor you would output an image at gamma 1.7-1.8, do your things, and then correct the gamma to 2.2 to display on an other LCD or TV

    Post edited by Takeo.Kensei on
  • MEC4DMEC4D Posts: 5,245
    edited December 1969

    It is assumed that 100% mean 1kW , from my long research for many years it seems like it is .. Gamma correction is to set the balance between the dark and light area for more details and higher range of gray scale .. brilliant colors and more clear details

    using 2 lights on 100% on an object will overexpose the surface and colors, gamma correction will find the right balance even if the light is screwed up .. the best result is to have all your light in the scene resulting =100% and you will not need gamma correction

    Another interesting twist, lol.

    Mec4D said:
    There is a difference between gammas and I see Szark getting really confused :) lol
    If you create art on your computer your monitor need to be calibrated to match the printing as much as possible
    you can do that manually using windows calibration or use a special device . Most of the monitors are NOT 2.20 but simple 1.00
    to have a 2.20 gamma your monitor would have a wide gamma and it is expensive one .

    The gamma correction in Daz Studio is a compressor that correct the curve of the image for the best result .
    if you use Gamma correction ON , your gamma should be set on 2.0 ( for the wide range )
    if not the gamma should be set on 1.00 so the correction can be done for example in Photoshop

    Usually the Gamma correction suppress the highlight preventing it from ( burning the colors - over-exposure ) as it is in photography
    mostly all color textures are shot with gamma 1.0 and the Gamma correction ON in DS with the Gamma set on 2.0 will prevent it from overexposure especially if you use to much light in the scene

    for example if you use UE2 with base light and add one more distance or spot light the image would be automatic over exposed as the power of the light will end in double , since 100% value of light usually is 1000 Wat so you ending with 2000 W straight in the face what call for Gamma correction ! or reducing in power light ..
    thanks to Gamma correction ON and Gamma 2.0 the render will be compressed and overexpose reduced ending with a brilliant color and balance

    so each light at 100% is equivalent to 1kW? or was that an arbitrary number for the sake of understanding the concept (Using Gama Correction to counter two much light in the scene)?

    We doubled.
    I'm using whatever 3Delight came with DS ("O", it updated from 50).

  • Richard HaseltineRichard Haseltine Posts: 70,477
    edited December 1969

    Gamma Correction is, as noted, an adjustment to the way the tones are used to better accommodate the human eye. It has nothing to do with balancing lights, though of course a scene lit to look OK at Gamma 1 will be over-lit at Gamma 2.2 (which is why several posts have mentioned adjusting the lights).

  • MEC4DMEC4D Posts: 5,245
    edited December 1969

    Gamma correction controls the overall brightness of an image. Images which are not properly corrected can look either bleached out, or too dark. Trying to reproduce colors accurately also requires some knowledge of gamma. Varying the amount of gamma correction changes not only the brightness, but also the ratios of red to green to blue

    so it have a lot to do with balancing the light and brightness .. especially if using HDR light maps
    other way who will need it and for what .. other than balance the right tones in your render..
    it also affect very much the specular level

    bellow simple test.. Gamma 1 no correction with 2 x 100% distance light
    you use the render is over exposed
    now second render with Gamma 1 correction ON.. as you see the brightness of the light is adjusted

    that what Gamma correction do and that was a question of the thread subject ..
    if you set it to 2.2 or whatever have nothing to do with the subject .. as that are values to be adjusted to taste and expected result
    of the render but that is not an answer to the question about WHAT GAMMA CORRECTION IS in this case ..

    so you answer was regarding the values of Gamma and not about Gamma correction ..
    as you see in my quick test the light was balanced down from over exposed ..
    better results are with HDR light maps ..

    so when you have Gamma correction ON, you can play with the Gamma values to give you the best result .. it can reduce the brightness of the image overall if you have to much light source or make it brighter when there is not enough light in the scene.. that is what the function is for ..

    Gamma Correction is, as noted, an adjustment to the way the tones are used to better accommodate the human eye. It has nothing to do with balancing lights, though of course a scene lit to look OK at Gamma 1 will be over-lit at Gamma 2.2 (which is why several posts have mentioned adjusting the lights).
    1290 x 899 - 445K
  • Richard HaseltineRichard Haseltine Posts: 70,477
    edited December 1969

    Yes, gamma can of course be used to balance lighting - but that isn't "what it is". And the Gamma Correction switch affects textures, not whether a final gamma correction is applied to the render - in your case, it's removing the Gamma 2.2 in your textures (you'll notice that the plain ground colour has not changed between the two renders).

  • MEC4DMEC4D Posts: 5,245
    edited December 1969

    but it changed the background color what is weird ...so not just the textures
    it change the plain ground when using HDR light maps as well , so not just the textures
    it depend also on the level of specular and the plain ground has the specular set off ..

    anyway it works for me as it should

    Yes, gamma can of course be used to balance lighting - but that isn't "what it is". And the Gamma Correction switch affects textures, not whether a final gamma correction is applied to the render - in your case, it's removing the Gamma 2.2 in your textures (you'll notice that the plain ground colour has not changed between the two renders).
Sign In or Register to comment.