• Runtimes
  • Shader variant error on Android device running in Unity runtime

Shader Spine/Skeleton, subshader 0, pass 1, stage all: variant <no keywords> not found.

I've never heard of "keywords" in this context before so the google results I'm getting make no sense to me.

Is this a Spine issue or is it a Unity problem? Does anyone know how to resolve it?

In a dev build everything looks okay aside from this error showing in the console, but I think this error is killing the non-development build on startup.

I'm on Spine 4.1.12 and Unity 2022.3.0f1

Thanks in advance

Related Discussions
...

The error you're encountering, Shader Spine/Skeleton, subshader 0, pass 1, stage all: variant <no keywords> not found., is related to shader variants and keywords in Unity. This issue can arise due to several reasons, including shader stripping, incorrect shader usage, or missing shader variants.

Here are some steps to help resolve the issue:

  1. Shader Keywords and Variants: Unity uses shader keywords to create different variants of a shader. If a required variant is stripped out during the build process, it can lead to errors like the one you're seeing. Ensure that the necessary shader variants are included in your build. You can do this by:

    • Disabling shader variant stripping in the project settings (not recommended for production).
    • Creating dummy materials that reference the required shader variants and including them in your build.
    • Changing shader_feature to multi_compile in your shader code to ensure all variants are included.
  2. Shader Usage: Make sure you are using the correct shader for your Spine assets. For example, if you are using SkeletonGraphic components, you should use the SkeletonGraphic shaders provided by Spine.

  3. Updating Spine-Unity Runtime: Ensure you are using the latest version of the spine-unity runtime. Older versions might have bugs or missing features that could cause such issues. You can download the latest version from the Spine Unity Download page.

  4. Shader Fallbacks: Temporarily disable shader fallbacks to diagnose the issue. Replace lines like Fallback "another/shader name" with Fallback Off in your shader code. This will make it easier to identify if a shader can't be loaded.

  5. Asset Bundles and References: Ensure that the shaders and materials are correctly referenced and included in your asset bundles. Mismatched references or missing updates can cause such issues.

  6. Testing in a Clean Project: Sometimes, issues can be caused by project-specific settings or conflicts. Test your Spine assets in a clean Unity project with only the spine-unity runtime to see if the issue persists.

Here is a useful link for more information on writing your own shaders for spine-unity: Writing your own shaders.

By following these steps, you should be able to diagnose and resolve the shader variant error on your Android device.

This is a little bit generic, I don't know what to do.

I don't want to break the shader, but it seems like I have to disable the straight alpha input in order to enable multi_compile in the Spine/Skeleton shader? Once I've done that there's no change in the application and no recompile so I don't know if changing it will actually flow on through to a newly compiled shader.

I believe I'm using the correct shader. Again, in dev my spine animations show and run on the device. But in production I think that this error kills it at runtime before it can do anything.

The runtime is up to date, seemingly (the github version is still at 4.1? No package manager prompt to update.)

Fallbacks: again, I'm not confident editing the shader.

Asset bundles and refs: yeah it looks like they're there, because the animation loads and plays.

Testing in a clean project: I am completely out of time and won't have a job tomorrow if I can't fix this, so there just isn't time to test it in this way. It would take me at least a week to set up.

    Realised 4.2 is the latest, so I removed and readded the latest package from github. That didn't resolve it.

    I worked out I had to replace "shader_feature" with "multi_compile", not the argument following it. Trying that now.

      Antidamage The runtime is up to date, seemingly (the github version is still at 4.1? No package manager prompt to update.)

      Note that when using Spine UPM packages with Unity Package Manager and Add package from git URL.. , you specify the git URL including either a specific commit, or a branch like #4.2 as suffix (see here).

      Note that Unity likely does not recognize that any commits followed since you last updated the package from the git URL, so you may always need to hit Update at the package in order to update to the latest state from the repository.

      Antidamage I worked out I had to replace "shader_feature" with "multi_compile", not the argument following it. Trying that now.

      Likely what Spinebot described under 1. applies. When a shader contains shader_feature, Unity will check during a build if any Material included in the build uses the shader feature. If not, then that shader variant will not be included.

      This happens for example if you programmatically at runtime create a new material with a given shader. The problem not arises when this programmatically created shader uses certain keywords which would require a previously stripped variant (might be the default keywords as well).

      It's similar to Always included shaders, where if you don't use a shader in any Materials in a build and later programmatically create a Material at runtime using this shader, you have to add it to Always included shaders so that it's not missing. With shader variants, it's similar but one level deeper, and unfortunately there is no Always included shader variants, instead you would either need to create dummy materials or change shader_feature () to multi_compile to always include both variants.

        Harald It's similar to Always included shaders, where if you don't use a shader in any Materials in a build and later programmatically create a Material at runtime using this shader, you have to add it to Always included shaders so that it's not missing.

        This is probably what I need. I've been trying to figure out how to force-include everything to do with spine but all I get is nothing:

        The other aspect is, I have tried forcing a wee spine animation to exist in the project and not be assembled at runtime to make the shaders be included and it didn't fix the issue.

          Antidamage I've been trying to figure out how to force-include everything to do with spine but all I get is nothing:

          Your search excluded content from packages, you need to hit the eye icon to the right in the Select Shader window to show "hidden" files (files from UPM packages).

          8 dias depois

          Sorry for the delay, right as I came to test this I broke my build configuration and it took the better part of a week to restore everything. Going crazy.

          Including the spine package shaders hasn't fixed the error above. I can only assume that it IS halting on this error in non-development builds and not something else, as it's the only error I get in development.

          I'll re-generate the full log output and add it after this. Any more ideas are welcome!

            Antidamage Sorry for the delay, right as I came to test this I broke my build configuration and it took the better part of a week to restore everything. Going crazy.

            Oh dear, sorry to hear. In general it's always highly advisable to keep the ProjectSettings directory in git or version control in general as well.

            Antidamage Including the spine package shaders hasn't fixed the error above. I can only assume that it IS halting on this error in non-development builds and not something else, as it's the only error I get in development.

            I assume that by "Including the spine package shaders" you mean adding them to the Always Included Shaders list. It's strange that you still see the variant being reported as missing, as the documentation explicitly states that it should include all shader variants when a shader is added to the list:

            Always Included Shaders
            This is a list of shaders for which Unity includes all possible variants in every build.

            I guess in the end that wasn't the blocking issue. I have no idea what changed, but everything now loads on the device. I guess destroying the settings by mistake was a good move.

            Thanks for the help!

            Glad to hear you've figured it out, thanks for getting back to us!