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

Author Topic: Optimizing variable tile map rendering  (Read 1439 times)

0 Members and 2 Guests are viewing this topic.

Shuvi22

  • Newbie
  • *
  • Posts: 6
    • View Profile
Optimizing variable tile map rendering
« on: July 20, 2022, 02:22:36 pm »
Hi everyone who stopped by here. My problem is that I want to draw a tile map of about 512x512 tiles. This loads the CPU by half and the FPS is about 5-10. If I draw every other tile, the FPS increases several times. Because each tile can be changed, I can't merge all the sprites into one, or merge everything into one sprite every time. I had the idea of merging sprites into chunks(i.e. the same thing as before, but only a small part of the sprite would be recreated into one), but I don't know if that would work correctly. How good is this idea and are there any better ideas?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Optimizing variable tile map rendering
« Reply #1 on: July 20, 2022, 04:12:48 pm »
Are those tiles all visible at the same time?

Common strategies are:
  • Using a vertex array and a single texture to reduce draw calls
  • Using a quadtree (or similar structure) to determine what is actually visible on the window and only draw that
  • If you're zoomed out a lot to view all those tiles, consider using lower-res textures, which then fit more easily on one texture to be rendered with a vertex array

Generally using a vertex array should yield good enough performance even with more complex tilemaps.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Shuvi22

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Optimizing variable tile map rendering
« Reply #2 on: July 20, 2022, 05:54:55 pm »
Yes. Thank you. I recently learned about vertex array and this is what I need

 

anything