Search Unity

Question Local Shader Keyword Restrictions

Discussion in 'Shaders' started by lukamoon, Aug 2, 2021.

  1. lukamoon

    lukamoon

    Joined:
    Nov 15, 2018
    Posts:
    15
    Unity's documents detail a bit on local shader keywords here - https://docs.unity3d.com/Manual/SL-MultipleProgramVariants.html. In the documentation, it also states that "There is a maximum of 64 unique local keywords per shader." Seeing as you define the keywords inside of a pass, I was wondering if by "per shader" the 64 limit was applied per .shader file as a whole or per-pass inside of a shader file. Thanks :)
     
    Last edited: Aug 2, 2021
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    I'm not too sure on that one, I would assume per-shader file since I think they'd mention Pass if it was that way, not to mention you can't change a keyword value on just a specific pass from script, you can only set it on the material/shader as a whole.
    But I would also note that in 2021.2, the limit has been raised to 65534, so essentially no limit.
     
    lukamoon likes this.
  3. lukamoon

    lukamoon

    Joined:
    Nov 15, 2018
    Posts:
    15
    I'll assume this to be true since, after thinking about it some more after posting, keywords are stored in the material and then passed to the shader - and the material doesn't really consider passes when passing said information. That's great to know about 2021, thanks so much for your input!
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    Yes, it's per shader, not per pass.
     
    lukamoon likes this.