yuv422 / png2tile

Convert PNG images into Sega Master System tile format
MIT License
24 stars 5 forks source link

Filter out blank alpha tiles #7

Open lajohnston opened 1 year ago

lajohnston commented 1 year ago

Hi there,

Thanks for this tool, it's really helping with my Aseprite => Tiled workflow for SMS game development :)

I'm wondering whether it would be possible/desirable to filter out blank 'alpha' tiles from the outputted data, i.e. tiles that don't contain any RGB pixels, which may occur in a source image that has some blank space in it. As an example, my current workflow is to construct tiled background objects in Aseprite, export full images of them, then use png2tile to convert them into a TMX tilemap. The result is de-duped tilesets (with h/v flip awareness) plus the constructed representations of these objects in the TMX that I can paste into my Tiled level tilemap, without having to reassemble the pieces like a jigsaw.

This is working fine so far, but one problem I'm having is that because the source images are full images rather than compacted tilesets they do have some blank transparent space in places, and this results in a junk blank tile being added to each tileset that is filled with palette index 0. The particular graphics I'm creating are isometric and I can't really compact them together to get rid of this space.

Would it be possible for these alpha tiles to be filtered out from the tileset completely, either by default or as an option? The resulting TMX tilemap could then use tile id 0 in place of these, which I believe is Tiled's way of representing non/transparent tiles in a tilemap layer.

Thanks!

yuv422 commented 1 year ago

Hi, yes I can see how this would be useful. I'll take a look at adding it in for you. :)

lajohnston commented 1 year ago

great, thanks šŸ™‚ Just a related thing regarding blank tiles if you get a chance to look at this, it seems the tileset PNG files (*.tmx.png) currently get padded with blank tiles to the nearest 16-tiles (so 1 tile becomes 16, 17 tiles become 32). The actual binary data doesn't contain these blanks so that's fine, but the extra tiles mean it's not possible in the custom Tiled exporter I'm writing to determine how many actual tiles there are within each tileset and how can they can fit together. As a workaround I can manually crop those images but it's just an FYI in case this fix also resolves this šŸ™‚