low frame rate when looking at SurfaceTool terrain mesh

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

hi there,

after a year of abstinence i went back to an old project of me.
The reason why is stopped developing stands in the title.

But now iam interessted about whats going on.

Description of the project:
I have a little bit more complex Godot project to test different things. One bigger part of that is a terrain generator (i call it “Surfafe”, it sounds like “surface” spoken from a german when eating a hot potato :smiley: :D).

You can find this part of my project here (100% gdscript):
(Its a node, but im not sure if its cleanly standalone :smiley: )

This is roughly how it works:

  • I split the world in “sections”. one section per default is 16x16x16 blocks tall.
    Each block is defined by its corners and is generated with marching cubes tables.

  • A simpel noise generator generates data for a procedural landscape (very basic)

  • Up to now it generates a predefined number of sections, when the game starts. No generation while playing atm.

  • It has a LOD-system included (disabled per default) which generates each section for lower resolution (but there are still missing the transitions)

The Problem:
Generation works well for me. But when you generate a bigger terrain you get a very low frame rate. But i do not really understand why.
For example i added a 3D-model with about 250,000 vertices made with blender. It runs very smoothly. I can add 10 of them with no problem.

But when i generate a terrain with my generator it has very low performance when it has about 300,000 vertices and i look in its direction.
If i look in another direction (empty space) the fps raise to normal.

Here some screenshots:

Tested in Godot 3.1.1 (then) and now in 3.2.3
Hardware: amd ryzen 7; geforce 1080

I would be happy if someone could explain to me what I am doing wrong :smiley:

thx :slight_smile:

:bust_in_silhouette: Reply From: Calinou

Your script is spending 77 milliseconds in _process() on every frame. This means you’re running heavy processing in your script, likely because you’re doing something every frame when you didn’t intend to.