Search Unity

Moving from Gamma to Linear Color Space?

Discussion in 'General Graphics' started by moco2k, Sep 17, 2015.

  1. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Hey everyone,

    I've started a project using gamma color space (target platforms Windows, Mac, Linux).
    I have a lot of scenes finished already and I have to say that I am quite happy with the lighting as it is now, using the gamma space.

    Recently, however, after reading through some literature, it seems that linear space is superior to gamma space, especially when it comes to HDR rendering. So I thought about moving from gamma to linear color space. Of course, the basic goal is to at least retain the visual quality as it is now and, if possible, further improve it.

    After my first attempts to change to linear space, the lighting seems to be much stronger after changing and I find myself in need to change all the lights to get similar visual results as before. In addition, I found that some textures are rendered very different and look worse than before. While I do not understand all the things going on so far, I presume that this issue is related to the shaders. I guess that I might need to change some of the shaders to get comparable and pleasant results. Can someone confirm this? Do I need to use standard shaders with linear space, where I used different legacy shaders before? Are there other aspects I need to consider?

    At the end of the day, I am wondering if this step is worth all of the effort and if I can expect to receive the same or even better visual results as before with some tweaking? This would actually mean that going linear space would be a win in the long run, even it it requires some effort to change all the lights now.

    Or, do I need to expect that visual quality and lighting will be just different using linear space but not necessarily better in any case? If so, it would also be reasonable to just leave things as they are, especially because I am quite happy with them.

    Thanks for your help!
    moco
     
    Last edited: Sep 25, 2015
  2. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    *bump*
     
  3. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Cant help you but I'm wathcing threads like this now. We're just starting to look at visuals and lighting and I'd always been using gamma. I guess thats a +1 for Linear if you're just sarting out :)
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If you use Linear and HDR, it is *not* optional to ignore tone mapping. HDR cannot be displayed by the monitor, so it looks all bright and washed out. This is why you use tone mapping to convert HDR into LDR.
     
    moco2k and theANMATOR2b like this.
  5. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    322
    Hey moco2k, we've just made this shift in Hurtworld. We've found it's given us much better looking lighting, crisper shadows, etc. Note however that we had to do some custom magic to tree shaders, and a lot of tweaking to our post-fx pipeline.

    Generally, we found with texturing that things looked worse because we had been attempting to correct for the effects of gamma. We did have to tweak textures - something to look out for is bypassing sRGB in the import settings. This proved necessary for a few instances, like where we're storing data in textures, not images. Overall it has made the texture pipeline for our artists easier, as things end up more 1:1.

    Definitely use standard shaders, imo. Legacy is called that for a reason. Those lighting models just can't compete.

    Although at the end of the day, as with all game dev, only do it if it's worth it. You say you're happy with the lighting - well then, you probably shouldn't mess with the lighting. You get no brownie points from the player for technical semantics. The only thing that matters is the end result.
     
  6. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Thanks for your valuable information hippocoder and cowtrix, this will help.
     
  7. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I'm using linear, deffered, HDR and Scion, but I use the scion variant without tonemapping because I thought it looked better. The one with tonemapping tendet to look a bit overexposed in the bright areas. Am I doing it wrong? Is there a compelling reason why I should use Scion with filmic tonemapping and try to adjust the tonemapping white point and other parameters to get the visual result I want? I am not going for a photorealistic look by the way, more like retro pixel with highend postfx underneath.
     
  8. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    This seems familiar to me.

    Yesterday, I tried to convert a scene to linear mode which I had started in gamma mode. This was after reading (again) in a documentation of a bloom asset that using gamma mode is one of the biggest mistakes one could make. Hmm... of course, I don't want to do such a big mistake. Anyway, the thruth is that I really like the lighting and colorization for my scene as it is in gamma mode. So this is my reference and I started trying to achieve same results in linear mode. After one hour of tweaking, I found that I could get a quite similiar result in linear mode. This required me to change most lighting values like color, range and intentisy. However, at the end of the day, somehow I still did not felt completely satisfied. I don't know. Some things seemed to be better in linear, like bright HDR spots, and shadows seemed to be more precise. However, I quite liked the more washed out and diffuse look of the gamma shadows. Also, some stone textures looked clinical, artificial and sterile in linear mode. Maybe this is not the fault of the linear color space, but more of the texture though. I guess all decisions, pro and con, also strongly depend on the kind of scene, targeted art design, and so on... What's good of a bright day scene may not work as good in a dark underworld dungeon.

    Is using gamma mode really the biggest mistake you can make? I don't know yet.
    What I know, however, is that I want to be happy with the results.
    I guess I need to do more experiments and visual tweaking on this to find out what's right for my game.
     
    ice2011 and protopop like this.
  9. G-Mika

    G-Mika

    Joined:
    Jul 17, 2012
    Posts:
    99
    @moco2k

    Gamma space are OK if you are not using HDR, but if you use HDR super bright colors won't looks right. Linear space is more numerically correct because there is not a strange gamma curve applied to colors and values when lighting is computed, and they are read as they should be. Sure, Gamma space can look good because introduce a contrasted look but this is fixed with something else when using linear space.

    Linear space won't make your scene look better by itself simply because there is not enough precision on your screen to show all the range of the HDR colors. This will introduce a foggy kind of look, and you must either fix it with a contrast oriented tonemapper (better) or with Color Grading (OK, but has precision issues). This is explained a bit more on my filmic tonemapping asset thread here:
    http://forum.unity3d.com/threads/fi...-now-with-eye-adaptation-high-quality.315636/
     
    theANMATOR2b and moco2k like this.
  10. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Thanks for your input and information. I will definitely try the filmic tonemapping.