Problem with shadows shaking with the csm plugin only visible on a mobile


Here is the minimal code to illustrate my problem:

When I hold the click, the orange cube moves forward among the big green cubes (100 instances) and the projected shadows (trough plugin CSM) shake when I activate my “follow_camera_target” function.
But my fps is still 60fps.

The problem is that this problem appears only on mobile. On a computer, no shaking noticed. I have below the codepen of the code but that will not illustrate the problem… :

Here is a gif of the problem encountered on mobile :


And here is also attached the apk of this piece of code that allows to realize the concern on mobile.

app-debug.apk (1,1 Mo)

Could you help me about that ? I must admit that on this one, I have no idea where the problem could come from :anguished:


If you run the Codepen from a mobile you will see also the shadows shaking.

Thanks for your help…

Your app runs on my Pixel 2 XL with only 25fps. Maybe try to optimize something and the bug will go away?

On my Samsung S9, it runs with 60fps.


Your Pixel 2XL is normally better than my phone :thinking:

Maybe try to optimize something

  • i use instances for my big cubes (only 100 elements).
  • My CSM settings are very low
  • It’s only a flag that allow to move my cube
  • my “follow_camera_target” function runs only once since it is locked by my data.camera_could_move flag

… what could i do more ?

On my Laptop (Lenovo P15s) it runs at 40-50fps. Without CSM it runs at 60fps.

Why even use CSM? Here it looks like your entire scene has very nice shadows. (I assume you don’t use CSM there)

Yes i use csm on this app.
On huge scene, i don’t find a solution to simulate shadow correctly…

But, i don’t believe that’s it’s depending on CSM. The same scene wihtout function “camera_follow_target”. Only orbitcontrols and no problems with shadows shaking :

I think that my function “camera_follow_target” is not perfect, but i don’t see where is the problem.

Shaking visible also on PC

1 Like

Thats because the cube is so small to see the the shadows in millimeters. Make the cube 1000 x 1000 x 1000 units, this will make the shadow switching in millimeters invisible.

1 Like

I try with 1000x1000x1000, it’s not the solution…

On this game all are set like my parameters and it works without shadow shaking :

1 Like

This threejs project has high quality csm shadow

Yes Thanks but the performance are poor…


Could you test this version ?

app-debug.apk (1,0 Mo)

On my phone, no lags and no shaking shadows…

Pixel 2 XL

1 Like

:confounded: :confounded: :confounded:
why,why,why ???

It has a DPI of 3.5
Maybe try:

1 Like

app-debug.apk (1,0 Mo)

Could you test with your modification ?

I hope it’s better :sweat:

61fps without noticeable change in quality.

hoooo thank you.

1 Like

No shaking

1 Like

Thanks for your test