0 votes

I have a terrain model exported from blender(it was generated from a heightmap and has about 16k faces), in my scene there are also 1400 trees which are 140 faces each. So all up about 220k faces. When adding the trees and terrain to my scene, the framerate drops from 60 to 40ish which lead to my thinking I must either be doing something wrong or need to do some optimising. I have heard Godot is not well suited to this sort of thing currently but I'd like to try optimise where I can.

Should I be trying to reduce the faces in my terrain? Or using MultiMesh? I have clumps of tree models in forests so perhaps each forest should be in a MultiMesh? Then I have also read about whether I should be trying to load parts of the terrain in chunks.

asked Mar 30 in Engine by Wallace99 (95 points)

16k faces per se is basically "nothing" even on mobile devices. But if you use some specific shader for the terrain (i.e. a splatmap shader) that could be part of the performance degradation.

The trees most certainly would profit from LOD. But you'd have to script it yourself. Make sure that the script won't worsen the performance though (i.e. 1400 scripts with a _process handler each is a bad idea).
LOD would mean either just toggling the visibility of the trees or replacing them with lower detailed meshes, maybe even with a simple billboard texture (using alpha or alpha scissors transparency). Also using MultiMesh might simplify the LOD approach as you will have less nodes to process (transition might be more noticable though).

Anyway I'd evaluate each step one by one.

2 Answers

0 votes
Best answer
  1. Find a way to use LOD for the terrain. For instance, you could design the terrain using the Godot Heightmap plugin. If you plan on using Blender anyway, you'll have to find a way to chunk the terrain and export it with several detail levels so the face count is more reasonable.

  2. Look at using MultiMeshes to decrease the number of draw calls. You want to batch small groups of trees together rather than batching all trees in the same MultiMeshInstance. Otherwise, view frustum culling won't be able to cull any trees since MultiMesh culling works in an "all or nothing" fashion.

answered Mar 30 by Calinou (5,674 points)
selected Apr 2 by Wallace99

Ah thanks I'll check out the plugin and multimeshes too. So you think the face count could be a significant factor in dropping framerate?

Yes, but it may not be the only bottleneck (or even the main bottleneck). While polygon count isn't important on desktop as it used to be, you should still strive to avoid unnecessarily dense polygons (which is a recurring problem with terrains that don't use LOD).

I've switched to using the heightmap plugin you suggested and been quite impressed by its results. Still trying to decide how to approach trees. I'm wondering if perhaps I even need to have each tree collideable as with multimesh it seems it's just the mesh with no collision info. Perhaps I could add multimesh forests and manually lay out collision shapes for the areas where the player can't go

0 votes

Please take a look at Occlusion Culling

Optimization techniques are another big area of graphical programming.

answered Mar 30 by rpggeek (33 points)

Cheers I will have a read of that. I've noticed that regardless of whether the trees are in the scene, the terrain model still seems to result in low frame rate. I tried re exporting in blender with the vertices reduced by 80% but still poor frames which doesn't make sense to me. In the profiler the number of vertices drawn gets up to 1 million occasionally which I assume is quite high? I'm going to try look at what I could be doing wrong with my terrain model in blender

The lack of occlusion culling is most likely not what's slowing down things here. (When you have a depth prepass like Godot does in GLES3, there's not much else you can occlude in a terrain-based game. LOD, however, is essential to have.)

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.