Z-Sorting with Isometric maps and Object layers in tiled


(Christopher Dumas) #1

In Isometric mode in Tiled, a layer is either always on top of the layer below, or always below the layer above. How would I make it so that an object layer interacts correctly with a tile layer in Isometric mode? For instance, I want the object to render below walls that it is behind, and above walls that it is above, to give proper 2.5D perspective. How should I accoplish this? Thanks!


(Thorbjørn Lindeijer) #2

This is unfortunately not possible in Tiled currently. It’s somewhat related to the following issue on GitHub:

But your request is a little different, in that you’re asking for an object layer to be interleaved with a tile layer. I certainly think that it would be an interesting feature to support, but it would need to be thought out carefully regarding how it would fit in with other features.


(Christopher Dumas) #3

Yes, and its also extremely necissary for creating playable games with Tiled in isometric mode.


(Thorbjørn Lindeijer) #4

Right, that depends on your game of course. Many playable isometric games have been made with Tiled, like Flare, Patchman vs. Red Circles and Brigador.

If this feature is critical to your game, then I guess you may have a pretty good idea of how it could be implemented. You’re invited to look into how it could be added to Tiled. I’m available for any questions.


(Christopher Dumas) #5

Okay, well, I’d be happy to try my hand at implementing this render setup, but my question now is, how did those games get the proper rendering order for their objects? (i.e., stuff that’s toward the back is behind stuff that’s toward the front)? I was hoping that if there was a way with tiled, there would be a way to render it in game (my real problem).


(Thorbjørn Lindeijer) #6

Alright, so in your game you can of course do whatever you want. A common approach here is to interleave the rendering of the tiles with the rendering of the moving objects. This is not unique to isometric maps, but applies just as well to moving objects on orthogonal maps.

Another common approach is to use the Z-buffer. If you associate the right “z” (depth) value with each sprite you’re drawing, then the graphics card will make sure that sprites or tiles further in the back will not be drawn on top of sprites or tiles that are in front of them that have already been rendered to the screen. This approach does not work when your graphics have pixels that are partially transparent, though.

The games I mentioned probably got around the whole issue in their maps because their moving objects are likely not part of the map. And if they were, they were probably more like marked “spawn points”, where the correct rendering order is not critical. That said, I’m sure they could have benefited from having this feature in Tiled.


(Christopher Dumas) #7

Thanks! The first option is what I had planned, the problem is that I don’t know how to render tiles individually using STI (Simple Tiled Implementation) in order to interleave the moving objects. Do you have any insight on that?


(Thorbjørn Lindeijer) #8

I would suggest you look at the source code of STI to find out how it’s rendering tiles, and to determine how you might combine it with the rendering of moving objects.