Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Large tile maps with many non-tile-entities, Best Practice?  (Read 2256 times)

0 Members and 1 Guest are viewing this topic.

Notion

  • Newbie
  • *
  • Posts: 17
    • View Profile
Large tile maps with many non-tile-entities, Best Practice?
« on: April 21, 2021, 02:48:52 pm »
Hey everyone,

this is maybe rather a design problem than a "technical" problem, yet still, I think I lack some technical knowledge about how to deal with it:

Imagine a 200*200 tilemap with 100px*100px tiles. We can do that, probably in a single draw call (even though splitting it up might be helpful?). But that part is not the problem. Now assume that - in the worst case - each tile has an Entity occupying it with its own sprite (or maybe 2-3 Sprites, if they have additional icons displaying their status). Thats 200*200*2 = 80.000 Render Calls. That's a lot. Probably not gonna happen.

So, how to solve? Do I only use a sprite array of screenSize/100 sprites and panning over the map reloads the sprites of different entities into the array? So basically I dont move the view over the tiles, but instead move the index or range of entities for which the sprites should be shown right now.
Or should I just make it 2 giga-large vertex arrays, one for the map and one for all the entity sprites? They might be overlapping though, there's no useful way to quickly generate overlapping textures for tile maps, right?

Also: Given that there could be about 1000 different entity sprites each 80px by 150px, there's not way but to atlas them, is there?

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Large tile maps with many non-tile-entities, Best Practice?
« Reply #1 on: April 21, 2021, 06:43:05 pm »
in my opinion, the best approach is to use VertexArrays to the base tiles. i've used up to 200x200 with no problem at all. more than that, you may want to tear it up in chunks. and all tiles from a VertexArray are drawn at once, just a single draw call. the only downside is that all must have the same single texture source ('tileset').
we have a specific tutorial about tilemaps:
https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-tile-map

for entities, you'll probably want to have a seperate handling. maybe quadtrees ou just divide their positions in chunks (like big imaginary tiles that contains the entities, and are loaded when the player gets close)
« Last Edit: April 21, 2021, 06:45:00 pm by Stauricus »
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything