I am working on optimizing a VR project.
The scene I am working with is containing a large city with a lot of buildings that are static, a few dynamic objects and there are 2 directional lights.
Because I only animate the light color and intensity, I made the 2 directional lights stationary and baked the whole lighting.
The stationary light will only cast dynamic shadows on a few dynamic objects and the rest (about 90% of scene) will use the baked shadows.
With this setup I couldn’t get 90 frames per second and I noticed when I switched both lights to dynamic I did get 90 fps.
So in this case it seems that it is faster to calculate the shadow for the whole scene dynamically then using stationary lights.
I noticed in the GPU visualizer that when using dynamic lights, that mainly the shadowdepths renders faster then when using stationary lights.
When I open the shadowdepths I see that when using dynamic lights It will have a few large shadow maps for a few “WholeScene split” items.
When using stationary lights the shadowdepths renders slower and it will contain a bunch of smaller shadow maps for each dynamic item in view.
It seems that splitting the whole scene up in a few shadow maps is faster then using more but smaller shadow maps.
When using stationary lights I set the “dynamic shadow distance stationary lights” to zero.
This is the only way I found to let the engine use baked shadows for all objects except the dynamic objects.
Could there be a way to get the dynamic shadows from stationary lights render faster or should I just use dynamic lights for everything although it seems so inefficient?
Below a screenshot to illustrate the differences in the GPU visualizer