Bouncy shadows when changing RTT refresh rate

Hello,

I’ve tried changing the refresh rate of my ShadowGenerator Render Target Texture so that I can squeeze some more performance out of the shadow rendering, by not rendering it every frame.

When using the simple ShadowGenerator, I get a strange - bouncy - shadow behavior.

On line 42 in the playground, if you comment it out, you can see the expected behavior.

If switching to a CascadedShadowGenerator, the refresh rate of 60 works fine. The strange behavior seems to happen only on the simple ShadowGenerator.

Any ideas as to what might be the issue? I can’t always use the CascadedShadowGenerator, it causes bad performance, especially on mobile devices.

Thanks in advance.

You are basically in your playground generating a new shadow map only 1 in 60 frames so it is kinda expected. The bouciness is probably to account on CSM where the cascade setup might have not change in between the animations as well.

@Evgeni_Popov is there a way to also pause any CSM compute when the RTT refresh rate is lowered ?

I’m currently running on a 165 Hz monitor so probably setting it at 60 does make it a bit more obvious. I’ve captured a gif to how it looks on my side:

Both cubes rotating with ShadowGenerator:
chrome_XOZW2sHloY

Only the left cube rotating with ShadowGenerator (we should expect the shadow on the right cube to be static?):
chrome_8CMzmocGnp

Both rotating with CascadedShadowGenerator:
css

Only left rotating with CascadedShadowGenerator:
chrome_m1er3mVPPs

The wobbling is because of the recalculation of the light frustum in the x/y (width/height) dimensions based on the cube animations. Because of the rotation, the width/height dimensions change each frame but the shadow map is not regenerated to account for the changes because of the refresh rate > 1.

You should disable the auto extends computation (light.autoUpdateExtends = false) and set your own light frustum dimensions to fix the problem, either by using the shadowFrustumSize property or the orthoLeft/orthoRight/orthoTop/orthoBottom properties. Using the latter:

3 Likes