Compiling Shader Variants Taking Ages

Hi Guys,

I’m just building my project, and for some reason the ‘compiling shader variants’ is taking close to an hour to do. I mean fair play, it’s a fairly large project, but for example for terrains I have a small park, with one grass texture and some of the built in unity trees… That’s it. It’s compiling 6768 shader varients for ‘Nature/SpeedTree’. Anyone have any idea why this is taking so long? Thanks!

4 Likes

Are you by any chance compiling for mobile VR with single pass rendering enabled in Unity 2018.1? We were getting the same problem and it looks like having that enabled causes pretty much every possible shader variant to get compiled…

7 Likes

Hah, not quite. VR on desktop with single pass rendering in 2018.1 lol. So it looks like that’s the culprit. Hopefully will be repaired in a few weeks when 2018.1 is officially released.

1 Like

Just trying with 2018.1 release… same problem.

2 Likes

It’s still there, a true and simple deal-breaker for me, probably will need to revert to 2017.1.

1 Like

Still there for me too. I am just biting the bullet and doing other jobs while the project builds (about 10 minutes).

it just started doing that with latest version. It’s running for a while and then crash and exit completely.

Help please Unity !!

1 Like

I’m experiencing the same problem. Building for Oculus GO (Android target) is taking much longer on Unity 2018.1.4f1 than on 2017.4.1

1 Like

Yeah I did find when it’s built once, and you don’t make changes to those shaders that same build is faster when re-done I ‘think’, but that’s worth double checking. Either way when you have large projects it means walking away from the computer for a good hour. On company time it doesn’t look good lol.

We have a similar problem with 2018.2.0b2 building for WebGL. All of a sudden all builds (even empty 1 cube scenes) are compiling hundreds of thousands of shader variants. The best we can tell is that the editor gets stuck in WebGL1.0 emulation mode (or automatically switches to it upon build and then freaks out.

No clue why it’s happening but it’s killed this project and it’s delivery deadline.

1 Like

experiencing the same issue today with Unity 2018.1.0f2
building for android and get 6144 shader variants to compile, but it seems that the compiler is going back at 1024th shader… and restart compile from scratch to get stuck again athis 1024th shader…

Also downloaded and tested with Unity 2018.1.5f1 got the exact same problem

any help ?

after more inspection i deleted a folder containing a serie of shaders that may be the probelm, the compiler is now going further . :wink:

For the interim i had to replace all lights in my scene with area lights to get it to generate a build in a timely (still twice as long as usual) manner. It seems that once lighting is baked, unity creates hundreds and thousands of shader variants for each light type, and material in the scene. So far it looks like the (back of napkin) math is close to Materials * #light types * #shader variants per material ‘visible to each light’

2 Likes

Bump, does anyone know what is causing this problem?

The most shader variants are coming out of the PostProcessing FX folder and I don’t think it’s even being used.

1 Like

Try to notice where and when the builder stops, it may be a clue to find what to remove.
Another thing that may helps is to build your application using Build system Internal instead of Grable

At this point I’m doing cloud builds. Yeah they take a while, but at least it doesn’t mean at work I play about for 40 minutes.

Is there a way to reuse the compilation output from the previous build? For most games this will rarely change.

5 Likes

Not that I’m aware of, however you may be able to get around it on 2018.2b. You may not want to use it for production code, but one of the main features is stripping the shader variants to decrease build time… You know, create a problem to fix a problem lol. Link here: https://blogs.unity3d.com/2018/05/14/stripping-scriptable-shader-variants/

2 Likes

Take some time, get a coffee, did so and it only takes this “hours” once. You can also put your variants in a preset in the Project → Graphics Settings on the bottom. That might help a bit :slight_smile:

4 Likes

Lol no it doesn’t. Our issue is it happens every time like everyone is saying in this thread.

1 Like