Say you're rendering a 2D top-down tile map and there are some objects in the tile map that the player should be "in front" of when below them, and "behind" when on top of them. Like in this example screenshot:
This works because the player is on layer 1, the top two tiles are on layer 2, and the bottom tile is on layer 0.
Let's say in this example that the object has no collision. If the character then walks up, then the character will be half-in-front and half-behind, like this:
The reason why this is a problem is because with tiles, they don't really have a concept of state. If the 3 tiles were part of the same "object", then this wouldn't be a problem, because we could just render the entire group of 3 tiles as a single sprite, and then sorting could be done, and the entire sprite could be rendered behind or in front of the player.
However, with tiles, this knowledge isn't known, as they are purely decorative numbers.
One possible solution is just to instead forsake tiles for these sorts of objects, and force them to be entities in the game itself as opposed to just tiles, but because there can be many of these, that would be a performance hit. It also complicates the logic.
Is there any better solution?