0 votes

Cube hierarсhy:

StaticBody
- 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: https://imgur.com/a/QXraHaX

Have any ideas?

Godot version v3.3.3.stable.arch_linux
in Engine by (15 points)

2 Answers

0 votes
Best answer
  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?
by (846 points)
selected by

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

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?

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.

Analyze your frame with RenderDoc or your GPU vendor profiler.
NVIDIA
AMD

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!

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

So you want a high-performance world of cubes with collision?
https://github.com/Zylann/godot_voxel

0 votes

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

by (2,394 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.