Tilemaps sprites API


Is there any tilemaps API in PlayCanvas?
I mean something like pure canvas api (https://developer.mozilla.org/en-US/docs/Games/Techniques/Tilemaps/Square_tilemaps_implementation%3A_Static_maps) but using PlayCanvas sprites.

Input: tilesets and tilemap layers. Output: rendered sprite.

Only example I found is Procedural Levels (https://developer.playcanvas.com/en/tutorials/procedural-levels/). It clones entities - looks like it can have not very good performance on weak devices (e.g. mobile). Is that right or maye there are some engine optimisations under the hood?


Your best bet is to leverage Texture Atlases for that:

Here is the relevant entry to the manual and the available API:




I think the OP is wanting to render/draw the tilemap background in a single/as few as draw calls as possible


Right! Batching is not available through the editor for sprites/elements, it was removed at some point, temporary I think, due to some issues with the drawing order.

But the property is available through code for entities having a sprite component. You can set the batchGroupId property to a dynamic or static batching group ID to see if the batcher will pick them up. I haven’t tried it myself but it might work:


Here you can read more about how PlayCanvas batching works:


Sprite Batching

Leonidas, thanks for response. I’ll try batch group id later.

By the way, I wrote simple test shader for tilemapping. Maybe it will be usefull as a starting point for someone else


Nice, that’s a very peculiar way of rendering an ISO grid in a pixel shader.

Thanks for sharing!