If you use AssetBundles, Unity might compile duplicate shaders if you reference one shaderA program that runs on the GPU. More info
See in Glossary in two or more objects. For example:
This can increase the memory and storage space shaders use, and break draw call batching.
To avoid this, you can use the following approaches:
You can add materials and shader variant collections to an AssetBundle to specify which shader variants to include.
If you create a single AssetBundle, some shaders might stay in memory even if they’re no longer needed, because you cannot partially unload an AssetBundle. You can avoid this by creating a separate AssetBundle for each group of shaders you use together, for example a ‘forest’ AssetBundle and a ‘desert’ AssetBundle. See Managing loaded AssetBundles, or Memory management in the Addressables system if you use Addressables.