[SOLVED] Application will stutter in the Intro Animation

It’s complicated. The generated shader (in case of a StandardMaterial) depends on many additional things which impact the way it gets generated, and those are not known ahead of time. An examples here are:

  • vertex format (we generate different shader if mesh has tangents for example) - so we need to know what mesh is used
  • texture formats - some textures might need decoding (RGBM/RGBE/RGBP) and so we need to know what materials is used
  • global lighting settings / envLighting texture format that needs encoding, mesh instance that specifies lightmaps and similar.

We cannot generate the shader till we know all those (and some more). And so we cannot easily do this ahead of time.

There was a functionality that let you play the game, which collects all ‘options’ the shaders use, and this allowed shaders to be precompiled if used. This was never functioning really well and this is temporarily not supported - even though I plan to add support for something similar in the future.

I’ve started splitting the rendering into two passes - first that walks over the primitives and triggers shader compilation - so that all shaders compile in parallel. But so far this is done per render pass, and not globally. I’m planning to make this global at some point (maybe), and at this point we might have an API that only triggers shader compilation, without the rendering. But none of this is simple to do at all.

4 Likes