Search Unity

[WEBGL] Shader warmup takes a lot of time (for ex on draw mesh instanced or shader preload)

Discussion in 'Shaders' started by fciornei, Jan 10, 2020.

  1. fciornei

    fciornei

    Joined:
    Mar 6, 2016
    Posts:
    3
    Hi! recently I started to use Graphics.DrawMeshInstanced in my WebGL game, because there are scenes with 10k+ objects that need to be rendered. This helped a lot to improve the FPS, but sadly added another issue.

    Now it takes ~20 seconds to load a scene where Graphics.DrawMeshInstanced is used because the first call to this function requires the shaders to warm up. The next time the scene is loaded, it loads almost instantly.

    This is kind of unbearable, especially in multiplayer, where other players will have to wait for a single-player until he loads the scene.

    Things I have tried:
    1. Using a shader variant collection, and adding it to the preload shader list in Graphics. This, of course, solved the problem of slow scene loading, but now the game took really a lot of time to load (>1 minute, although the shader variant contained only a single shader and a single variant).
    2. Calling Shader.WarmupAllShaders on game start. I waited 10+ minutes, but the game still did not load, but that was expected, there are 600+ shader variants.
    Is it possible to somehow speed up the shader warm-up time in WebGL? I'm using Unity 2019.03.0f1
     
    mowax74 and Daniiii like this.
  2. jcj_bdk

    jcj_bdk

    Joined:
    Oct 1, 2020
    Posts:
    4
    I am very curious about whether you found a solution to this issue or not?
    I have a 2,5 min WarmUp time a shader collection with just 26 shader and 70 variants (also webgl).