Search Unity

How to tell which is what in the Lightmap?

Discussion in 'Global Illumination' started by BuzzKirill, Jan 13, 2020.

  1. BuzzKirill

    BuzzKirill

    Joined:
    Nov 14, 2017
    Posts:
    48


    I have these lightmaps and obviously a huge part of one of them is "unused" (that is, a large object, or an object with a big Lightmap scale value, is taking up a lot of space in the map while clearly not contributing anything to the visuals).

    How do I easily find out what object it is that's taking up all this space, without thumbing through every object in the scene? Obviously this is not empty space, since the lightmapper has deemed it necessary to create an additional small lightmap to fit the remaining few objects. (Lightmap 4, 256x256 - the last one in the picture)
     
    sarahnorthway likes this.
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Currently, there's no way to tell which lightmap UV shell belongs to which object.

    That light blue area that the arrow is pointing to is empty. The reason why it appears to be of blueish color, is due to the fact that we apply push-pull dilation to the lightmaps while baking. This minimizes lightmap seams between different UV shells when mipped.
     
    BuzzKirill likes this.
  3. BuzzKirill

    BuzzKirill

    Joined:
    Nov 14, 2017
    Posts:
    48
    Thanks. But then I don't understand why it created an additional 256x256 map if there was plenty of free space available in the previous map?
     
  4. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    103
    @BuzzKirill I have a guess. Unity packs objects from different LOD groups into different lightmaps. For example, the LOD0 and LOD1 bakes of an object will always go to separate lightmaps (regardless of unused space). Can this be the explanation in your case?

    My guess is that the last 256x256 lightmap contains the result of baking the LOD1 group.

    You can test this hypothesis by searching for objects with LOD groups using the search string "t:lodgroup" in the Hierarchy window's search box. Try disabling the LOD Group components and doing a rebake. If the problem disappears this suggests that the 5th 256x256 lightmap is due to LOD1 objects being split from LOD0 objects before packing starts.

    Another (I think less likely) explanation is that you have assigned different Lighting Parameters to different objects. For example, if you have specified different "Baked Tag" or different "Antialiasing Samples" for groups of objects, then these groups will end up in separate lightmaps (regardless of how much space may be left in any of them).
     
    BuzzKirill likes this.
  5. BuzzKirill

    BuzzKirill

    Joined:
    Nov 14, 2017
    Posts:
    48
    @rasmusn Thanks. I did have LODs, however after deleting them an additional 256 map is still created. I do have different lighting parameters on a select few objects, however the baking tag and antialiasing is the same for them as for the rest. Maybe I'll try setting these objects back to default setting.
    One further thing: I do make use of the "lightmap scale" settings (giving much lower values to certain objects that aren't going to be seen). Can that be the culprit here?
     
  6. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    103
    No, I don't think so. Objects in one lightmaps can indeed have different lightmap scale.

    If you can manage to reduce the problem to a simple scene/project, then I encourage you to submit this to us via the menu's Help > Report a Bug. Then we can take a more close look at it.
     
  7. BuzzKirill

    BuzzKirill

    Joined:
    Nov 14, 2017
    Posts:
    48
    I found one way to visually tell where the small lightmaps are, is to go to Shading Mode - Lightmap Indices.
    From there I was able to eliminate the small extra lightmaps Unity was creating. The reason extra Lightmaps were created seems to be that the corresponding objects' Lightmap scale was set to 0, or, as Rasmus said they used different Lightmapping settings.
     
    Last edited: May 1, 2020