Hello guys,
I have spent several days googling and reading about this problem and I couldn’t find any definitive answer to this problem.
When I build my project to test it in my Android phone, the compiling shader variants takes a lonnngggg time. Mainly in "standard (specular setup).
Is anyone else here have had the same problem and if so, has anyone found a clear and real solution for this?
Regards,
Carlos
1 Like
How many graphics APIs do you have enabled for the build? Each will generate an additional shader variant.
1 Like
I used to find this before 2018, now I don’t know where to find the settings where I can select the apis I want to use to remove the other ones. So I don’t know now if there are some apis enabled that I don’t need.
Regards,
Carlos
1 Like
afaik the place is still the same - player settings
you can access this either via the build window → player settings or edit → settings → player settings
1 Like
Got it. I only have Vulkan and openGLES3 enabled.
1 Like
How many shader variants does it build?
1 Like
When I use Standard shader(specular) build thousands of those. I have 13 scenes in my game, and I had to disable the last 7 scenes from the build in order to spend less time since I am only testing, and despite this it took around 40 to 45 minutes compiling shaders. I only use that standard specular shader and a couple of other, which compile very fast and very small amount of variants.
1 Like
This just means you have a lot of shader features used in your scenes.
If this is just for testing, you can remove one of the gfx APIs from the list, this alone should the shader build time in half.
1 Like
What do you mean with having a lot of shader features? I use the diffuse and normal map slots only. Is there a way to remove features that don’t have texture slots from the standard specular shader?
1 Like
This is not only about using textures. Do you have fog in any of the scenes? Lightmaps with different parameters? Standard shader has support for many things, and each of those you use in your scenes might double the amount of variants.
The variants that are not possible are excluded, though.
3 Likes
I am actually experiencing this same issue… I use only standard shaders, no fog, no light maps, one single light-source. Are you speaking about how many actual standard shaders (“variants”) we are using?
Yes. You can right click on a material, select “Select shader”, then click on the arrow on the drop-down “compile and show code”. It will show how many variants are actually used.
1 Like
368 this is overkill as hell as I have maybe 12 in the scene… is this really just due to selecting multiple API tiers? >.>
I know for certain that this didn’t happened before I started using Unity 2018 and I was using then the same amount of materials and all the other usual stuff, or even more.
2 Likes
Here I have a couple of screenshots, the first one demostrates that the Standard Specular shader is only being compiled for Android, the seconds shows the usage of the shader in the material. And only one character is using this material
1 Like
I agree with @strongbox3d Before Unity 2018 the shader variant compilation build time was at least 90% faster then the current build time. This is also becoming a serious issue in our company! For the same project with target windows (mono) i’m compiling shaders for 20 minutes per build, while in previous versions of Unity this was like 1 or 2 minutes!
@aleksandrk Can you please elaborate ways to decrease this or the reason why Unity does this? It seems like a MAJOR regression in build time!
4 Likes
I wonder why I didn’t get any other answer from the Unity folks in relation to this issue. I believe that this issue is “kind” of important and unacceptable when trying to test the game in the target platform.
Regards,
Carlos
1 Like
Indeed, this issue is effecting production workflow so much, in bad way. There suppose to be a solution a selection, because it wasnt like that before 2018.1. I know there are major render pipeline changes in that version but, there suppose to be a way, at least the sake of quick testing and there are situations that you cant use unity remote for testing so an actual build will be necessary in that kind of situations. Dear Unity team, please find a way to shorten or remove that “dead block” of time.
1 Like
As new features are added (and there were some new features in 2018.x), some shaders get additional “#pragma multi compile BLA” or “#pragma shader_feature BLA” lines. The first variant always doubles (or more than doubles, depends on the amount of parameters) the amount of shader variants, the second does that only if the actual thing is used.
Another thing is that it’s possible to load scenes additively. This means that if you have a material with a certain set of features in one scene, and you have another scene that adds something that can affect this material (e.g. fog), the material has to support fog, although it’s not in the actual scene where it’s used. This tends to increase the amount of permutations as well.
We are well aware of this issue, and add additional parameters only if that’s unavoidable.
I get the explanation why unity does this variant compilation. But still I don’t get it why it takes AGES since Unity 2018.x for the same project that took 30 seconds in Unity 2017.x?? To me whatever the explanation is, this should be fixed, because build time is currently unacceptable!
Might it be part of the solution to actually expose the usage of shader keywords and the impact this has on shader variant compilation to the user? Unity is literally compiling 100.000+ shader variants for just using the “standard shader” In our world! I’m very willing to understand why this happens!?
1 Like