Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Lightmaps messed up in build

Discussion in 'Global Illumination' started by pojoih, Apr 16, 2017.

  1. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    208
    I'm stuck with a really annoying problem. While lightmaps are fine in the editor, they are totally messed up in the build. Realtime light works fine. Anyone's got a tipp for me to check? Using 5.6.0f3
    - Happens in all of my scenes with heavy geometry
    - Happens on enlighten and progressive baker lightmaps
    - Happens in VR and non-VR
    - Realtime lit geometry is also affected when a baked lightmap exists (see wind turbine wings)
    - Does not happen when I partially deactivate lightmapped meshrenderer, but I cannot nail it down to a single mesh/shader/material.
    Build: build1.jpg
    Editor: editor.jpg
    Bake View: editor2.jpg
    Lightmaps: lightmaps.jpg
    Settings: settings.jpg
     
  2. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    208
    Okay it's getting weired now. Seems related to the textures in my project.
    I can make the lightmap look correct without rebaking if I remove some meshrenderers in the scene, deactivating does not help. Is there some kind of maximum texture count (size does not matter i've already tried reducing all textures to 1024px) for builds?
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,943
    Can you try non-directional and see if that works properly? At least we can narrow it down as being an issue with the directional mode then.
     
  4. Amitgp

    Amitgp

    Joined:
    Aug 18, 2014
    Posts:
    22
    Did you add second UV Map to your 3D models for the lightmapping to be baked into the texture?
    Did you make sure the unwrapping is unfolded and not cut and spread out?
    Have you tried switching between forward vs deferred?
    Have you tried switching between gamma vs linear?
    Have you tried changing from progressive (preview) to enlighten before doing final rendering and build?
    Have you checked project - quality settings for any wrong settings?
    Have you made a cube inside Unity and checked if the scale of your objects imported into the level is bigger or smaller than the Unity Units?
     
  5. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    208
    Done everything sadly. I'm now down to lowering the meshrenderer/vertex count of my scene. This seems to help but I can't narrow down when this breaks exactly. Thanks for your help!
     
  6. LarsNonne

    LarsNonne

    Joined:
    Jun 30, 2016
    Posts:
    5
    I'm currently experiencing the same issue on 2017.2p1. None of my attempts to fix this helped.
    Did you resolve this issue? If so, how did you do it?

    My last guess what might help is to let Unity generate the UV maps.
    Since the scene with the issue is a very large one (and strangely the only one in the project), this takes ages to complete. So if there is another fix, it would be great to know.

    Thanks.
     
  7. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    208
    We did not fix this problem but worked around it. I deleted some meshfilters/renderers in my seen (deactivating does not help) and at some point it worked again.
    I suspected an overload in the build data with too much textures/meshes but didn't manage to pin it down to specific objects or numbers (we had > 15m triangles and a lot of 8K textures).
    Your best try is to delete unused gameobjects with renderers/filters on them and build again. Good luck, took me some nights to get a good looking scene with some objects deleted :(.

    Edit: We did use Meshbaker for merging geometry but deleting the deactivated originals did not do the job either, I had to remove some of the baked geometry/atlases as well.
     
  8. LarsNonne

    LarsNonne

    Joined:
    Jun 30, 2016
    Posts:
    5
    Thanks for the help.
    Unfortunately I was not able to fix it.
    If I delete visible objects my Lead Designer would kill me ;)
    My best guess is, that the reason is the Meshmerger/baker, more specifically the lightmap UVs that are generated. And therefore the amount of maps that are generated in the project gets too high.

    Cheers.
     
  9. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    208
    pierre92nicot and OldManSmithers like this.
  10. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    388
    I've had this problem recently. The lightmap was flawless in the editor, but in builds it had bizarre artifacts like blocky textures and patches that were so extremely bright that they'd fill the screen with bloom.
    Rebaking and rebuilding seemed to fix the problem... so I don't know what the heck happened.

    Using 2021.3.15f1
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,943
    Start a new thread and post pictures of what's happening, then maybe the rest of us can come up with something to help you.
     
  12. Zergling103

    Zergling103

    Joined:
    Aug 16, 2011
    Posts:
    388
    As the problem went away I'd have nothing to show, but otherwise this would be great advice.

    However, if this does happen again, I'll be sure to do this.

    For anyone happening upon this conversation, I know that "just rebake, rebuild and cross your fingers" isn't the most satisfying conclusion, but hopefully it'll be enough to get you through whatever your working on.
     
    AcidArrow likes this.