Search Unity

Question Persistent UV-overlap looking artefacts on large lightmap bake (with perfect lightmap UVs)

Discussion in 'Global Illumination' started by TheGuineapig, Dec 20, 2021.

  1. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    Hi, after hours of trial and error I am at a loss with this lightmap issue. I have a fairly empty, large scene with some low/medium resolution lightmapped meshes. When I bake lighting, it appears perfectly fine on almost the entire scene apart from a hard cut-off point a certain distance away from 0,0,0. Both large and small meshes beyond that point are covered in bake artefacts. It has a similar appearance as having incorrect or overlapping UVs. I have tried baking with the CPU and GPU progressive lightmapper and have observed the same result on both. Increasing samples and texels per unit also doesn't seem to help the issue. I have tried baking at 1024 and 2048 lightmap resolution and I am unable to bake at 4096 at anything other than low quality. My scene is about 4,600 units along the longest axis. Rotating the large dome mesh produces the same result in the same region, regardless of the mesh itself. The pillars are also separate meshes and are still affected. I am on Unity version 2021.2.6f1 using the HDRP. Does anyone know what's going on here? Any help or pointers would be appreciated, thanks :)


    Here is an image showing my issue after baking with the GPU progressive lightmapper


    Here is the lightmap result


    This is an example of one of the higher lightmap settings I tried to see if it would reduce the appearance of the errors (it did not)


    UV overlap


    Here is a CPU progressive bake. As you can see, the issue persists


    The settings for the above bake
     
  2. Nicrom

    Nicrom

    Joined:
    Nov 17, 2013
    Posts:
    421
    Hi. How big is the dome model?
    Most likely the issues you encountered are caused by the large size of your dome. If possible, try to break the dome model into smaller pieces.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Those samples values aren't high enough.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    But also, yeah, I don't think it's possible to bake something this big without issues. Lightmapping starts producing artifacts far away from the origin.
     
  5. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    I first tried with the whole dome as one model. After getting these artefacts I broke it down into two halves and re-did their lightmap UVs (with no perceivable change). What's odd is that it also produced bake errors on smaller pillar models when I added those around the edge of the ring.
     
  6. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    Is this just an unavoidable fact of unity's lightmapper? I unfortunately can't change the scale or position of this object.
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    I always assumed it was and I’ve been working around it for a couple of years, but maybe it isn’t?

    Here is a recent thread with a somewhat similar issue and a dev took interest.

    https://forum.unity.com/threads/stripe-patterns-appearing-in-lightmaps.1207276/

    I would say this is worth a bug report, but please be warned that you might want to find a workaround anyway (like… scaling down the object, baking it, then scaling up at runtime?) since even if this is a fixable bug, a fix for it may arrive in a Unity version you can use in 6 months or a year or something.
     
  8. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    Thank you, I might just have to come up with something like that. The weird part is I have other scenes of a similar scale that aren't getting this issue. However they are uniformly spread out from the origin as opposed to all being off in one axis. I will submit a bug report.
     
  9. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    327
    If you do submit a report, please drop the case ID or issue tracker link here. Thanks
     
  10. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    I have set up a similar scene with the same assets in a blank HDRP project and reproduced the same results first time. I submitted the bug report and the ID is 1390059_cndjvr8d7f3i2n3a
     
    Last edited: Dec 24, 2021
  11. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    Here is the result of baking in a fresh HDRP project (with shadowmasks enabled in the HDRP settings):
     
  12. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    (just small side note, that isn't a link to the issue tracker, which is public, that's a link to fogbugz which isn't quite as public, and it has the often undesired side-effect that people can access all other bug reports you've done from it, which may be a problem if at any point in the future maybe you say something semi confidential in a bug report. I'm just saying you may want to consider just posting the number here and removing the link)
     
    Last edited: Dec 24, 2021
  13. TheGuineapig

    TheGuineapig

    Joined:
    Sep 21, 2015
    Posts:
    7
    I didn't know this! Thank you for the heads up!
     
  14. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hello!

    I wanted to provide a quick update regarding this issue. We have discussed this issue internally. As noted in another thread, which @AcidArrow has linked to, it is caused by 32 bit floating point precision errors. This means that large scenes, and objects placed away from world origin (0,0,0) will exhibit lightmap artifacts.

    We are planning on addressing it as part of the upcoming unified baking backend work. We cannot provide the ETA, unfortunately.

    In the meanwhile, you could try the workaround which @KEngelstoft had suggested in a different forum thread:

    The stripe artefact is is likely caused by 32 bit float point precision issues as AcidArrow said, so increasing push off on the object via Lightmap Parameters could be a workaround. https://docs.unity3d.com/Manual/class-LightmapParameters.html

    I hope this helps.
     
    AcidArrow likes this.