Search Unity

Unity Strict shader variant matching

Discussion in '2022.1 Alpha' started by aleksandrk, Sep 7, 2021.

  1. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,135
    Hello Unity alpha users!

    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.

    Happy debugging! :)
     
  2. Kleptine

    Kleptine

    Joined:
    Dec 23, 2013
    Posts:
    167
    Hah! I discovered the 'fallback' earlier this year while tracking down a particularly nasty shader bug.
    https://uninomicon.com/shaderkeyword

    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.
     
    Jes28 likes this.
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,135
    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.
     
unityunity