Can somebody write the ultimate guide to shader keywords? There are many cluttered infos out there but I can’t get them together.
Does the same keyword in two shaders count twice?
I have the hdrp default shaders, vegetation studio speedtree shaders (don’t use them, though) and one shader graph and I get the message that I have more than 256 keywords in use.
If I open up shader control from the asset store, it tells me that LayeredLitTessellation uses 101 Keywords and LayeredLit 99, Lit 97 and LitTessellation 73, which are almost all duplicated.
As far as I recall, materials keep old settings around if you change the shader, so this will lead to a consumed keyword as well. Flushing materials can probably tidy things up and indicate to Unity that those keywords are no longer needed. Like you mention though, I could be out of date.
As new feature called “Local Keywords” landed into 2019.1.0a3 we will probably going to do some new manual that will include about efficient shader keyword usage. (However it most like will not land in 2018.3 as it is already in beta stage)
Keyword uniqueness is controlled by the name itself. So no matter where it is requested or created (Material.EnableKeyword or in shader multi_compile) as long as the name is the same there isn’t going to be any duplications.
Same as above, they have all different names, for this reason they all treated as unique keywords.