Directional light performance issue related to castShadow

Hi, I found a performance issue with directional light. There are two situations that will cause frame drops related to castShadow.

In the scene, there are some models that have castShadow enabled.

A. When castShadows are disabled on a directional light, the frame rate starts to drop.
B. When castShadows are enabled on a directional light, but as the camera moves away and those models are beyond the shadow distance, the frame rate starts to drop.

Here is an example project which can reproduce: project link
It’s quite strange because disabling castShadow on light or moving away from models that cast shadows make the performance even worse.
We rollback the engine version from six months ago still encounter the same issue.

Hope someone can help look into it, and I hope it can be fixed. Thank you. :man_bowing:

1 Like

Hmm. I can’t seem to reproduce. The framerate is stable for me, regardless if the shadow casting is enabled or disabled. What browser is it? Are you on Mac?

I cannot reproduce this either. I capture this in profiler in both cases, and both CPU and GPU gets cheaper when characters are far away and so they don’t get rendered to the shadow map.

After several tests, we have found that this problem occurs on macOS ARM M1 with Chrome 123, but it works fine on Firefox. Some iOS devices encounter it in our own project, but we can’t reproduce it in the sample project.

We will keep tracking the problem! Thank you for taking a look at this.

with mac on chrome there was massive performance regressions when it uses the metal backend. have a look in chrome://flags and try setting “Choose ANGLE graphics backend” to OpenGl and see if you notice any difference.

3 Likes

Thank you for the information! Yeah, when I change the options to OpenGl the frame drops problem disspear. That’s so sad, the deault setting for the users might be metal backend on Mac chrome like mine and need to wait for browser to resolve it. :smiling_face_with_tear:

2 Likes