How to merge multi small pngs into a single one with smallest size?,
Members - Reputation: 122
Posted 22 December 2008 - 09:47 PM
Crossbones+ - Reputation: 7022
Posted 23 December 2008 - 08:50 PM
Members - Reputation: 642
Posted 24 December 2008 - 07:59 AM
Original post by MikeTacular
I found this to be very useful
I always recommend that site for those looking into making a texture atlas. It is, by far, the fastest way to get it done that I have seen. I was able to pack a couple thousand textures into a 4096x4096 atlas in around 100ms I believe it was.
It definitely won't give you the best fit, but it will give you great scalability and performance. If you want an example of bad scalability, the XNA website has an example that just scans every pixel from the start until a fit is found. Works fine up until you want to pack more than about 5 textures.
If the size of the atlas really is that important, I'd suggest you build the atlas first by guessing the size. You know the width will need to be at least >= the largest item's width, and >= the sum of all width. Same goes for height. The area will also need to be >= the sum of the area of all items packed. Using that, you can take the first two power-of-twos that fit those conditions.
Since it is not unlikely that the first atlas will fail, even if it fits those conditions, you just keep trying by moving to the next atlas that fits those conditions, ordering them by the atlas's total area (since that is what matters to you the most).