TileExtruder tool (helps remove seams in tilemaps)

Monkey Archive Forums/Digital Discussion/TileExtruder tool (helps remove seams in tilemaps)

Nobuyuki(Posted 2015) [#1]

I wrote a tool today in an attempt to help reduce problems with using autofit and tilemaps in mojo1. This tile extruder is a commandline tool which takes the edge pixels of each tile in a tileset and repeats them backwards for the amount of extrusion padding you specify. It can also pad tiles with blank space.


This should (in theory-at least!) reduce or eliminate any seams and moire effect you notice in your tilemaps when resizing the main canvas using autofit or AutoScale in mojo1. I haven't been able to test this in any of the current frameworks however! Please let me know if this works for you.

Requires .net 4.0 framework to run.....

Samah(Posted 2015) [#2]
I've fixed the Diddy Tiled engine to work properly with extruded images, too. It wasn't calculating the tile count correctly from the margin/spacing settings in tmx files.

Nobuyuki(Posted 2015) [#3]
cool! I'll check for a diff and apply the relevant changes to my fork.

tiresius(Posted 2015) [#4]
Does mojo2 have the same tiling problems you are trying to solve?

Nobuyuki(Posted 2015) [#5]
no, with mojo2 I'm pretty sure you can blit all to one surface at once, and then resize all of that. However, none of the frameworks (except maybe Pyro?) support tilemaps in mojo2 yet. This is most useful for mojo1 where you don't have fine control over this without resorting to direct ogl calls or externs. By setting the extrusion factor to at least 1 pixel and the spacing to 1 pixel, you can virtually eliminate all seams in tilemaps and anything else that you would normally stitch together. Diddy's tilemap now supports this feature, and you can enable its usage either directly from Tiled when creating a new map, or by editing the TMX file directly for an existing map (I'm not experienced in Tiled enough to know if margin/spacing can be altered for tilesets after they've been loaded into a map).

Another example of its use in mojo1 would be using this tool to facilitate "glass block" anti-ripping measures to keep casual people from viewing certain images in your data folder -- running an image through the extruder at your specified block size, then using your own tool to take each block and rotate/flip them using a cypher of some kind. I may even write this functionality into the tool at some point.

Samah(Posted 2015) [#6]
@Nobuyuki: ...then using your own tool to take each block and rotate/flip them using a cypher of some kind...

Tiled actually has support for rotate/flip in the file format, but it's not supported in Diddy at the moment. Let me know if you add it to your tool and I'll add support for it.

therevills(Posted 2015) [#7]
I've got 3 tiles in a 16x16 tile set, which I've extruded by 1 pixel X and Y:
TileExtruder.exe tiles.png size=16 pad=1 space=0 tilese.png

How do I load it into Tiled so Tiled will render it correctly? I've messed with margins, offsets etc but when I load it into Tiled it displays it as 4 tiles instead of 3.

Playniax(Posted 2015) [#8]
However, none of the frameworks (except maybe Pyro?) support tilemaps in mojo2 yet.

Yes, it does (grab the latest update for the brand new Tiled importer).

Nobuyuki(Posted 2015) [#9]
therevills: The extruder and Tiled use different definitions for what it's expecting :( It can be frustrating to get it "just right", and if I remember correctly, you might need to use even numbers in the extruder (don't quote me on that) because Tiled doesn't use full pad in all directions but one direction only. So, I believe you need to set Tiled's spacing to double the combined pad and spacing values you give TileExtruder, then the margin is the pad value from TileExtruder.

For example,
TileExtruder.exe tiles.png size=16 pad=2 space=0 tiles.png

In the tmx file (or set from within Tiled when importing):
 <tileset firstgid="1" name="tiles" tilewidth="16" tileheight="16" spacing="4" margin="2" tilecount="3">
  <image source="tiles.png" trans="ff00ff" width="60" height="20"/>

Playniax(Posted 2015) [#10]
It still baffles me that this problem is left to the programmer to be solved in this modern day and age! For Ignition there is a tool that solves this for you but still it is an inconvenience. However, Pyro, because it uses Mojo 2 does this a lot better. The tileset class has a command called: 'DuplicateBorders' so you don't need to make any changes the tmx file although it now only works for orthogonal maps. Currently I am looking in to Isometrics also. In my experience, giving the tiles a double border and enabling padding works best. I suspect TILEEXTRUDER TOOL is doing the same?

Nobuyuki(Posted 2015) [#11]
The tool bakes extrusions into the tile set itself. This is done to reduce the amount of blitting necessary at runtime.

Playniax(Posted 2015) [#12]
Thanks, I understand. Pyro does the same. After the tilemap is loaded and the tileset is created etc. you can use the command 'DuplicateBorders' to do this for you. This means you can just load any tilemap without having to use a tile extruder everytime you change the tile bitmap. But I left it to the programmers control in case they prefer to use another way like your tool tile extruder instead.

therevills(Posted 2015) [#13]
Thanks Nobuyuki, I'll use your example settings and they work fine.... it was doing my head in!