Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

10 minutes build time ( and canceled!! ): shader variants..

Discussion in 'Shaders' started by Crystalline, Apr 21, 2021.

  1. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    150
    I dont know in which world it is normal for a game engine to take 10 + minutes to build a scene with a cube and 1 directional light and 2 materials. ( built in )
    All that time taken just to complile shader variants , FOR THE DEFAULT MATERIALS.
    URP.

    Built in , legacy renderer still much better than this .
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,105
    Did you, by chance, have postprocessing enabled?
     
  3. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    150
    Yes there is was PostFX.
    But just now I recreated the exact scenario in the built in pipeline and the build time took no more than 90 seconds.(2 materials, 1 directional light and plenty of PostFX)
     
  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,613
    The Lit shader uses several multi-compile keywords to create shader variants based on pipeline settings:
    - Shadows on/off
    - Shadow cascades on/off
    - Soft shadows on/off
    - Point/spot light support
    - Lightmaps
    - Ambient occlusion
    - Etc...

    All for the general purpose of performance scaling. The Standard shader in the built-in RP doesn't use this set up, so builds faster.

    It can easily amount to 25k variants and can take up to an hour for the first build to finish because of this. Though, subsequent builds will be super fast due to caching.

    In 2020.3 this behaviour was recently improved. Now, if shadows aren't enabled on any pipeline assets in the project, no shader variants for shadows will be built at all.
     
  5. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,105
    @Crystalline well, postfx v2 in URP allows to turn things on and off at runtime, so there's a lot of variants there by default. There's a long thread about this already, probably more than just one :)
     
  6. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    150
    Okay but does stencil has much to do with postFX? Because , right now i am building a simple scene and its been compiling stencil related stuff for more than 8 minutes.

    Im 15 minutes into building a scene with 4 objects and one light ( + post fx) and still not done.
     
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,105
    That's unlikely :)
    What's your PC configuration? Or are you on a Mac?
     
unityunity