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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Lightmap UVs squashed in atlas

Discussion in 'Global Illumination' started by Futurerobot, Jun 3, 2015.

  1. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Upgrading the project unity 4.6 to 5.1, I noticed some differences in the lightmap. Unity 5.1 seems to have softer shadows on lights than in 4.6, the directional light casting these shadows both have 0.35 shadow angle.

    However they also seem to be lower res, because of a strange squashing seen in the lightmap atlas.
    On the attached image you can see the 4.6 atlas on the left. The area marked is the ground, it matches proportions to how the groundplane actually is in the level. On the right you see the unity 5.1 lightmap atlas, which seems to be squashed together for some reason.

    Ideas? Mesh's lightmapper uvs created by unity in both cases. Same resolution and padding, both bakes resulted in 6x1024 lightmaps.


    unity46-51_lightmapdifference.jpg
     
    Last edited: Jun 5, 2015
  2. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    On other areas of the same ground, the difference in the lightmap is also quite big. This is a shadow cast from a hard shadow light. (Baked shadow radius = 0)

    Unity 4.6 on the left, Unity 5.1 on the right

    LightmapUnity46.png LightmapUnity52.png
     
    Last edited: Jun 5, 2015
  3. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
  4. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    Checked out your thread, seems to be the same issue. UVs are squashed (or stretched, but I'm leaning towards squashed :D ) and the resulting free space goes unused. It's almost like it finds a spot for the actual UV island to fit. Then it scales the whole UV square layout down to fit into the appropriate area. Instead of only placing that specific UV island unscaled there. If that makes sense.

    I can move my squashed UV problem over to your post if you like.
     
  5. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Whatever you prefer :)

    There are even more problems related to UV and lightmapping. As an example if you make your custom lightmap UV layout from max/maya etc and you don't fill ALL the uv space, this free space is not used by the Unity's uv packing for any other object of the scene.
     
  6. Futurerobot

    Futurerobot

    Joined:
    Jul 13, 2011
    Posts:
    179
    And do the ones that don't use all the space get squashed? Sounds like a plausible bug in a packer.
    1. Checks size of uv island, ignoring empty space as it should. Finds an empty spot.
    2. Fits whole uv layout into available space, forgets to take empty space into consideration.
     
  7. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    416
    This issue is very much related to:
    http://forum.unity3d.com/threads/gi-baked-point-light-blotching-black-spots.319940/
    http://issuetracker.unity3d.com/iss...irection-uv-maps-overlapping-causing-blotches

    For your convenience:
    "UVs not filling the entire 0-1 space, either smaller or bigger (as in this case), would cause the packing to go haywire. It would manifest itself in UV islands overlapping (causing black blotches), in resolution being calculated incorrectly (hence the object would get too low or too high amount of texels) and the UVs being stretched. It is now fixed in 5.2 and the fix will be backported to 5.1."

    Cheers!