That's probably as good as I am going to get it. Obviously red represents dead space. I wish there was less dead space in some of those but, I just end up trading width red for more height red.
Original allocBlock system (from actual quake source) defined 1 static number that represented the height and width of the final atlas.
Math.sqrt( (total group width)*(maximum found height));
The original would throw an error if the best position + the current height blew out it's static number.
(best > 2048) throw Error(...)
which is also a static number but it is the absolute max that my platform can produce for image dimensions.
after every call to allocBlock
height = Math.max(lm.height + lm.y, height)
before I draw or even init the atlas
height = makePow2(height);
I treat the lightmaps like one long singular row and square root the results.
That makes the width substantially less and allocBlock will position everything over many rows
I then let the height do whatever it wants all the way to my platform max.
I then find the highest used y value, make it power 2 and snip the rest.
Here is a code sample that illustrates everything I said. The left organizes and allocates everything before it is sent to the atlas. The right side is the allocation function itself.
I also changed the default for my fog to (0, 2000, 0x555555);
With such a large stretch between the origin and the max the gradient is much smoother. There are a lot of maps where this looks pretty good. Below is one.
I'm still going to make it to where these values can be overridden in worldspawn.