Local Shader Keyword Restrictions

Unity’s documents detail a bit on local shader keywords here - Unity - Manual: Declaring and using shader keywords in HLSL. 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 :slight_smile:

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.

1 Like

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!

Yes, it’s per shader, not per pass.

1 Like