Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture atlas creation #2

Closed
mosra opened this issue Oct 29, 2012 · 4 comments
Closed

Texture atlas creation #2

mosra opened this issue Oct 29, 2012 · 4 comments

Comments

@mosra
Copy link
Owner

mosra commented Oct 29, 2012

Barebone joke implementation is now in https://github.com/mosra/magnum/blob/master/src/TextureTools/Atlas.cpp. Also -- would it be possible to preestimate atlas size to avoid specifying it manually?

@mosra mosra mentioned this issue Oct 29, 2012
mosra added a commit that referenced this issue Feb 27, 2013
Brain failure #2. Also I don't know if such thing as dot product exists
here :-)
mosra added a commit that referenced this issue May 4, 2013
This class now stores the tree in flat array, making it easier for user
to query the contents, but the internals are much more complicated. This
solution already reduces allocation count by count of nodes in the tree,
future work might remove the per-shape allocation altogether by using
large typeless array and placement-new etc.
@ArEnSc
Copy link

ArEnSc commented Dec 26, 2013

I think I would be genuinely interested in doing this based on the RectangleBinPack Algorithm which is something I wanted to implement a while ago. This will be looked at after the windowless opengl fix.

@mosra
Copy link
Owner Author

mosra commented Jun 21, 2022

Would be great to finish this before the issue turns 10 years old, heh.

Just for the record, an alternative and very specialized algorithm was added recently: https://blog.magnum.graphics/backstage/pot-array-packing/

@mosra mosra moved this from TODO to In progress in Math and algorithms Jun 21, 2022
@ArEnSc
Copy link

ArEnSc commented Jun 21, 2022

LMFAO!!!!! omg. Better late than never! =) have fun

@mosra
Copy link
Owner Author

mosra commented Sep 27, 2023

Okay, it had to take 11 years after all. As of 66bf0b2 there's a new TextureTools::AtlasLandfill packer, which is based on a very simple idea of tracking currently filled height and filling the image in a linear fashion bottom-up. Thus, "Landfill". It's also capable of incremental packing and has support for texture arrays.

atlas-landfill

Combined with pre-sorting the items from highest to shortest and making the items all the same orientation it has efficiency comparable to stb_rect_pack, while being significantly faster. This is just an initial implementation aimed at glyph packing however, its efficiency and speed properties, especially for packing larger and more varying input sizes, are likely to improve further.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants