The balls simulate a big level mesh whereas the cube simulates some player character running around in the level.
I get around 40fps. If you are still at 60fps, try increasing “n” at line 30.
Now the weird thing (to me…), it is not the shadows! If I comment them, fps remain low. If I turn off the lights however, fps jump up. I tried PointLights instead, got even worse
@Dad72 Oh, good that you mention zoom. At a high enough zoom level, the frames go up again. I thought there is some LOD-like optimisation stuff going on and did not think about it anymore.
@Evgeni_Popov I used Firefox. I have just tried Chrome and Edge; and Electron. The same frame drops. It is always the “Inter-Frame” time that goes up.
Hm, returning to the “LOD-like optimisation” I wildly guessed above. Does BABYLON do anything like that in the lighting code? Or sort of a culling on vertex level, like skip these instruction if vertex not in viewport?
Otherwise, it might be more something like, because now that lights are on and cause more stress on fps, the other underlying fps issue surfaces.
In Chrome, you should try to do a performance record of a few seconds (“Performance” tab in the dev tools). This way, we should be able to see what’s taking time.
For some reason, Firefox does not show GPU timings. In this angle the GPU time almost matches the inter-frame time. But in the next one, inter-frame time goes rogue again:
(captured with low-fps camera angle; all but level mesh disabled; lights on)
This profile is weird. I compared against a 60fps profile and those gaps are actually good, I think, because the frame finishes rendering early, right?. But why the frame drops then? Where do they come from? If the GPU was lagging behind, shouldn’t the green blobs at the bottom be much larger?
Load playground, shrink code editor.
– as is: 40fps
– disable both DirectionalLights: 60fps
– disable BLM: 60fps
– disable every mesh but BLM: 60fps
– with nothing disabled, different camera angles 40fps - 60fps
– with DirectionalLights disabled, all angles 60fps
– with BLM disabled, all angles 60fps
– with everything but BLM disabled; different angles 50fps - 60fps
**Note: Testing in Chrome now
***BLM = big level mesh
The profile is definitely weird, you have missed frames (the red blocks), where according to the report nothing happens (no time spent in the main thread, or in any other thread), but you still miss these frames…