Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

18k shader variants, lengthy standalone build

Discussion in 'Graphics Experimental Previews' started by hd5ai, Dec 12, 2018.

  1. hd5ai

    hd5ai

    Joined:
    Nov 2, 2018
    Posts:
    5
    Is there a good way to track down what exactly is causing such a spike in variants?



    .. on first export, it took over an hour with Unity looking like it had hung (in fact, I thought it had several times until I used procmon) before the build finished. An example of the file activity while 'hung'


    (https://i.imgur.com/orSpoIr.png for bigger)



    On every export it does this for about 5 minutes, slowly jiggling up the progress bar.

    Any tips on unwinding where we've gone wrong? We have disabled all the lighting and fog variants in graphics settings and I've tried setting up a Shader Variants Manifest (about 30 w. 200 variants 'found' when running the scene in question)
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    4,004
    Just so you know, there is already a thread (multiple) about this and therefore there is probably no point posting another one:

    https://forum.unity.com/threads/compiling-shader-variants-taking-ages.527724/

    If you go through that thread you will see I and other users have posted workarounds/fixes as well as what seems to be the root cause.

    TLDR: change your #pragma multi_compile statements to #pragma shader_feature and manually manage your variants to bring it right down
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Also enable variant stripping for HDRP if this is used. It's in the asset where you configure HDRP but not enabled by default.
     
  4. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    936
    Hi,

    note I assume that you use HDRP 4.6 as seen in your log here, other wise what I will say is wrong:

    > We have disabled all the lighting and fog variants in graphics settings and I've tried setting up a Shader Variants >Manifest

    We don't used the fog of builtin unity, this wouldn't have any effect, only lighting option will do something.

    >TLDR: change your #pragma multi_compile statements to #pragma shader_feature and manually manage your >variants to bring it right down

    Shader variant stripping is always enabled with HDRP (otherwise it will never finish compiling). You should do any replacement in the code, we have already option in HDRP asset to disable everything not required. By doing this you could cause crash at runtime. In HDRP asset you should enable only what you used,

    In order and by default I will suggest to:
    - change lit shader mode to deferred (if you use deferred rendering)
    - disable light layers if you don't use it
    - disable runtime debug display (you can divide your build time by 2 with this one)
    - disable backface for transparent (if not using it)

    with those above you should win a lot of variant already.

    Note that the number of display variant from the menu is unrelated about what will be compile. So don't expect anything from it.

    Regarding the progress bar during the player build, sadly it is not really accurate and will change at the next build, the only thing it really allow is to know that you wait for shader compilation.

    Hope that help.

    With careful option choice we have gone from 12 Hour on FPS sample game to around 40 min to build. All depends what you used in your game that we can't predict.
     
    hd5ai and hippocoder like this.