How to optomize for many nodes in world? Performance problem

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

Cube hierarсhy:


  • MeshInstance
  • CollisionShape!

I generate test world 200x200 (40 000 cubes, it’s 120 000 nodes). FPS is ~3. In reality, the world will be much larger. Is there any way to optimize this? I have an idea to use large textured cubes, but this is a crutch for my game.

Cubes don’t have attached scripts. And I tryed to use only MeshInstance, it’s did not help. I think the problem is precisely in the quantity, each tick of the engine causes some kind of heavy API for each node.

Screen: Many nodes problem - Album on Imgur

Have any ideas?

:bust_in_silhouette: Reply From: yrtv
  1. Load and unload world in chunks. Do not load entire world at once.
  2. Is Collision layers setup, or you have 120 000 static bodies colliding every frame?

Yes, I used collision layers. And I tryed use only MeshInstance without CollisionShape, it had no effect.

InterVi | 2021-10-05 10:12

MeshInstance Renders 120000 unique cubes.(nothing is shared)

MultiMeshInstance renders one cube 120000 times.(all mesh data is shared)

Do you need 120000 unique cubes every single frame in your game?

yrtv | 2021-10-05 10:40

I tryed MultiMeshInstance, I get 150ms frame time and 7fps. Using only MultiMeshInstance get 50ms frame time and 20fps (if use random color, this down to 7fps). Well, it partially helped me, thanks. But more optimizations are needed. No, there will not be many unique cubes.

InterVi | 2021-10-05 14:22

Analyze your frame with RenderDoc or your GPU vendor profiler.

yrtv | 2021-10-05 15:57

I didn’t fully understand the work of MultiMesh, it seems that I didn’t use it correctly. I’ll write when there are results. Thank you, you helped me a lot!

InterVi | 2021-10-05 17:44

Now I used MultiMesh correctly, I get 60fps. This was a necessary optimization, the problem was resolved. Now I will experiment with CollisionShape. Thanks!

InterVi | 2021-10-05 23:28

So you want a high-performance world of cubes with collision?
GitHub - Zylann/godot_voxel: Voxel module for Godot Engine

yrtv | 2021-10-06 05:54

:bust_in_silhouette: Reply From: Inces

Is every single cube important in unique way, or is it only visual ?

If it is only visual You could just use one flat cube and write shader for it, or use a particle shader