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!
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…
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.
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.
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
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’
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
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/
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