By default, when a shader variant is not found in the player build, Unity silently picks a “close enough” variant from the available ones. This has a potential to hide bugs in the keyword setup.
Unity 2022.1 has a new checkbox in player settings, “Strict shader variant matching”, that can be used to alter this behaviour. If this setting is enabled and a variant is not found by the player, an error is printed in the console, specifying the shader, subshader index, pass and keywords that were used for variant search, and error shader is used for rendering.
This setting is intended as a simple validation layer that reveals keyword setup mistakes. By default it’s disabled.
It’d be nice if the fallback mechanism were documented. How does it choose? Even better to have a warning like “Shader [Keywords] is missing. Falling back to Shader [Keywords]. Renderer [objectpath]”. As is it’s rather hard to identify when it happens.
That’s not a fallback, it’s a consequence of having global keywords.
This is the second keyword system improvement (the first one is here ). We want to introduce strict rules for resolving keyword conflicts, and make fixing keyword issues easier, but this will come later.
Here’s a thought - can we specify an “error shader” of our own? Having that control over default fallback is an even safer way to manage this new option. A use case scenario is that the developer wants to manage it strictly but one falls through the net. The dev can identify it but the gamer just thinks “oh, generic wall”.
Revenue unaffected, everyone happy and it’s silently fixed by the dev in the know.
@paulatwarp This often means the variant doesn’t exist at all.
In your particular case, are there any directives that don’t have an underscore? These need one of the keywords to be enabled. It can also happen if two keywords from the same directive are enabled simultaneously.
Okay, I’ve found the model / material. It’s an FBX file, imported with a default material and None set in the import settings. When that model is in the scene, the material set is Default-Material. And I get these errors in the console:
Also if I create a new Material using the standard shader. This new material does not have the _EMISSION keyword on it by default, but the result is the same two errors as above.