Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Packing continues to be horrible, please fix

Discussion in 'Global Illumination' started by AcidArrow, Jan 25, 2017.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    Packing for lightmaps was great in Unity 3. It got a bit worse in Unity 4 (it packed by bounding box instead of tighter packing, but still good). It is horrible in Unity 5 (it fails to pack very simple cases).

    I am trying to fit everything in one 1k map.

    So I have this lightmap.

    lm1.png

    Plenty of wasted space I think. I could try bumping up the resolution a bit.

    So I take it from 42 to 44 and...

    lm2.png

    Did you notice some islands missing? They are in a second lightmap now. Even though the first one still has all that free space. And they definitely fit inside the first.

    I mean...

    lm3.png

    I haven't seen any other Unity feature regress this much. And I'm including baking with Enlighten vs baking with Beast in that. It has gotten THAT bad.

    I mean, the logical next step for Unity 2017 is to just not do any packing, and create separate maps for each mesh.

    Please... Please fix it.
     
  2. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    I've noticed this as well, very annoying. Do you happen to know if the progressive lightmapper has better packing?
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    I don't know, but I'm also not sure if it's related. Packing is a different process and I don't think it matters which lightmapper you are using afterwards.

    I'm hoping they plan on doing improvements though.
     
  4. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    That's what I fear, I was hoping they'd do a better packing method for the new lightmapper but likely isn't the case. Have to wait and see. At least iterating trying to find the "bad-but-not-the-worst" packing will be faster with the new lightmapper..
     
  5. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    1,960
    Offtopic the progressive lightmapper won't match the full GI glory of enlighten anyway.
     
  6. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    I am hoping it won't match Enlighten in terms of being pre-alpha quality, slow and fragile mess when baking lighting. I'm hoping it's more like Beast in terms of output & robustness.
     
  7. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    Now it's good time to check if the packing is any better; the new lightmapper is in 5.6 beta 6!
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    I did check very quickly.

    I believe it's a bit... worse as far as packing goes.
     
  9. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    At least it was nice knowing the resulting lightmap sizes very quickly when changing things. Helps quickly adjusting if things are on the verge of splitting into too many lightmaps.
     
  10. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    I still can't get the over that the packing in Unity 3 was so much better.

    Also can't get over the fact that originally they were going to have a mode where you would pick how many light maps and what resolutions you want, and the packer would try to maximize the resolution without creating more lms. But they scrapped it because apparently "people don't want that".

    *sigh*

    Sometimes Unity makes me really sad.
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    Can we at the very least get some info on this?

    It seems to me, that older versions of Unity packed the UVs from bigger to smaller. Which makes sense. You fit the biggest first, so you can then potentially place the smaller ones in weird gaps so you can fill space more efficiently.

    Unity 5 and 2017 don't do that. I have no idea why. I don't know if there's any logic, it looks random. But what happens is since it fills the space somewhat hap-hazardly with small and medium UVs and then there isn't enough continuous free space to fit the bigger ones.

    Look at this:

    packing.jpg

    The top one is Unity 4, the bottom one is Unity 2017. (it's not 100% the same, since I have tweaked the UVs since then a bit, but it's the same scene).

    You will firstly notice that Unity 4 has much more efficient use of the space.

    And that's because of it fits the largest islands first.

    I can't increase the resolution at all in the Unity 2017 version since this island:

    chunk.jpg

    Gets packed last. Not sure why. And since it's packed last and it's a big square area, it really can't fit anywhere if I increase the resolution.

    Placing the big UVs first and fitting everything else around them makes sense and it works. Placing smaller ones first and then trying to fit the big ones in the remaining fragmented space, does not.

    I don't know why it was changed and I don't know why they won't change it back. If there is a logic to this madness, please let me know.
     
    Shorely, Peter77 and mh114 like this.
  12. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    I too would be very interested in hearing more info about the packing. @Jesper-Mortensen might know about it with progressive lightmapper..?

    I haven't used Unity 3, but with 4 and above lightmap workflow of specifying resolution first has always felt backwards to me. I would like to set a limit on how many lightmaps to use and what their maximum resolution should be -> lightmapper / packing would figure out the correct resolution to give me that (or at least give something that is close to what is requested).

    Now, and this is especially problematic with wasteful packing there is currently, you have to guess a resolution and tweak it down (+ adjusting lightmap scale on objects) until you get close to what you want. Granted, it's faster to iterate with progressive LM and I'm grateful for that, but still the other way would make a lot more sense to me (mobile development). Thoughts?
     
    AcidArrow likes this.
  13. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    287
    Seriously, nobody considers wasteful packing a problem? Pfft, you PC devs! (;))
     
    Shorely, Martin_H and JamesArndt like this.
  14. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,677
    You're not alone, Ive noticed this as well and I dont see better packing using the Progressive Lightmapper. I end up experimenting for a long time with scale-in-lightmap values for tons of meshes and then seeing odd and random overflows into new lightmaps (with the same big empty spaces in existing maps). The packing is so bad/inefficient I've resorted to packing my own secondary UV set in 3ds Max.
     
    mh114 likes this.
  15. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,218
    Perhaps it's just a bug and Unity Technologies isn't aware of it. Did you submit a bug-report already?
     
  16. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    I'm not sure if it's a bug.

    The way it's picking the order to pack the islands, is based on the transforms in the scene. So I'm guessing it's deliberate, but I don't know why.

    In any case, I'll do a bug report now.
     
    mh114, JamesArndt and Peter77 like this.
  17. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    Case 955445

    I haven't received a reply yet on whether or not they consider this a bug. I'll update when they do.
     
    mh114, Adam-Bailey and Peter77 like this.
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    Still nothing, but I made this image to explain the issue for the bug report and I thought I'd post it here as well for prosperity.

    explanation2.jpg
     
  19. kemalakay

    kemalakay

    Unity Technologies

    Joined:
    Jul 12, 2016
    Posts:
    224
    Hi everyone,

    Just wanted to tell that we're aware of packing issues and that's why the roadmap for Progressive Lightmapper is being re-arranged and one of our developers will start to work on packing improvements soon.

    Main reason why it was delayed so far is because other tasks took priority. Primary goal for Progressive Lightmapper is to have feature parity with Enlighten and it is getting there (memory work is currently being addressed, also static scene dressing for lightmapped objects and importance sampling for emissive materials will be added).

    Thank you all for your understanding and raising your concerns. We hear your input and it is really valuable to us, we're simply trying to arrange the schedule based on priorities.

    Thanks!
     
  20. OwlBoy-

    OwlBoy-

    Joined:
    Dec 11, 2015
    Posts:
    11
    Any news on this packing issue?
     
    Last edited: Oct 16, 2018
    mh114, Shorely and JamesArndt like this.
  21. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,677
    Wow, your graphic really makes the problem clear. So any word on the fixes yet? Looks like it's been exactly a year since they started tackling this issue.
     
    Shorely likes this.
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,028
    This was actually fixed some time in the 2018 cycle (I think). It wasn't mentioned in the release notes for some reason. At least for the progressive lightmapper, not sure about enlighten.

    I am talking specifically about packing the larger islands first.

    There are still things that are worse than old Unity versions. For example, packing is still bounding box based, while older versions of Unity did a much tighter fit, but they took that out to accommodate for bake selected. But now we haven't had bake selected for years and packing is still bounding box based.
     
    OwlBoy- and mh114 like this.
  23. kwcae

    kwcae

    Joined:
    May 26, 2017
    Posts:
    34
    We're using 2018.2 and the packing algo is still horrible. On a 4K map, there's 2K of used space and the remaining space consists of two flat colors that don't appear mapped to any of the 4 meshes in our scene. (All 4 meshes using Unity's automatic unwrap setting)

    @kemalakay Any updates on the progressive packer.?
     
    Shorely likes this.
  24. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,677
    Any update on packing improvements for the Automatic Lightmap UVs? I keep checking release notes on each successive release of Unity since 2017 and I don't see any notes on it, so not sure what's been worked on or improved? I still have the issue of Unity not respecting my custom-authored lightmap UVs from 3ds Max. Unity still performs it's own rotation to my UV shells, moving them onto different atlases, etc. I've set proper packing tags for geometry I want on the same atlas, but it doesn't respect these because of very poor packing of atlases...so it shifts UV shells onto atlases with massive amounts of empty texture space.
     
  25. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    32
    Thanks for all the feedback guys! As clear from the above, the packing algorithm used in the progressive lightmapper has a lot of issues. It needs work and over the last year this work has been postponed due to other problems that for various reasons have been deemed more important.

    Unity 2019.1 will have a minor new packing feature and that is "Limit Lightmap Count", the ability to set a max number of lightmaps to be used for a certain group of objects. This feature is currently in the polishing phase, and once it is done, I will focus on addressing the issues mentioned in this thread.

    I cannot guarantee anything, but on my radar right now is:
    • Improve texture utilization (i.e. avoiding space waste).
    • Avoid texel bleeding/overlap.
    • An option to pass-through UVs unaltered (as requested by @JamesArndt ).
    • Spatially coherent packing as shown here.
    Do note that none of these changes are trivial and it will take some time to get right. Thanks!
     
    Lars-Steenhoff, mh114 and JamesArndt like this.
  26. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,677
    Thank you so much for the consideration of this. The Bakery Lightmapper plugin does something similar with its "Lightmap Groups" functionality. You can assign a Lightmap Group to a set of geometry that may or may not be combined meshes. Once you've assigned this script you can drop-down select to use "Original UVs" and it will bake and preserve my 3d package authored UVs. I would highly recommend looking at this plugin as it produces lightmap bakes that are cleaner than anything I've seen come out of Unity in years.
     
    rasmusn and fguinier like this.
  27. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    134
    I say they (Unity) should just buy Bakery. Over night the problems are all solved. I guess I'm going to have to buy Bakery next week. My experience with lighting in Unity lately has been frustrating-- I put a few models I've made in and bake lighting and whole UV islands are getting the wrong colors with hard seams. It has nothing to do with bad mapping on my part, since the artifact remains even if Unity does the UVs. Looking at the islands, they have plenty of space around them. I noticed the UV packing. I thought-- Jeez, if they're going to waste the space, move the islands farther apart or something to help avoid artifacts. Plus, I cant get global illumination to change no matter what buttons I push or sliders I drag. The HDRI Sky script seems to be missing from 2018.3 HDRP... Or do I have to download Unity's HDRI sky pack for half a gig to get the script? The spotlight in the demo construction scene seems to have the light map pixels drawn backwards or else some weird choppy gradient artifact is chunking up the shading-- Oh wait. I see it on the ground from the directional light too. so... Yeah. I'm gunna buy Bakery for 55 bucks and hope it works for me. I'm just an artist that wants to try making stuff for the Unity store, and I want my promo pics to look good. But dang. I feel like I have to be a Technical Artist who can code and knows engines and video cards in depth just to set up a nice looking test scene :(
     
    Shorely and JamesArndt like this.
  28. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,677
    I would highly recommend this plugin. I've used to great success to lightmap large racetracks on a project of mine. It's for mobile so I don't need a lot of the fancy realtime GI stuff. For Beast-style lightmapping that looks even better than Beast this is the plugin that does it!