Hi Unity people, I need to use PackTextures at run-time with an unknown amount of textures. How would I be able to tell if the textures are going to be resized if they go over the limit before actually packing the textures?
You can't without doing the algorithm. The best you could probably do is take the number of pixels in each image (width * height) and multiply it by the total pixel count in the max size and consider it full once it surpasses ~90% (depending on the size of the images you are packing into it, larger images require a larger buffer space). If it's over 100% it's definitly full but the 90-100% it's impossible to guaratee without doing the algorithm yourself (though that takes about 0.5 milliseconds or less on an iMac if you want to create your own algorithm to check). http://www.blackpawn.com/texts/lightmaps/default.html That's the algorithm, and if you precheck it you could save some time not having to do so many modifications to the image. I've replaced PackTextures with something based on that and it came out identically (minus PackTextures not handling vertical padding consistently)
Hi, I went without checking on this thread for a while. The information you've given is incredibly helpful. Thank you!