Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Shader Keywords

Discussion in '2018.3 Beta' started by Carpe-Denius, Sep 30, 2018.

  1. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    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.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,725
    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.
     
    protopop and Carpe-Denius like this.
  3. LukasCh

    LukasCh

    Unity Technologies

    Joined:
    Mar 9, 2015
    Posts:
    102
    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.
     
    Carpe-Denius likes this.
  4. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    I think the combination of those two posts will lead me to the culprit. Thank you both.

     
  5. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,219
    @LukasCh ,

    Is it more than 256 keywords (per earlier vote for 1024) in Unity v2018.2.14?