How to optimize tile map draw calls? (SOLVED)


I have very simple layout it has just 5 tile maps and one sprite as character. And I have 360 draw calls
layer1-3 use the same tile set. main map use another tiles with different texture, so I expected that I’ll take just 4 or 5 draw calls for this scene but i have 360

upd1: I tried to remove parallax layers from the scene - so after that i got 320 draw calls. maybe it’s related to the main level tile map which has the size 300x1000?

upd2: reduced the tile map size to 30x30 draw call reduced to the 17. So it’s definitely related to the big map somehow

upd3: if i make all layers in my big map invisible draw call reduced to the same value (16) as well

upd4: One more interesting thing. If i reduce the number of used tiles in the map - like make just an empty map with 4tile width border - it also reduce draw calls to something like 100) in both cases tile map has size 300x1000


Untitled Jumper platformer

I tested this now too and can confirm that drawcalls increase as the absolute size of a tilemap increases even if the extra area is outside of the game view. There seems to be some obvious issues with tilemaps in the engine.

Perhaps use a chunk tilemap approach instead of a giant one? Maybe even use game objects for tiles and stream them in and out based on distance - that may help you reduce draw calls but you’ll still be constrained by world transformations. Should probably use Tiled for making tilemap layouts and exporting data to use.



Just hit this.
250x250 tilemap with a single layer and single tile cause 64 draw calls. I know this is not reasonable. I just wanted to test the limits :slight_smile:



Can you upload a minimal sample?



This is nothing serious. I’m trying to stress my astar native extension. Just wanted to test it with 500x500 tilemap for fun :slight_smile: Going over 128x128 is pointless. 32x32 chunk is the way to go.



This is really strange. I started hacking together a little project on saturday which uses a full screen 1024x768 pixel tilemap, with 2x1 tiles (so 512x768 tiles) which I’m manipulating quite often at runtime in small sections. I realize this isn’t an ideal thing to do, with all the loops I’m running (which is why i said “hacking together” above :stuck_out_tongue:), but I just checked the profiler, and with about 1/3 - 1/2 of the tilemap filled up with 4 different tiles, and a couple GOs on the scene as well, my drawcalls are at a steady 32.



Solved in 1.2.161