SHADOWUPDATE_THISFRAME not working

Hi,

is SHADOWUPDATE_THISFRAME working for anyone? I set the shadowUpdateMode once during the update cycle, but nothing happens. Checked all light types to no avail.

…light.shadowUpdateMode = pc.SHADOWUPDATE_THISFRAME;

Setting SHADOWUPDATE_REALTIME works as expected.

Is there another method to force a shadowmap update?

1 Like

Hi @DiBi and welcome!

From what I remember something like this will work to force update the shadows, when set to only this frame:

myLightEntity.light.updateShadow();
3 Likes

@Leonidas

Thanks, I’ll give that a try.

For now I have been using this workaround in the update loop:

    if( this.updateShadows )
    {
        this.keyLight.shadowUpdateMode = pc.SHADOWUPDATE_REALTIME;
        this.updateShadows = false;
    }
    else
        this.keyLight.shadowUpdateMode = pc.SHADOWUPDATE_NONE;

From the documentation I would have thought “shadowUpdateMode = pc.SHADOWUPDATE_THISFRAME” would cause a single shadowmap update when Playcanvas enters the render cycle and is then reset to NONE.

When using “.updateShadow()” I guess it flags the renderer to update shadows in the render cycle and not immediately?

So, you can set this flag to a light either in editor or through code and it will have the result of calculating shadows for that light only on the first frame of the app’s lifetime.

At any point you can force the shadows to update using the code I posted above, that will update the shadows immediately at the next frame rendered.

Check how the renderer treats that flag:

1 Like

Thanks for the detailled information. I will update our code to use the .updateShadow() call.

1 Like