Sign in to follow this  

Texture placement within atlas

This topic is 3740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As a side project i've been writing a few handy texture atlas tools and i've struck upon an automation problem.... ....Assuming arbitarily sized textures (or at least 2^n), Is there an efficent algorithm for determining the best placement of each texture within the atlas? One idea i had was to start with an AABB quadtree, then each time i place a texture subdividing it into 4 more nodes (one holding the placed texture the other 3 at the vertices of the parent node).... then each time i place another texture i traverse the tree until i find the unused AABB which is as close to the size of the texture as possible(but still greater than). This will probably work, but im wondering if this is just a standard problem which already has some optimised solutions? Im guessing there is at least a few good approximate solutions, or even an optimal one, but im probably not up to the math....

Share this post


Link to post
Share on other sites
The magic google (and forum) search words are "rectangle packing" and "bin packing". Unfortunately this problem is NP complete, but there are some approximate solutions that work quite well.

There are other threads on this forum that discuss this, just search for "rectangle packing".

Share this post


Link to post
Share on other sites

This topic is 3740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this