Announcement

Collapse
No announcement yet.

Looking for a good approach to render tiled-based maps efficiently

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Looking for a good approach to render tiled-based maps efficiently

    I am creating a grid- or tiled-based map system in C++. That system uses quadratic meshes as ground planes for each grid cell.
    Maybe something like this (just an example, not my game):

    Click image for larger version

Name:	9d0cf182aa9af61f8c4b3675c9cfdeea.png
Views:	1
Size:	47.0 KB
ID:	1599009

    First I tried to create a new simple actor, with a static mesh component, for each grid cell / ground plane / tile. But it turned out for large maps (say 100 x 100 = 10.000 map cells or even larger), for example when rotating the camera around the map zoomed out, then FPS would drop drastically. I thought that are just too many actors transformed each tick.

    So I changed the system to use instanced static mesh components with one single actor instead. That works fine also for such large maps. However, now I encountered the problem that every time I remove a mesh instance (to replace it with another tile / mesh instance) that removal takes a bit of time, which adds up when I remove many mesh instances at once. From my research this seems to be normal ISM behaviour.

    So ... what would be a better approach to deal with this requirement of tile- or grid-based maps built UE4 via C++?
    Modular Menu System @ UE4 Marketplace: "Build your UMG Menus in Minutes!"
    Marketplace Page | General Discussion | Support Thread | Preview Video

    #2
    Hi,
    Are you using memory pool to keep the reference memory of the tile and just reuse it instead of creating another one ?

    Comment


      #3
      When I replace a tile with another one then I remove the mesh instance of ISM component A and add a new mesh instance to ISM component B.
      Modular Menu System @ UE4 Marketplace: "Build your UMG Menus in Minutes!"
      Marketplace Page | General Discussion | Support Thread | Preview Video

      Comment


        #4
        Instances in an ISM are just a linear list of transforms. Removing items from arrays like that is not optimal, since all elements after the removed item must be shifted. You need a different way to manage the instance arrays more effectively. I don't know how you are keeping track of which index in which ISM component each tile is, so here are some ideas:

        - You can copy the transform of the last instance in the array into the index you removed. This way removal would be super fast, but the order of the items will change so you'd need to keep track of this somehow when you need to change this tile again.
        - You can try to set the scale of the instance you removed to zero and add its index into a list of "free slots". When adding a new instance, reuse the indices from the "free slot list". I never tried this, so you'd need to set to see if there's any overhead to having zero-scaled instances

        Also, remember that ISMs don't do per-instance culling. If any part of the ISM component bounding box is visible, the whole thing is rendered. So if your level is much larger than what the camera can show, it would be wise to break your level in smaller "chunks" of tiles. Changing one 16x16 or 32x32 chunk's instances would also be much faster than changing the instances of one massive ISM with several thousands instances.

        Comment


          #5
          Thanks for your ideas Manoel.Neto, I will have a look at your ideas!
          Modular Menu System @ UE4 Marketplace: "Build your UMG Menus in Minutes!"
          Marketplace Page | General Discussion | Support Thread | Preview Video

          Comment


            #6
            I am more and more thinking that this whole ISM idea is not the best approach. Wouldn't it be better to have a "normal" landscape actor (i.e. only one mesh) and only place the tile textures or materials (e.g. for a road) via decals on to the ground? Or is there a better way to "paint" textures/materials in a grid on to the landscape actor?
            Modular Menu System @ UE4 Marketplace: "Build your UMG Menus in Minutes!"
            Marketplace Page | General Discussion | Support Thread | Preview Video

            Comment


              #7
              If you're not going to be changing heights like the picture you provide, paper2D has a really nice map editor.
              https://youtu.be/Tf9Qd4isHTM?t=967

              Might be worth checking out. Even if you plan to change heights, you may be able to utilize this feature.
              Unsure if this can be changed at runtime though or if it's editor only, if you play to do some sort of dynamic level creation.

              Comment

              Working...
              X