Is it a bad idea to have only one TileSet?

Godot Version

4.2

Question

My game has a lot of tiles and I’m unsure if I need to create multiple TileSets.

In terms of where and when different tiles are used, there are at least four groups:

  1. General tiles (used in multiple scenes)
  2. Scene specific tiles (mostly used in one scene)
  3. Seasonal tiles
  4. Placeable tiles

Usually scenes will have tiles from multiple groups. Right now my solution is to have one TileSet that contains every single tile. The TileSet consist of multiple TileSetAtlasSources so it’s easy to find tiles and use the TileMap.

Having multiple TileSets would mean that I would also need multiple TileMaps if tiles from different TileSets are used in the same scene. That would make editing scenes harder and I could accidentally place multiple tiles in the same spot.

It seems that all TileSetAtlasSources are loaded by default even if no tiles from that source are used. I checked this with ResourceLoader.cached(). It is possible to make TileSet resource unique and then use TileSet.remove_source() to remove and free a TileSetAtlasSource that is not used in the current scene. I’m not sure if that is a viable solution.

Yes, I know you should not optimize too early but creating a TileSet with collisions, custom data and autotiles is very time consuming and afaik there is no simple way to later combine different TileSets or divide them into smaller TileSets. I want to make sure that my approach makes sense.

TLDR:

Is it a bad idea to have only one TileSet? Will it have any significant impact on performance?

if your entire tileset atlas fits within one GPU memory page, which iirc these days if about 4000x4000 pixels (but a power of two duh) then it makes no difference. If you use multiple tilesets, each atlas may get its own memory page of the appropriate size. If you use a larger tileset you may get automatic splitting or an error. In any case, the rest of the tileset that is not the atlas image is all individual objects that will have about the same memory footprint no matter what.

Say you are using 32x32 tiles. This means you have to make 1024 tiles to cover a 1024x1024 atlas. that’s how large GPU memory pages were a decade ago. I believe they are 16 times larger, as I said, btu definitely 4 times larger.
Do you intend to have more than a thousand tiles?

If it’s comfortable, put all your tiles in the same tileset, it’s fine, it will be loaded once at the start of the game process and never need to be loaded again, and even better, it will be uploaded to the GPU once and likely stay there the entire time the graphics context lasts, which is good. But this would be a benefit in 3D games with lots of textured polygons. On 2D it’s a tiny benefit that barely factors in performance.

teal deer: do it, it’s fine and good

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.