0 votes

I am working on a game where you can build Lego bricks but its realy lagy because of the little cylinders on top of the brick. How can I optimize it for better performance ? I downloaded demos for Multimeshs but I have no idea how to get a better performance.

Godot version 3.2.2
in Engine by (251 points)

1 Answer

+3 votes
Best answer

For sure, multimesh is a big option for improving performance but you have to do it right, it comes with an overhead so misusing it can easily cost you performance.

You've not given a lot of detail on what your project consists of so there's a limit to how specific my recommendation can be. But, to give you an idea, my game has a comically small spherical world with 10,000 radius, 1.2bn sq units, so I need 45 million objs to make it look remotely full and I get 120 fps with Godot. Plus, I only think about optimisation when I have to, generally it's much better to think about getting the functionality in place / development done quickly than sweating the optimal solution at every corner. Trick is, you put a few things in place to limit rendering far away and work around that. You only need stuff near the camera. The rest of the world can go to hell.

Ok, so you've got lego galore I assume. The drawback with multimesh is that it doesn't cull objects behind you like an instancemesh will. That means that you're paying for every obj in the scene, even though the rendering is optimised. Much better not to render than to render optimally. So, loop some multimeshes and make "chunks", toggling their visibility when they're not needed and let the engine decide if the remaining one's are visible. Are you calculating position of every block on the fly? Why not make a "lego terrain generator" and do that beforehand and just loop through the file on startup? Thousand times quicker.

Another amazing option is particles. They don't have to move, they can just hold objs and you can hand the processing over to your gpu - a device designed to deal with large numbers at once.

Another thing to do is lod, do you need to render a million verts in the far distance? Probably not. Just mark the high def one not visible and put a low poly one in its stead.

I can only talk in general because your question wasn't specific and optimisation is a very game specific thing. What works for Civ5 doesn't work for GTA5. The general rule is: pay for what you need and no more. Use the tools Godot gives you optimally and any game can run fine.

by (1,541 points)
selected by

I must say, this is a genuinely great advice!

The LOD part is also quite important. Triangles that are smaller than a pixel on screen have to go through a slower code part on the GPU, which is why they tend to slow things down.

Thanks for your great answer. I will try to implement a part of your solutuions.

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.