Search Unity

[Unity5]Linear Color space looks bad

Discussion in 'General Graphics' started by Jymmy097, Mar 30, 2015.

  1. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Hi everybody,

    I'm using linear color space and, after having baked lightmaps, I get those lines. Yes, they can be seen clearly just with a high screen brightness, but, as it's been told me that the linear color space is more realistic, I would like to get rid of those artifacts. Does anybody know a solution for this problem?

    Thanks a lot!!

    PS: I have direct3D11 enabled, I know that it can cause problems... Why? Shouldn't it be more advanced?

    Gianmarco Lusvardi
     

    Attached Files:

  2. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Jymmy097
    Are you using compressed lightmaps?..if so, turn it off
     
  3. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Thanks a lot.
    I've noticed that I have the same bug, also in gamma space and with both lightmapped and non-lightmapped rooms (I tried to delete baked data, nothing changes).

    What could it be?

    Thanks a lot!

    Jymmy097
     
  4. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Jymmy097
    it isn't a bug... it is file compression. Lightmaps take up a lot of space. Compression is used to make these smaller, but results in a decrease in color depth for the lightmap. This is a tradeoff (File size vs Quality).

    Think of it like a mp3... the more you compress a wav file, the worse the quality of the sound will be, but the file will be much smaller in size.
     
    theANMATOR2b likes this.
  5. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Well,
    First of all thanks a lot for your replies, but I experimented the same problem creating a new project.
    This is what I did:
    1. I've created a new project
    2. Added a plane
    3. Added a FPSController
    4. Deleted default light
    5. Switched to Color Ambient light and set it to (30,30,30)
    6. Played (first "Problem_gamma.jpg")
    7. Switched to Linear color space (second "Problem.jpg")
    8. Added a point light (I do not remember whether I was in Linear or Gamma space, I think Gamma, anyway, third "Problem_point.jpg")
    9. Tried to disable Direct 3D11: few minor changes which did not touched my problem
    10. Tried to use Deferred Lighting: few minor changes which did not touched my problem
    That's all...
    I've tried on my brother's PC (by compiling it with my Unity) and the result is always the same....
    I haven't lightmapped anything on that project.
    I noticed that the problem can be shown if the scene is very dark (as I would like my scene to be)
    :(:(

    Have you got any ideas?
    Thanks a lot!!

    Jymmy097

    EDIT: sorry, forgot to attach images, you can see that, whenever I switch to Gamma to Linear color space, or vice versa, an error is shown: it is about a Peek operation on a stack... I think it regards editor, but I'm not so sure...
     

    Attached Files:

  6. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Anyway, I've uncompressed my lightmaps in the project: the problem persists. (To uncompress them: Lighting->Scene->Baked GI -> Uncheck Compressed & Build again!). Right?

    Thanks.
     
  7. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Are you rebuilding the maps after you change the color space? Post a screenshot of your lighting window... it is difficult to follow without being able to see your lighting settings.
     
  8. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Ok, sorry for the late reply, but here it is:

    1. I've created a new project and set the lighting mode to be Deferred and Gamma
    2. Then changed the Ambient Light to (30,30,30)
    3. Removed Directional light and added a plane and a FPScontroller
    4. Played (Problem.jpg)
    5. Added a point light at a certain distance from the plane (about 7)
    6. Played (Problem_PointLight.jpg)
    7. Set Plane to be static, baked Lightmaps with settings shown in Problem_Lightmap.jpg
    8. Nothing changes from 4, anyway the screenshot is Problem_LightmapBakedWithStaticPlane.jpg
    9. Changed to linear color space (awful result: Problem_LinearColorSpace.jpg)
    PS: I've noticed that, even if I've baked the lightmaps with the plane set to be full static, Unity does not generate any lightmaps, just reflection probes of Skybox.
    EDIT: As far as I've seen, this message seems not to accept any more attachments, so I'll attach those settings in the next one you can find here.
    PS2: Is this problem normal for really dark scenes? I'm asking this because the behaviour you can see on the plane is reflected to all "light edges" so they seem sawtooth gradients and they are A.W.F.U.L.

    Ed

    Thanks a lot for your help!

    Gianmarco Lusvardi
     

    Attached Files:

  9. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Here's the files:
     

    Attached Files:

  10. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Quick question: what platform are you targeting? If you are indeed targeting PC, You need to leave DX11 on!
    Also check your quality settings. I am going to try to reproduce what you have posted.

    EDIT: I think I know what is going on, you still are reflecting the skybox. You need to 1) Decrease the smoothness of the material on the plane, or 2) Change the skybox to another, or you could remove it altogether.

    That said, If you assign a proper material to the plane with a texture, I doubt you will see what you are now.
     
    Last edited: Mar 31, 2015
    theANMATOR2b likes this.
  11. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Hi,

    Yes, you're right: I'm reflecting the skybox.... As soon as I can I'll try to
    • Change the skybox (as the default one is not what I need for my dark scene)
    • Change the smoothness of the plane.
    Can a reflection probe solve the problem if the entire scene is occluded by walls, right? In order to replace skybox reflection with the proper one, isn't it?

    Thanks a lot for your help: now I have to go to school, but I'll try your solution as soon as I can!
    Thanks again!!

    Lusvardi Gianmarco
     
  12. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Well,
    If I play with parameters, I get nicer results, yes, not perfect, but nice, in general.
    I've changed the Skybox in my scene: now everything looks ok, in the gamma space, I still have some problems in the linear color space: if I go near textures on the walls, where the light is more reflected on, I can see some almost imperceivable artifacts (I will make a screenshot as soon as I can).

    So, many thanks for your help, I've needed it!

    PS: I've attached a screenshots where the problem has disappeared.

    Just the final question: if I disable the Continuous Baking I get darker results in my scene and when I bake the lightmap, it is much brighter than before... Is this problem due to the fact that I've switched off Continuous baking before changing the lightmap?

    Thanks again!

    Lusvardi Gianmarco
     

    Attached Files:

  13. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    From the screenshot above, I don't see much of anything but a textured wall? The lighting on it looks ok, but you are very close to it.

    You need to quit changing color spaces so often - choose one and stick with it. Gamma and Linear space use a very different falloff for light, so what looks good on one is almost guaranteed to look awful on the other. If you are going for PBR, use linear and remember that linear cannot be used on mobile platforms at this time. This is a good explanation of the differences you can expect in spaces:
    http://docs.unity3d.com/Manual/LinearLighting.html

    As for baking, I have made a very large thread about this - and I think it may be due to internal bugs that have been fixed in a yet unreleased version. The thread is here:
    http://forum.unity3d.com/threads/realtime-vs-baked-lighting-inconsistent-results.307962/

    The status on the bug leads me to believe that is has been fixed:
    http://issuetracker.unity3d.com/iss...roken-or-significantly-different-from-4-dot-6

    You are correct. In gamma space, point lights do indeed appear brighter when baked vs realtime. Oddly enough, they appear to not have this discrepancy in the linear color space. I suspect that internal tweaks done to lighting for PBR applications results in erroneous intensity values when baking in gamma space only.

    As a workaround, I would just work in real-time until v 5.0.1 has been released. I am guessing it will be here sometime this week. We can test baked lighting at that time.

    Best of luck.
     
    Last edited: Apr 1, 2015
    theANMATOR2b likes this.
  14. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Did you try turning off compression here?
     

    Attached Files:

  15. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Yes, I did. I turned it off.

    EDIT: Added screenshot: this is how Linear Color space looks like... I've tried to play with material smoothness/metaless, but the problem does not go away. That's a pity because the other parts of the scene look good.

    Thanks for your help...
    Lusvardi Gianmarco.
     

    Attached Files:

    Last edited: Apr 1, 2015
  16. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
  17. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    Hey,

    Do you get the same results in a build or is it only in the editor window ?
     
  18. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Hi,

    Yes. I've this problem in a build too. Here's a screen.

    I can see the problem in really dark areas.

    Thanks!

    Lusvardi Gianmarco
     

    Attached Files:

  19. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    What are your quality settings like?.... that looks compressed to me.
     
  20. Charkes

    Charkes

    Joined:
    Apr 17, 2013
    Posts:
    228
    It looks like a nasty color banding to me like rendering buffer has not enough precision. Are you using an HDR camera ? Tonemmaper ?
     
  21. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Mmmhhh, I do not know if my camera is marked as hdr... I used default settings... I do not know what Tonemapping does, I did not use it... Just antialiasing... I will check whether I have hdr enabled... Speaking about antialiasing, could somebody tell me why the antialiasing in the quality section does not seem to do anything? Or it is just my impression/problem. I used image effects to solve the problem

    Well, I am sure that it is not compressed. I have double checked it.I have also tried with compression, and almost nothing changes...

    Many thanks to everybody.

    Jymmy097
     
  22. Brad-Newman

    Brad-Newman

    Joined:
    Feb 7, 2013
    Posts:
    185
    Like Charkes said, it seems like a floating point precision issue when HDR isn't enabled on the camera. I was experiencing the same banding artifacts in Linear space and enabling HDR on a camera fixed the issue in both the Game and Scene views.
     
    theANMATOR2b likes this.
  23. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Ok... Unity 5.2.0:
    1. Enabled Deferred Rendering Path
    2. Use Linear Color Space
    3. Enable HDR on Camera
    => It looks far better!
     

    Attached Files:

    • NoHDR.jpg
      NoHDR.jpg
      File size:
      22.7 KB
      Views:
      1,473
    • HDr.jpg
      HDr.jpg
      File size:
      21 KB
      Views:
      1,226
  24. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    PLEASE, don't save screenshots in jpeg, use lossless 24/32-bit png instead, so we could see exactly what you see, without jpeg compression artifacts.
     
  25. Jymmy097

    Jymmy097

    Joined:
    Jul 7, 2014
    Posts:
    67
    Sorry... I did not pay attention when I saved them... Anyway that's more or less like what I see: a huge improvement!
     
  26. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    You can't get rid completely of these "lines" between areas with different brightness. It's a hardware limitation: 24-bit RGB / 8 bit per channel. Our eyes have greater resolution and can spot the difference between, say, RGB (30;30;30) and (31;31;31). That's why we see those lines. The only thing you can do to hide them, is to apply a noisy texture to the surfaces.

    However, since the screenshots are in jpeg, it's impossible to check what the exact RGB values are on the pictures.
     
  27. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Here's some more examples. The editor view is different from the camera's view:

    1. Linear
    2. Gamma
    3. Linear - Camera non HDR
    4. Linear - Camera HDR (fixes banding in Game view, but brightens Baked view)
     

    Attached Files:

  28. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    There must be a way to fix it in the engine. Unreal Engine appears to be doing something interesting to avoid this problem. And it is a glaring problem for me because my current project is low light and uses basically no textures. And in VR it gets even worse.

    I saw Carmack complaining about it as well.

    Look at the screenshot. Looks the same with any settings. And in UE4 it looks perfectly smooth.


    EDIT: Fixed most of the ugliness with a subtle fine noise detail texture.
     

    Attached Files:

    Last edited: Aug 2, 2016
  29. bravo075

    bravo075

    Joined:
    Dec 7, 2012
    Posts:
    32
    If I ever see you in person I will kiss you, I've been struggling with this for so long... man!
     
  30. Deleted User

    Deleted User

    Guest

    Having a similar issue since upgrading from 5.6 to 2017.



    In my case turning HDR off on the camera seems to fix the ugly banding?
     
    led_bet likes this.
  31. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    I Unity 5.6 or later they fixed a lot of banding by applying some sort of dithering to the shading.

    @kvekos, no wonder HDR has more banding. HDR stretches the scale much farther so there are less intermediate tones and more pronounced banding.
     
  32. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Excuse my dragging this thread back from the dead, but has there been any headway on this issue?

    I'm having the exact same problem in 2017.3, using deferred rendering, linear space, and uncompressed light maps (even disabling baked maps entirely does nothing)..

    Here are screenshots from both deferred




    and forward (notice the smooth light fall off compared to the ugly striping found in deferred):