How to improve Gridmap performance - Octant size

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Andrea

Hello,

I recently decided to switch to 3D and i´m trying to create a very big map using GridMap.
In my plans, my Gridmap is composed by 1 single layer spread on a square up to 1000x1000 tiles (and maybe bigger in the future).
I noticed slowing down of the framerate when increasing the map dimension, but I also noticed that changing the Octant size makes a lot of difference (even if in the opposite direction of what i was expecting).

So a few question about this topic:
1 - How does the octant work? Why do increasing their size improve the performance?
2 - Is there a way to make the gridmap render using less resources (other than increasing the octants)
3 - Is there a way to make the mesh I use as tiles, to be less resource consuming while rendering? This is especially important when the camera look towards the horizon and so many meshes are rendered (any property to unflag, or whatever?)

Sorry for the newbish questions, but i couldn’t find a good answer for them around

:bust_in_silhouette: Reply From: SIsilicon
  1. Octant size pretty much determines the size of the chunks your gridmap is split into. When rendering, Godot will filter out the chunks that are not visible, and then the grid elements inside the visible chunks. So the larger the octant size, the less elements that need to be filtered individually; hence increase in performance.

  2. If you’re grid elements are using different textures, you should consider putting them all into one atlas texture. You could also enable mip maps (although you most likely already have that enabled :P), or use a lower resolution texture.

  3. You can use Lod’s for the meshes. The farther the geometry is, the lower the poly count of mesh should be. I haven’t really used them myself, but they should help depending on the base mesh you already have. Like if it is already low poly then it won’t help at all.

Hope I answered your question(s).

Edit
Godot 3.0 doesn’t natively support lod. Tough luck. Maybe it will exist in 3.1.

Thanks for your suggestion, i was already using most of them.
Maybe with LOD support this task could be managed easier!

Andrea | 2018-04-28 12:20

A related answer:
i tried to add a collision layer to the tiles of the grid, now it´s so slow it doesnt even load the map…
Doesnt matter what, anything bigger than 100x100 tiles freeze the engine.
I dont even need it for a physical collision detection, but for mouse clicking :frowning:

Andrea | 2018-04-29 19:15

Aren’t physics bodies in a collision layer by default? When you say add a collision layer, you meant to the physics body right? I’m going to look into it.

SIsilicon | 2018-04-29 23:32

And maybe its best to split the gridmap into multiple grid maps. Maybe that will help.

SIsilicon | 2018-04-30 03:01

Yes, I mean that at the beginning I was working with a mesh librabry of MeshInstance only, but then I switched to using StaticBodies in order to detect the clicks on the ground and the performance dropped drammatically.

What do you mean by multiple gridamap? One to load meshes and one for the static body?
Or spatially dislocated?

Andrea | 2018-04-30 09:25

You know like how minecraft works. The entire world is handled in chunks; but not like the chunks in my answer. So in your case kinda like manually splitting in your gridmaps spatial wise.

SIsilicon | 2018-04-30 18:46

I supposed I need to implement something in the script to make it load gradually, or either to change the way to select the map cells so that the collision meshes are not necessary…
Thanks for you help!

Andrea | 2018-05-01 11:18