Unity 5: Efficiency of lightmap packing?

Hi all,

I just looked at some of my baked lightmaps and they seem to be packed pretty inefficiently. I guess with better packing the number of the lightmaps in my example could probably be reduced from 7 to at least 5 or even without reducing size or quality of the individual patches.

Now I’m wondering if there’s somewhere a setting that lets us pack those patches more efficiently. Or if not, can we expect an update for the packing algorithm in the near future?

Since Bake Selected is not available anymore and we still require some objects to have differently baked lighting we currently store those objects in an extra scene and transfer the objects (including ligthmaps) into the original scene.
But this workflow requires some extra manual work for each lightmap that’s generated. So, the fewer ligthmaps the better :slight_smile:

1 Like

UV packing has been improved in 5.2 beta 4.

2 Likes

Nice! Looking forward to it :smile:

You can expect the update to the packing algorithm in 5.2b4 (released last Friday). :slight_smile:

One issue that was fixed that has to do with taking UV bounds into account properly and is described in more detail here:

The other thing that will improve your case is that the size of the last lightmap is now reduced to pack the instances more tightly and not waste space. So in your case, where you lightmap some objects in a separate scene and, possibly, they occupy only a part of one lightmap – now this lightmap will be made as small as possible (while still being square though).

Hi, I have still not been able to get the UV packing to improve with Unity 5.2 ( Installed in mid Sept). Also the Shading on my light map UV do not match in tone giving odd artifacts in the light map. Why does the Unity light map UV give such inconsistent seams? Thanks.

Also, can we please PLEASE (did I say please?) switch to the tighter packing that we had back in the 3.x days? The bounding box type packing wastes SO much space, especially when you generate your lightmap UVs (which has a tendency to put the uvs in an L shape)

I believe it was changed to work better with bake selected, but bake selected is no more, so… why are we wasting so much lightmap space?

This thread is a couple of months old but it seems that either the latest algorithm still needs work or I’m missing something (I’m on 5.2.3f1). My atlases have 70% wasted space and opening them in PS shows there really is nothing in those spaces.

2422898--165873--lightmap atlas space.png

I am also experiencing this using Untiy 5.3, i am getting 13 lightmaps and 3 of them are 90% empty and some others 75% empty.

Am i missing something?

Something similar had been driving me crazy for a while in the last few months too. I had been getting a whole scene packed into one map and then ONE object getting its own one whole 1024 even though it was about 4x4 pixles, the rest 99.9% of the map black.
It turns out the Layers you assign objects to matter in the new packing process. Correct me if I am wrong, please, but for me, making all of the objects I needed packed together be on the same layer fixed that problem.

Here’s one bug related to lightmap packing. Supposedly it should be fixed in 5.4. psycocrusher’s case above looks similar.

@KDurzy I tried your solution but it didn’t work fro me.

Alternatively if the unity Devs could tell us exactly how they want our lightmaps, we could set them up ourselves and set preserve Uvs coming from the art package? Can you give us an intermediate resolution that describes how you need them to look in order to pack them efficiently?

This is still a problem. If I try to have all my scene in one image I get either of these two results, there’s no way to utilized completely the whole area of the lightmaps.
Is there no way to manually fix this? I’m using 5.3.4.


Yeah Unity really needs an improved texture packing system. Still really poor packing in 5.3.4. Might be worth noting that it’s sometimes possible to get better packing by switching to a different texture size (eg 2048 vs 1024). It’s pot luck but might help someone else out

Packing is still pretty poor in 5.4b22

1 Like

This is still a problem in 5.4, regardless of the supposedly “fix” via the bug report listed above.

BTW, I discovered that changing things in the lightmap parameters (like the “is transparent” checkbox), forces the objects that have those parameters to be on a separate lightmap.

I don’t have a complete list yet. It would be nice if these sort of things were documented.

I hate to bring up direct engine to engine comparisons (since different engines usually have things going on under the hood totally differently) but I wish Unity 5 had support for user defined lightmap UV’s like UE4 does. I was reading outdated documentation (not realising that things had changed since it didn’t have a Unity version number on) and was under the impression I could lay out the lightmap UV’s manually for a scene, so spent a day doing that in Maya, giving high resolution to areas the player would get close to while compacting areas the player wouldn’t. Then imported it into Unity and discover that the UV’s are rearranged anyway.

Hey Adam. Yeah that is a nice feature in UE4. Having used both engines though I’d say there are benefits to both systems (I like being able to see an entire atlas and edit it in PS). Regarding your particular issue though - you can still use your per object UV2 layouts as well as set custom texel resolutions in Unity. Whereas in UE4 you’d set per object texture sizes; Unity lets you specify a texel ratio. It’s a little more trial & error (though you can enable resolution grids in the scene view for better visualisation).

If you want to completely control how every piece is arranged relative to one another (probably not necessary but it’s an option) then you can export the entire scene from Maya (I’ve done the same from Max).

i confirm this, this one totally confused why i have another small atlas in the lightmap list.
Turned out isTransparent object are baked in other atlas