I'm using Tiled Map Editor to generate a tile map for my game in libgdx. I noticed while creating a simple map that having two tile layers causes many extra texture bindings. I'm using 2 packed tilesets and NOT using individual pngs.
For example, here is map with 2 tile layers with 2 tilesets. The dirt is from 1 tileset, while the rocks, trees, and other objects are on a different tileset.
This causes 25 texture bindings.
However, if I delete the layer with the rocks, trees, etc. and only leave the dirt, I get 1 texture binding.
Is there a better way to achieve this? Again, I'm not using individual pngs for the tiles, they are packed into 2 tilesets. What are the work arounds for this? To just pack everything into 1 tileset? I have some maps that are causing 80+ texture bindings.
Not really doing anything weird to render the map either:
class MapRenderer {
private TiledMapRenderer tiledMapRenderer;
public MapRenderer(TiledMap tiledMap, float tiledMapScale, Camera camera) {
tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap, tiledMapScale);
tiledMapRenderer.setView((OrthographicCamera) camera);
}
public void update() {
tiledMapRenderer.render();
}
}
Sort of seems like it is rendering each tile, tile by tile. When a better way to reduce texture bindings would be to render each tile by tileset.
When you create the tiled map, create separate layer for tiles from each tileset. This way you will have only 1 extra binding for each tileset.