Tilemap Layers performance

Engine guys :slight_smile:

We want to use tilemaps for our mobile game but am not sure about the impact of tiles and layers in a tilemap.

  1. Are all layers part of the same mesh in the end or is each layer one single mesh/geometry that needs to be handled by the gpu?
  2. If I have one base layer with all tiles filled with gfx and another layer with just a few tiles having filled in gfx will the second layer still have the full geometry? (all empty tiles still made up with quads in the mesh that needs to be handled and even worse, rendered?)
1 Like

AFAIK, each layer is a mesh, and multiple meshes are used as your tilemap dimensions grows in size. So if you have 2 layers with a large tilemap you get 2x as many meshes and there’s a drawcall for every mesh.

Me and @Mathias_Westerdahl did a quick check in the code, it works something like this, simplified;

  • The tilemap is divided into “regions” (a region is max 32x32 tiles).
  • Every region results in one “mesh”, all layers within that region are included into the same mesh.
  • Empty tiles does not generate vertex data.

Makes sense? :slight_smile:

7 Likes

Thanks! Exactly the info I needed. Want to be able to optimize as much as possible.
Also made me happy layers are embedded in the “mesh”.
I guess there is no culling on the regions that are outside of view? :wink:

/A

2 Likes

Sadly no culling at the moment! :frowning:

1 Like

Why do multiple layers along with number of regions increase the number of draw calls?

For culling, you could allow us to give a range in x and y to draw which we can manually update.

2 Likes

No culling yet yet?

My guess was it was aleady implemented, since once of the good things of tilemaps is the easy of detecting what is seen and what is not. (Maybe is not that ease on defold because we can rotate them… )

Please confirm is this idea make any sense to implement: Can I use multiple tile maps for “sections” of my level and use “disable”/“enable” messages (if they exist on tilemaps) to keep active only those tilemaps that I know would be visible?

Yes, this is probably what you want to do and should work. Chunk your world into multiple tilemaps, enable/disable them as needed.

1 Like

Great, thank you. I don’t see the enable/disable messages on tilemap reference I guess is something supported by most Defold objects. right?

Btw, one more question :slight_smile: … is it possible to disable a Layer? Or I need to fill with zeros :-o ?

Not sure, you might need to make a feature request. Or use multiple tilemaps per layer. Filling with zeroes does not sound right that would probably still add to draws.

1 Like

Yes, the enable and disable message works for all components.

No, it’s not possible.

1 Like

Search for “disable” in the docs and you’ll see this:

1 Like