foxnne / pixi

Pixel art editor made with Zig.
https://foxnne.github.io/pixi/
MIT License
645 stars 20 forks source link

Add 'Pack tileset' option during sprite packing #53

Closed slimsag closed 1 month ago

slimsag commented 1 month ago

This adds a checkbox under the Packing tab which aims to support packing a texture atlas for tilesets better, particularly for consumption in level editor programs like LDTK.

These programs typically expect a uniform grid of sprites (e.g. 32x32px tiles) where each sprite's size is generally 'fixed', or a multiple of the smallest sprite size (e.g. you might have a 64x64px or 96x96px sprite inside a texture atlas among mostly 32x32px sprites.) - and so expect that e.g. transparency is surrounding sprites' unused space, rather than it being trimmed for more efficient packing as Pixi does today.

With the checkbox unchecked, Pixi exports as it did before:

image

With the checkbox checked, Pixi will try to export a sprite atlas that is more compatible with common tileset software like LDTK. Right now this just means it tries to export a uniform grid, not tightly packing sprites:

image

In the future, we might need some other options to support this use case better but for now this at least means that if you have a bunch of pixi files representing tilesets, you can export those and get a packed texture with a uniform grid inside it and then consume that in LDTK or other level editor software fairly easily.

Helps foxnne/pixi#46