Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Any way to know if a shader variant has been stripped from exported build?

Discussion in 'Shaders' started by stephero, May 22, 2020.

  1. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi guys,

    I would like to know, from an exported build, if a shader variant has been stripped during the export. I am specially interested about the instancing variant.
    I have a shader which support GPU Instancing. However the material of this shader is created at runtime, and I enable the instancing via the scripting API.
    Since there is no material asset with instancing enabled using this shader in the project, the export strips the instancing variant of my shader when the "Instancing Variants" property is set to the default "Strip Unused" value in the Graphics Settings:
    Screenshot_75.png

    Is there any way to know is my instancing variant has been stripped from the exported build?

    When I enable the instancing from script, the bool stays properly at true, so I cannot check that:
    Code (CSharp):
    1. material.enableInstancing = true;
    I also tried to check if the keyword INSTANCING_ON was enabled (via Material.IsKeywordEnabled) since it appears in the frame debugger, but it's never possible to retrieve it from script (even when the instancing variant is properly exported).
    Screenshot_76.png

    Thank you.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    The easiest way is, probably, to check this visually - make the color output different based on this keyword and see what color you get.
     
  3. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hi and thanks for the suggestion.
    I would have prefer a way to trigger a proper error message, but it's better than nothing :)
    It could be useful to prevent from setting the enableInstancing property at true on a material which doesn't have the instancing variant available (the getter of the property could always return false).
    Or being able to retrieve the INSTANCING_ON keyword from script would make sense too.
    Thanks
     
    Last edited: May 23, 2020