The size of shaders in an Android build is too large (~28Mb)

Here is the log:

Textures 18.2 mb 29.9%
Meshes 2.3 mb 3.7%
Animations 5.3 mb 8.7%
Sounds 0.9 kb 0.0%
Shaders 28.0 mb 46.0%
Other Assets 1.2 mb 1.9%
Levels 1.2 mb 1.9%
Scripts 662.8 kb 1.1%
Included DLLs 3.9 mb 6.5%
File headers 188.5 kb 0.3%
Complete size 60.9 mb 100.0%

Do you know what is the problem? I’ve used not so many materials, most of them are standard.
Thanks for the following replies!

The log should have a section right after that which says “Used Assets, sorted by uncompressed size:”, you should be able to figure out which shaders are too large from looking at that list (or post the list here). My guess is that certain standard shaders are problematic and that using custom or mobile shaders would help.

The sizes of materials in this section are about 0.4-0.8Kb. This is too little to affect the final size of an apk.
However, I have smth like this:
27.5 mb 45.1% Resources/unity_builtin_extra

I strongly believe that this is a cause of my problem, but do not have any idea how to resolve it.

It’s probably all the multi_compile settings. You’re most likely using a bunch of different standard shader variations, which are all compiled and used separately.

You should consolidate the variations to a small set of 4 variations or some such. Every type changes it, as in, one with no normal map is one variation, one with one, is another variation, a fade transparent is one variation, a cutout is another, each one of those with or without normal maps… does that make sense?

Every minute variation you have is a different compiled shader, even though it’s built off the same core standard shader. Graphics cards do not branch efficiently like a CPU, so this is done to make sure that each variation actually performs quickly (it’s essentially a necessity).

1 Like

Thanks! I’ll experiment with that.

You can use the new ShaderVariant to manually select the variants of a shader that you want so as not to include extra shaders variants in the build by mistake.

Honestly, this is one reason why I hate the mega-shader approach and prefer the “Exact features I need” approach. It’s far too easy for an artist to flip a couple of options when experimenting and end up with 50megs of shader variants in your build.

27 MB for a shader file?! That is massive!

Hi Lebrokholic, I found the same problem that shader size is large after build and the Unity_BuildIn_extra is also large

How can you resolve this problem?

Thanks very much

Frankly, I didn’t find a solution. It was a part of my previous job, today I don’t experience such a strange behavior of Unity. Sorry.