Jump to content

[SOLVED]Optimizing this Scene?


Raggar
 Share

Recommended Posts

I'm looking for ways to optimize a scene I created in the Playground. This scene is based on previous work from another thread, I just added some objects and logic to mimic a small game.

It uses native CannonJS for the PFS-camera and movement of the monster models. I used the code and model from the instances demo.

From line 16, you can turn on and off physics for the monsters, skeletal animations, the skybox, trees, shadows, procedural textures(grass), and whether or not the monsters should lookAt and follow the player.

As well as specify the amount of trees + the range and amount of monsters.

https://www.babylonjs-playground.com/#FZZV7K#23

I'm only hitting around ~30 FPS with this example. Is a scene such as this too heavy for WebGL and browsers?

The trees are instances, so unless I clone and merge them, I don't see what could be changed there. Maybe a smaller, compressed texture.

The monster models all have skeletons and animations, so no instances or merging can be used here.

Disabling physics seems to give some FPS boost, so maybe using a worker would do some good in this example. I'll give this a try, and see what effect it has on overall performance.

Here's a minimized version, with most things stripped, and 50 monsters without animations.

https://www.babylonjs-playground.com/#FZZV7K#24

 

Link to comment
Share on other sites

I'm really bad at debugging performance.

HA0qsRO.png

2spYH7R.png

kBhnyGd.png

I'm trying something different to get a performance boost from the animated models, as these seem to drop FPS rapidly when animations are playing.

Same with trees. I'll try making simpler models, small or compressed textures and maybe merge them instead of clones. Will merging have any gains over instances?

 

 

Edit: Here's a full capture:

DW5zWvc.png

Link to comment
Share on other sites

So, we must use an organized approach here :)

- First try to remove everything and start adding feature one by one until you see a real FPS drop

- I'm concerned by the long call to updateDynamicVertexBuffer. Are you updating your meshes data dynamically?

- You have really high number of vertices (half a million). You should try to reduce this number a lot

- Draw calls are good so keep using instances

Link to comment
Share on other sites

The second playground I linked to(24), is a stripped down version. I'll give it a try this weekend, adding functionality one by one, while trying to reduce the number of verts by simplifying the monsters as well as the trees. Maybe try the SPS Tree Generator, as well as the Quick Tree Generator + instances or merging.

Link to comment
Share on other sites

  • 4 weeks later...

We're hitting a month since I started this thread. For god knows what reason, I suddenly wanted to make a fish tank with a neural network and genetic algorithms, so I was kind of stuck in a weird loop doing that :P

@Deltakosh

In my particular project, the individual models do not need to have different animations at different times, so I tried comparing clones to instances.

Using clones, I hit around 50FPS when having 40 models, but hit the same FPS using ~250 instances. This is certainly an improvement.

Clones:

https://www.babylonjs-playground.com/#2I6IG4#1

Instances:

https://www.babylonjs-playground.com/#2I6IG4

Link to comment
Share on other sites

24 minutes ago, RaananW said:

Just a general note - you don't need to add the render loop in the playground. Removing those lines (almost) doubles the FPS :)

here - https://www.babylonjs-playground.com/#2I6IG4#2

 

Lol. I tried with 80 clones, and it stuck close to the 60FPS. Was I rendering twice or something, then, since it affected the performance that way?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...