Open world optimization

I’m trying to make an open world out of tiles, but it works slowly. Each tile is a separate mesh. The drawing distance is the minimum required. And there will be more objects, how can it be optimized?

If I use “tiledGround” or merging meshes, will it help?

location

Hi,

I have made an open world game using babylon, and performance is not an issue for me, I have around thousands of objects in a scene.

This what I’ve done for better performance:

  • Streaming data and offloading computing into web workers so less work for the main thread.
  • Using instances.
  • Freezing objects not needing updating.

Here is a great source for information: Your Journey Starts Here | Babylon.js Documentation

Good luck :slight_smile:

4 Likes

Thanks for the tips

The problem is not in the rendering. Instance, lodLevel, freeze, and other graphical options do not help much. The larger the size of the world and the tiles in it, the more it slows down. And the player sees only a small part on the screen.
But I’ll try something else.

Have you tried scene.freezeActiveMeshes method ?

This may help as it reduces the number of meshes that need to be updated babylonjs.

The first rule of optimization - measure. Did you open a profiler or inspector?

2 Likes

A good feature, but it causes lag when used. If i freeze meshes once a second, for example, then fps will drop once a second. Thus, solving one problem creates another. I do not know how to use it effectively

In my code, I freeze or unfreeze meshes individually:

To reset the active meshes data instead of rebuilding them, you can use the following code:

scene.getActiveMeshes().reset();
camera._activeMeshes.reset();

This will reset the active meshes data without rebuilding them.

I’m not sure if this is the recommended way of resetting active meshes data :slight_smile:

@ARAMONIS what is the biggest you see in the inspector ???

I specifically tested on a weak PC, I want to achieve stable frame rate on it. It’s easier to identify weaknesses this way. If it succeeds, then you don’t have to worry anymore. On average, it outputs 30fps at a small location. But the location should be 2000x2000 tiles, and in this case it gives 1 fps

We can not help from only this information. We need to know the exact hot path in your code to see what it the best strategy to address it.

What do you see as your biggest hit in the Chrome dev tools ?

I think I have an idea. Freeze the entire location and manually unfreeze only the area around the player. But is it possible to completely freeze only one mesh? I have not found a corresponding method

mesh._freeze() should do the trick