Can 2 DirectionalLights kill the frame rate?

Hi everyone,

I am not sure whether I am setting this up wrong or whether this is just a hard limit.

Please have look at this playground: Babylon.js Playground

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 :pleading_face:

Best wishes

Based on these stats, the problem remains with the fact that you have a lot to process in the shaders:

All the time is spent in the inter-frame (meaning outside of JS)


3Millions faces is A LOT :slight_smile:
It is not even related to lighting: Babylon.js Playground (

1 Like

Argh, I am an idiot, I am sorry @Deltakosh I messed up the playground. I created a proper one now (thanks to the awesome scene serializer!!):

I am adding some screenshots in case you do not get the frame drop.

@Evgeni_Popov can you have a look? I’m oof this week:)

I shoot at 60 fps with your scene without any problem. Even when the camera sees the whole scene.

1 Like

I don’t reproduce either… Have you tried in other browsers? Do you see the same drop?

1 Like

@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.

1 Like

tested the scene in chrome , could not get it to dip under 60 no matter the zoom level or camera angle / position

1 Like

To be honest if this is interframe it means that something else is locking the driver outside of the browser

1 Like

Thanks guys for looking further in to this :slightly_smiling_face:


Oh, you know what: The Inspector lowers my FPS to 40 whenever I expand the _root_ mesh. This ruins all my measurements/profiles.

Ok, let’s start again. To cut it short, there still is a frame drop (it shows 50fps due to lower resolution):

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:

Looking at Performance Profile as @Evgeni_Popov recommended:

(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?

Or is it just that simple: GPU at its limits?

Appendix 1
DevTools performance profile
for personal reference; low fps cam angle

Appendix 2 - Observations

  • 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…