BBoxes
A downloadable tool for Windows
BBoxes
[GameMaker] Library for finding 2D bounding boxes by utilizing power of GPU.
With this asset you can find bounding box of a surfaces or sprites by utilizing power of you graphics card. You can compute bbox for several images and surfaces at the same time, so only single GPU-to-CPU readback is done for all requests.
Note, that this asset requires support at least "rgba16float" surface format, and for larger than 2048 images you need "rgba32float".
This can also be utilized outside the game, for example during compiling you can run bbox-calculation for your included assets.
---
How asset actually works
The sprites and images are placed into a surface, which uses floating point numbers. This means it can represent numbers other than 0.0 to 1.0. In practice rgba16float can represent all whole numbers up to 2048, and rgba32float can represent higher than that. So those are plentiful to represent pixel positions. The images are placed into surface, and shader is used to pick up pixel coordinates for non-transparent pixels.
Then surface contents are reduces by drawing into another surface, and finding min-max values for each 2x2 area. These surfaces are swapped, and step is repeated. This reduces each item, until each item has size of 1x1, containing their min-max values of whole item.
In practice, items can be different sizes, which makes things hard. This is handled by placing each input item into own "power of two" -slot, and placing items in Z-curve order. This doesn't directly solve the problem. But during reduction steps, largest items will be reduced into smaller ones, therefore at some point they will have the same size as the smaller items.
So all items are not immediately inserted into single surface, instead items are inserted whenever it's their time.
---
Originally made for Cookbook Jam #5
GitHub Page includes simple examples. The asset includes example how you can use it.
https://github.com/HannulaTero/BBoxes/
(The entry was bit rushed, so it might have bugs. If you find any, please inform)
Download
Click download now to get access to the following files:

Leave a comment
Log in with itch.io to leave a comment.