Search Unity

Unity 5: Light Leaks at UV seams

Discussion in 'Global Illumination' started by essimoon2, Mar 19, 2015.

  1. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Hi all,

    after baking a couple of scenes in Unity 5 I noticed a persistent problem: At edges where the lightmap uvs are split there are notable light leaks. It looks light blank space of the lightmap (->black) bleeds into the texture space occupied by the uv2s. I tried to increase final gather but it didn't solve the issue.

    Any ideas how I can prevent this, or is it possibly a bug and can be fixed by dilating lightmaps?

    The top image shows the leeks I'm talking about, the second one visualizes the uvs.

    light leaks at uv seams.PNG light leaks at uv seams debug.PNG
     
    Gekigengar likes this.
  2. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    The reason for that is most likely the lack of dilation.
    In Unity 4 we were using a very quick push-pull dilation algorithm that was running as part of the import.
    In Unity 5 we're not using it yet as we didn't have access to the mask of which pixels are the background and which are not. That functionality was added in Enlighten and we'll make the dilation work again soon.

    Could you perhaps file a bug report with the repro above, so we can check on our side if that fixes the problem?
     
    Zomby138 and essimoon2 like this.
  3. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Oh I see, thanks for your detailed explanation! :D Now I understand the problem better, and glad you're working on a solution :)

    I will gladly file a report to provide a working example for you and gonna write the case number here.
     
  4. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Ok, all done! Case number is 682143.
    Thanks in advance! :)
     
  5. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    I'm having a similar problem as well. Is there anything we can do in the meantime?
     
  6. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    It's possible to dilate lightmaps manually in photoshop using some script/action. But that's not practical if you do it for all the levels in a game project. Guess we have to wait :/
     
  7. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    Thanks for the repro, @essimoon2.
    And yes, you can ofc dilate them in an external program, but it's fighting a losing battle. We'll try to get the fix into a patch release, so you can get it ASAP.
     
    randomperson42 likes this.
  8. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    I am having this problem too.

    I guess I will have to wait for the next patch! :p
     
  9. foundway

    foundway

    Joined:
    May 30, 2013
    Posts:
    14
    Any update for this issue? I encounter this in Unity 5.0.1 too. Increasing resolution help but there is always visible leaking.
     
    randomperson42 likes this.
  10. S_Darkwell

    S_Darkwell

    Joined:
    Oct 20, 2013
    Posts:
    320
    I too am seeing substantial light leaking, regardless of what precautions I take on my end. A fix to this would be most appreciated!
     
  11. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    The main issue is that the spacing between UV charts of your object is too low. So charts are fetching lighting data from neighbouring charts.

    2015-04-24_16-24-07.png
    This can be fixed by changing the Pack Margin on the model importer. This adjusts the padding between the charts. The value is measured in texels, but assuming the mesh will cover an entire 1024x1024 lightmap. Of course typically it will be covering only a small part of it, so to get a reasonable margin, you may need to increase that resolution.

    For this object with the current resolution the value of 40 works well.

    We are planning to adjust the padding between the charts per instance, which will mean that we'll simply use the padding property from the Lighting window both between the objects and between the charts. A lot of people are running into that issue and we finally have means to fix them (per instance UVs).

    The other issue is that if one changes the mode from Non Directional to Directional or Directional Specular then it turns out that we were missing a one texel dilation margin in the directionality texture. This is fixed now in 5.1 and we'll backport the fix to 5.0.x.

    Another issue, I initially though you're running into, is us not filling the background properly. Generally this only matters if you're seeing one of the smaller mip levels on your object. I didn't find that to be an issue in your case.
    We will fix this as well though.

    Hope this helps!
     
  12. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Thanks for your detailed reply, Kuba! :D That's great, gonna try it out as soon as possible.
     
  13. Unreal-Vision

    Unreal-Vision

    Joined:
    May 6, 2013
    Posts:
    58
    Hi Kuba,

    I have the same issue in my scene and we create our lightmap in external software.

    It is a clear padding issue in the baking engine. You can add an option for this?

    Thanks

    Take a look to this reference:

    uv_seam_view.png uv_seam_map.png uv_seam_zoom.png
     
  14. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Although the issue on my particular asset is fixed we still have problems due to missing dilation in Unity 5 :(
    Any updates on when it will be ready?
     
    Last edited: Jun 25, 2015
  15. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Baked lightmaps need some love. Dilation is obviously a must have, it's very hard to make things look correct without it, but also, final gather needs some much needed love.

    I was one of those that weren't satisfied with "just" the upsampling of the realtime data for the bake. So you gave us Final Gather. Now every pixel has unique data. Cool! Awesome!

    But...

    Your final gather implementation is the brute-forciest implementation ever. There are a ton of techniques around (importance sampling, adaptive sampling, maybe combining it with irradiance caching etc etc), so that maybe, maybe we can find a way so that I don't need to crank the rays up to 20000 just because that little luminous poly over there is generating a TON of noise (but everything else looks cool with a fraction of the rays).
     
  16. Hodgson_SDAS

    Hodgson_SDAS

    Joined:
    Apr 30, 2015
    Posts:
    123
  17. essimoon2

    essimoon2

    Joined:
    Nov 13, 2013
    Posts:
    195
    Any update on the dilation? It's been a while and after updating to Unity 5.2.2 the problems seem to have gone worse :(
     
  18. mancuso

    mancuso

    Joined:
    Dec 5, 2011
    Posts:
    63
    Yeah, I'm having some issues with light bleeding through my object. Tried different values for the model but nothing works. Ticket raised: 741588.
     

    Attached Files:

  19. mancuso

    mancuso

    Joined:
    Dec 5, 2011
    Posts:
    63
    Ok, managed to fix this. I've set the Cast Shadow property on my prefab to Two Sided and that fixed the issue. The Shadow Bias was 0.04 and Normal Bias 0.05.
     
  20. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    230
    I also have this problem. I filled a bug report with a simple scene that has the problem, bug report 785185

    It seems I need something casting indirect light to make the seams appear, but in the project I am working, indirect light is the makority of the light and seams appear very easily

    Capture.PNG
    The seam exists even if there is two free pixels between islands on the lightmap (I am only using meshes from Unity here)

    Capture.PNG
     

    Attached Files:

  21. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Has there been any word on lightmap dilation? Still broken :/
     
  22. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    Will this ever be added?

    This is a major issue. Engines from 1997 have no issues with black bleeding and they have much lower res lightmaps.

    Is it really any harder than extending the colour of the pixels outward after baking?
     
    Autarkis likes this.
  23. Dmitry_Shesterkin

    Dmitry_Shesterkin

    Joined:
    Mar 3, 2014
    Posts:
    1
    Hi @Kuba,
    Two years have passed since we were promised the dilation, but we still don't have it. We use unity 5.5 and have annoying seams on smaller mip levels. Could you give us any update on the issue or suggest any workarounds we can try?
     
    DigitalJackson likes this.
  24. DigitalJackson

    DigitalJackson

    Joined:
    Mar 5, 2015
    Posts:
    3
    Yes, please fix this! This is a constant issue for me.
     
  25. Dorodo

    Dorodo

    Joined:
    Mar 8, 2015
    Posts:
    44
    Yeah, I just want to say as well that this is is something a lot of people would appreciate to be fixed.
     
  26. Lohrion

    Lohrion

    Joined:
    Aug 16, 2013
    Posts:
    107
    Yup, would really like to see this fixed...
     
    jonasschmidt likes this.
  27. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Is it not fixed in 2017.3 for you?
     
  28. FirePlantGames

    FirePlantGames

    Joined:
    Dec 11, 2012
    Posts:
    49
    2017.3 is beta, haven't tried it. Did this fix it for you?
     
    Autarkis likes this.
  29. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    +1, is there anybody that tried out .3 that's able to verify that it's finally been fixed?
     
  30. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    The progressive lightmapper has an option to stitch seams (the option is on the mesh renderer) that works quite well.

    Other than that, having UV seams in your model, will almost always result in some discontinuity in lightmapping, so proper UV making and making sure you hide the seams is something everyone should do (even though the progressive lightmapper does a good job of hiding the issue).
     
  31. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    Well of course, that's why I make my own uv2 channels :). Still, a little bit of dilation goes a long way.
     
  32. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Sure, but I think that the latest examples of the issue are not an issue of dilation.
     
  33. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    @AcidArrow considering the last comments on this thread were regarding dilation, what latest examples are you talking about? ( havent done much lightmapping in recent months, so I probably am out of the loop :) )
     
  34. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    forestrf's last post is not an issue of dilation. Lack of dilation usually produces black (or white, or whatever the background color is) "bleeding" where the seams are (which is exactly what happened in the first post in this thread.

    forestrf's issue is not lack of dilation. There's no bleeding happening there, there is just a discontinuity in the lightmapping because there is a discontinuity in the UVs.
     
  35. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    230
    It may not be lack of dilation, but while the discontinuity in the UVs doesn't affect direct lighting there, it does with indirect lighting. If there are no bounces, there are no seams :/
     
  36. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    The progressive lightmapper does stitch seams quite effectively though.
     
    forestrf likes this.
  37. forestrf

    forestrf

    Joined:
    Aug 28, 2010
    Posts:
    230
    I want to try it tbh. Problem is, right now I don't need lightmaps :/
     
  38. Autarkis

    Autarkis

    Joined:
    Oct 10, 2011
    Posts:
    318
    And the post right above forestrf's was mine about dilation that I was seeing in the lightmapper.
    However, just like forest, I'm not doing any baking at the moment, but it's definitely something I'll run tests on when I get a free hour or so.
     
    forestrf likes this.