Where's the source for SpriteAtlas.dll to be found?
Sprite Atlas for GameMaker
A downloadable library
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.
The sprites used in the demo projects are randomly generated; if you want to change the number of sprites generated, edit the value in count.txt. Setting the value to something very large (~>100) will make the algorithm slow down noticeably.
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.
The output sprite will be forced to a power of 2 in size (256x256, 1024x2048, etc). This tends to be helpful when dealing with textures in shaders. Again, if people need to I can edit it to only produce an atlas sprite that's exactly as large as it needs to be, although I don't really see that being useful.
See the demo part of the YYMPS for an example of how to use it.
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 considerably (I've found it can be made 3x-4x faster). Alternatively use the DLL, which is blindingly fast and can come close to doing the operation in real time.
- This code doesn't pack the sprites PERFECTLY; it only attempts to make them "reasonably close together." Packing them perfectly would make the algorithm noticeably slower and would probably not save much space in the long run.
- Speed may also be affected by the size of the sprites. You may find in practice that packing many small sprites can be faster than packing a few large sprites. Feel free to leverage this to your advantage.
- 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
Click download now to get access to the following files:
- 64-bit DLL (and a less ancient extension system)Jan 05, 2022
Log in with itch.io to leave a comment.
So, did you ever write the documentation?