Search Unity

Shadow leaks.

Discussion in 'Global Illumination' started by illinar, Nov 26, 2018.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Hi. I have these artifacts all the time: upload_2018-11-27_11-20-19.png

    This is shadow leaking apparently due to bilinear interpolation between black shadow and light. The right column is submerged on the given image. On the left column, the shadow is leaking from under the column. These leaks are everywhere. Will this be fixed in the new light mapper or in general? I know it's not that easy to understand which way to compensate for these leaks and which side is invisible, but I think this is solvable and configurable. For example, one could place some sort of markers and volumes to designate visible volumes. Or it could be done based on light probe positions.

    In this case, those are shadow leaks, but the light is leaking the same way. The lighmapper needs to be aware of the scene elements visibility so it can remove the leaks by extrapolating visible texels.
     
    Last edited: Nov 27, 2018
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    The attachment is not working so it's hard to understand what you're talking about.
     
  3. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Oops, sorry about that, I reuploaded the image.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    Actually it does that (it rejects texels that it considers to be in intersecting geometry). That's assuming you have the default backface tolerance value, and you haven't set those materials as double sided GI.
     
  5. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    I'm using a plugin lightmapper that has these issues solved, however it has some of it's own (much fewer artifacts though)
    upload_2018-11-27_11-31-8.png
    But this has to be fixed in builtin tools.
     
  6. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    It doesn't do it properly. It discards only one texel but it should discard 2, otherwise, the interpolation between the discarded texel and the next one will show as this leak.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    What back face tolerance value are you using?

    Is this a test scene? Can you share? I'd like to investigate.
     
  8. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    upload_2018-11-27_11-46-52.png

    Unity discards the texel 1, and as you can imagine if the texel 2 is black then half of the texel one will be a light to black gradient and it will result in a visible artifact.

    This light mapper discards 2 texels so that interpolation between texel 3 and 2 is not visible from above the surface in this case.
     
  9. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    I used every value of backface tolerance.
     
  10. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Hm.. Actually, I think I was wrong. This is the scene with point filtered lightmaps. The texels are not discarded as if backface tolerance not working at all.

    This is backface tolerance = 1:

    upload_2018-11-27_11-59-9.png

    This is backface tolerance = 0;

    upload_2018-11-27_12-7-26.png

    I'm skipping the filtering step there, I assume it only does the blur, and I don't want it if I want to see what's going on.

    This is progressive lightmapper. Same results on the Default Medium setting.

    Tried maximum pushoff (1), no difference.
     
    Last edited: Nov 27, 2018
  11. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    upload_2018-11-27_12-16-0.png

    With these settings absolutely the same result.
     
    Last edited: Nov 27, 2018
  12. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Last edited: Nov 27, 2018
  13. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    @illinar Are you sure you don't have double sided global illumination enabled in your materials? It seems to work fine for me. Can you double check?

    Here is the scene with double sided global illumination OFF on the materials:
    Screen Shot 2018-11-28 at 04.10.00.png
    (looks pretty clean)

    And here is the same thing with double sided GI ON (didn't bother to finish the bake)

    Screen Shot 2018-11-28 at 04.11.30.png

    It looks similar to what you're seeing, which makes me think that you have double sided GI on, which effectively disables texel rejection.
     
    illinar likes this.
  14. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Yes, thank you, I didn't know about that setting, it solves all those issues. It doesn't completely solve only the "box on the ground" problem (front face to front face) but that should be possible to avoid hopefully.
     
    Last edited: Nov 29, 2018
  15. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    For anyone else who has similar issues like this, you can also increase Packing Margin by a lot in model Lightmap UV settings, and you should optimise by cutting a hole in the floor and welding where the pillars are.
     
    illinar likes this.
  16. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    This wasn't really relevant in this specific instance.
     
  17. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    "and you should optimise by cutting a hole in the floor and welding where the pillars are" Hmm, why though? It doesn't save lightmap resolution since the lightmapper won't put anything into those holes anyway. Overdraw shouldn't be an issue since I will make sure that the floor and the ceiling are on a separate mesh, or all the objects in the center of the room are. Only thing it would do is make the direct baked shadow contact a bit better.

    And I might be polycount bound on mobile VR.
     
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,749
    At the expense of more vertices you would have eliminated the need for texel rejection. That's all.