Search Unity

Brutally slow player builds compiling shader variants

Discussion in 'Universal Render Pipeline' started by Justin_Larrabee, Jul 13, 2020.

  1. Justin_Larrabee

    Justin_Larrabee

    Joined:
    Apr 24, 2018
    Posts:
    106
    We've got a simple set of lit/unlit URP shader variants we use in the current version of our project. A clean build (no Library) takes upwards of two hours on a current-gen six-core i7 -- 100 minutes of which is simply compiling shader variants. We use addressables, so the cost of compilation appears to happen twice when we build both.

    I know 2020.1 is supposed to have improvements (~20%?) to shader compilation times, but is there anything else that can be done by us to speed this process up?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,176
    Hi!
    The long compilation time comes mostly from the amount of variants that are needed. What platform are you targeting? Which graphics APIs are enabled for the build target?
     
  3. Justin_Larrabee

    Justin_Larrabee

    Joined:
    Apr 24, 2018
    Posts:
    106
    This happens on win64, macOS, and iOS. In the case of iOS and macOS it's just targeting the metal API. We have about 450 variants of 94 shaders, and I have made sure to explicitly disable unused lightmap and fog modes in the graphics settings.

    By comparison, I've shipped another game with >450 shader variants in the standard pipeline and compiling shaders was barely a blip on the radar of build times.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,176
    Can you please send me (in a PM or attach here, whichever you prefer) Editor.log and all UnityShaderCompiler<X>.log (these are inside the Library folder in your project)?
    Or just open a bug report - we'll take a look there :)
     
unityunity