A downloadable library

Download NowName your own price

Did you ever want to be able to combine multiple sprites into a single sprite atlas during runtime? Probably not, since it's an incredibly specific thing to need to do. But if you do, here's an extension for it!

This can be useful if you're in the business of building vertex buffers on the fly, and you want to be able to combine sprites from different texture pages.

Play around with the demo for a rough idea of how the algorithm performs. The demo was built in YYC.

Documentation

Documentation is on the Github wiki.

It's fairly straightforward: feed an array of sprites into your packing function of choice, as well as amount of padding (space between sprites) and whether or not to repeat the pixels around the sprite borders. The function will return a struct containing the atlas as a new sprite, as well as a list of UV coordinates in absolute pixels for each sprite.

If you have a sprite with multiple subimages, all subimages will be written as individual sprites. There may be a more elegant way to handle this, but for now it should be good enough.

You have the option to force the output sprite to a power of 2 in size (256x256, 1024x2048, etc). This tends to be helpful when dealing with textures in shaders.

Price

As usual, the asset is free as-is. I'll fix simple or game-breaking bugs but more involved support requires payment via either Itch or Patreon.  I get the final say in what constitutes "game-breaking."

Notes About Performance (and other stuff)

  • This operation can be very CPU-heavy. Using the YYC speeds it up, though not as much as you might think. Alternatively use the DLL, which is about 3x faster in my testing.
  • You can speed this up at a slight hit to spatial efficiency by increasing the packing stride. This code doesn't pack the sprites PERFECTLY; it only attempts to make them "reasonably close together." As a general rule, you can probably get away with making your stride value about half of the size of your smallest sprite.

Credits

  • The Itch cover picture is based on Atlas by parkjisun from the Noun Project
  • The program icon is based on world by Creative Stall from the Noun Project
Updated 17 days ago
StatusReleased
CategoryTool
AuthorDragonite
Tagsatlas, GameMaker, Sprites, texture

Download

Download NowName your own price

Click download now to get access to the following files:

Packing-YYC.zip 3.8 MB
spritepacking.yymps 59 kB

Development log

Comments

Log in with itch.io to leave a comment.

Where's the source for SpriteAtlas.dll to be found?

Here

So, did you ever write the documentation?

Oh dear, thanks for reminding me. This should do it.

I also saw you left a few comments on Emu; I’ll try to work on that some time this week, there are a few other changes I need to make over there as well.

I made comments on Emu? The deleted ones? Can't remember what I wrote...