After all my models are loaded via asset containers and their contents added to the scene, I still suffer up to 5 seconds delay before the models appear. The skybox and floor are already rendered so scene initialization was clearly finished.
I want to add a Loading overlay, but I need an event to hook so I can clear that overlay when all is finally ready. What is Babylon doing during that delay? Lazy-compiling shaders?
Nope, this is some additional delay above and beyond the onReadyObservable. That’s why I noted that the skybox and floor are already rendered. Once my scene is ready then I begin loading the models.
And I’ve timed that delay, from beginning to end of loading. They get added to the scene, and then there’s an additional delay of a few seconds until they become visible. Which is strange because this is a very fast machine w/ an RTX3080.
Once the load and then the post-load delay are over, the renderer unfreezes and FPS are terrific. But that post-load delay is killing me.
This is our worst-case scenario, nicknamed The Beast. You should see the framework load quickly with all its 2D elements and a white canvas.
Then the skybox and floor load, but in low res for a moment. Then they come in clear. That’s scene init.
Then several seconds later, the model appears. But the model loading only takes about 1s (timed with Date.now() in the console) including adding all the asset container assets to the scene, and THEN the rest of the delay is several additional seconds with no mouse control.
Finally the renderer unfreezes, the models appear, and everything is normal.
@sebavan “as soon as the model is visible” would be the key phrase there. The trouble is the whole site appears to freeze for a few seconds until the model is finally visible.
I cant use the perf analyzer on this problem thus far, because Babylon isnt initialized until there’s a scene to load and the freeze happens almost immediately then. By the time I can get the PA open, the freeze is over. When I reload the page, the PA automatically goes away.
Is there a better way to get into the PA? Some way I can code it to open automatically?
If you are using a shadow generator it could be the problem, it seems the compilation of the shaders done during the scene.isReady process don’t have the prepass renderer enabled, so when the scene is “ready” and should be displayed, new shader compilations take place.
I do have 2 lights for which I instantiate a ShadowGenerator each, during onSceneReady(). Which I guess means after the scene has been initialized by the renderer. That’s bad then? I should init lights and shadows before, not after, scene ready?
const gen = new ShadowGenerator(256, light);
// PCF, because PCSS/"contact hardening" is expensive
gen.usePercentageCloserFiltering = true; // removes surface acnea
gen.filteringQuality = 1.0;
/* PCSS disabled for now, costs too much time on startup
gen.useContactHardeningShadow = true;
gen.contactHardeningLightSizeUVRatio = 0.6;