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.


^ 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 -
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 });

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:

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