Cascaded Shadow Map issue when rendering once


I’m having troubles with cascaded shadow maps when they are only rendered once.

This is how it looks when I do use:
generator.getShadowMap().refreshRate = BABYLON.RenderTargetTexture.REFRESHRATE_RENDER_ONCE;

And this is when I don’t (wanted look, but not with recalculating every frame):

Obviously I only need to render it once for better performance.
What is causing this and how can I counteract it?

Using REFRESHRATE_RENDER_ONCE with cascaded shadow maps will only work if you don’t move the camera: the generated shadow maps depend on the camera position, so if you move the camera the shadows will be off.

1 Like

Ok, so I should not use cascaded shadows if I don’t want to recalculate them every frame.

I’m a little confused why this is, since PlayCanvas seems to use a cascaded approach as well, but there it can be rendered only once:

The cascaded method gave me much better shadows, but I guess I’ll have to stick with a normal shadow map.

You will see that using SHADOWUPDATE_THISFRAME (which is the setting used when you choose “Once” in the editor) here won’t work:


Add the entry shadowUpdateMode: 1, (see screenshot) line 71: that will set the mode to SHADOWUPDATE_THISFRAME.

Excute the updated code by clicking on:

You will see the shadows are not ok.

You need to set shadowUpdateMode = 2 for the shadows to work correctly, this setting corresponding to SHADOWUPDATE_REALTIME (meaning shadows updated each frame - default setting).

You’re right, with those settings it behaves the same as in babylon.

However in the editor it does not. There is a visible performance loss when changing from Once to Realtime.

(I upped the shadow settings a bit for better distinction)


Yes, I think when you choose “Once” in the editor you are really in the "once "mode, so that shadow maps are generated a single time. But you will get artifacts, depending on your scene and how you move the camera. Note that when you choose “once” in the editor, you have a button that pops on the right which is titled “Update shadows”.

1 Like

Ok, I see where the issue was in my understanding.
PlayCanvas’ single “Shadow Generator” is just cascading = 1 and when set to 2-4 the issue when changing the camera starts to happen.
Now it makes sense to me, that Babylon only allows 2-4 cascades and not 1 :sweat_smile:

Thanks for being patient with me, I’ll have to stick with single “cascading” :innocent:

1 Like