Callback when ShadowGenerator finished creating ShadowMap

Currently I’m using a shadow generator to create a shadow map for my static map.

After all meshes have been created, each one of them is added as a shadow caster.
After that, I’m setting the refresh rate of the ShadowGenerator to REFRESHRATE_RENDER_ONCE, since I do not need to re-render the shadow map for my static scene anymore.

Now to my actual question; there is a little bit of a delay until the shadow map is actually visible after freezing the refresh rate (since the mapSize param is 4000).
How would I be able to make a callback or check if the shadow map has been fully created/rendered?

Using onAfterShadowMapRenderObservable to check if the shadow map has been applied, did not help much, since it still triggered before the shadow map was visible.

PG: https://playground.babylonjs.com/#CWJPSP#1

^ Im using alert to see if the shadow map is visible yet in the scene.
In this case, it’s not, and only after dismissing the shadow map is visible

Tagging @Evgeni_Popov

Here is the example with 2 possible methods - https://playground.babylonjs.com/#CWJPSP#2
Screenshots are there just to confirm that shadows are rendered as they should :slight_smile:


    scene.executeWhenReady(function () {
        BABYLON.Tools.CreateScreenshot(engine, camera, { precision: 1.0 });
    })

    scene.onReadyObservable.add(() => {
        BABYLON.Tools.CreateScreenshot(engine, camera, { precision: 1.0 });
    });
2 Likes

Please, do not tag the team members directly even if you were spot on as it helps us being mindful of time off :slight_smile:

Disabling parallelShaderCompile will help tracking it better mixed with the rest of the scene state: https://playground.babylonjs.com/#CWJPSP#3

you would still need to defer at least one frame to see the final result

1 Like

Thank you!
My bad about the tagging :slight_smile:

no worries but Evgeni_Popov is currently on vacations so we ll try to cover for him despite how hard it will be :slight_smile:

1 Like