Raggar Posted August 16, 2017 Share Posted August 16, 2017 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 16, 2017 Share Posted August 16, 2017 Can you try to run a profile session to see where the CPU is mostly used? Quote Link to comment Share on other sites More sharing options...
Raggar Posted August 18, 2017 Author Share Posted August 18, 2017 I'm really bad at debugging performance. 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: Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 18, 2017 Share Posted August 18, 2017 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 Quote Link to comment Share on other sites More sharing options...
Raggar Posted August 18, 2017 Author Share Posted August 18, 2017 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. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Raggar Posted September 15, 2017 Author Share Posted September 15, 2017 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 @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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2017 Share Posted September 15, 2017 Good news Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 15, 2017 Share Posted September 15, 2017 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 Raggar 1 Quote Link to comment Share on other sites More sharing options...
Raggar Posted September 15, 2017 Author Share Posted September 15, 2017 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? Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 15, 2017 Share Posted September 15, 2017 1 minute ago, Raggar said: Was I rendering twice or something, then, since it affected the performance that way? Yep, you were rendering the entire scene twice... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.