• RuntimesUnity
  • White seams when using Bleed + Straight Alpha with Unity on Android

lindsayt
I'll try and create a project to send through when I can, but that may take a while
I did a quick project with just the one Spine character. Same files, same Unity version. Copy pasted all the build and quality settings. Looks perfect on this other project. What gives?

    lindsayt We investigated updating to Spine 4.2 but it was not feasible for this project.

    I assume you meant Spine 4.1, since 4.2 is not yet out.

    I did a quick project with just the one Spine character. Same files, same Unity version. Copy pasted all the build and quality settings. Looks perfect on this other project. What gives?

    Please note that the Spine Preferences settings like default import settings are stored in the file SpineSettings.asset, by default located in Assets/Editor, outside the Project Settings folder.

    If you can later send us your reproduction project files, we're happy to have a look at what's the cause of your troubles.

      lindsayt Spine prefs are also the same across both projects.

      Thanks for checking. Please note that Spine Preferences only affect the first import of your skeleton asset. When copying your newly exported Straight-Alpha texture assets over PMA existing ones, the Spine Preferences Atlas Texture Settings preset is not applied, to not mess with your manually tweaked settings. Nevertheless, the Texture import settings and Material settings screenshots that you shared earlier already look correct.

      I assume you also receive the same issue when placing the exported assets in a newly created folder, right? So that no previous settings could mess up the import.

        Harald I have narrowed down the issue to the BlendModeMaterialsAsset. We currently have a mix of PMA and Straight Alpha assets as it is going to take a long time to re-export them all. If I create an asset and build the scene with it, it works. If I create the asset at runtime it's using the Default Blend Mode Materials Asset to replace the Material at runtime with an incorrect one. The documentation says this is obsolete but I don't know if this applies to Spine 3.8 as the "Upgrade" button that's mentioned is not present. In the project there is only the PMA materials, is there supposed to be the Straight Alpha ones as well or is this specific to PMA?

          The documentation says:

          If you have disabled Premultiply alpha, set Atlas Texture Settings to StraightAlphaTexturePreset and blend mode materials to SkeletonStraightAdditive, SkeletonStraightMultiply and SkeletonStraightScreen

          But those files don't exist. I re-downloaded the 3.8 runtime and they're not there either

          lindsayt We currently have a mix of PMA and Straight Alpha assets as it is going to take a long time to re-export them all.

          Sorry to hear. To save you some trouble for future projects, please note that it is highly recommended to automate your exports using the Spine Command Line Interface (CLI) to be able to quickly re-export your skeletons in one go.

          The documentation says this is obsolete but I don't know if this applies to Spine 3.8 as the "Upgrade" button that's mentioned is not present.

          Sorry for the confusion. In spine-unity 3.8 it was not yet obsolete as the new alternative did not exist yet, so you have to use the SkeletonData Modifiers - BlendModeMaterialsAsset in 3.8.

          Regarding straight alpha blend mode materials:
          spine-unity 3.8 did not yet provide straight alpha option at the blend mode shaders out of the box. Please download the latest spine-unity 4.1 shaders (additive, multiply and screen) and straight alpha materials (again additive, multiply and screen variants) from github here:

          Or alternatively import the same 3 shaders and 3 materials from a newly downloaded spine-unity 4.1 unitypackage.

            lindsayt Harald Is it expected that the BlendMode Shaders are the same for both materials? The only difference is that the Straight Alpha Texture is ticked

            Yes, that's the only difference.

            lindsayt I tried but I am also unable to use the 4.1 shader because they want the CGIncludes, which want a script, which want another script and so on.

            Sorry, I forgot that these were based on includes already. Then you need to import the required include files as well. It's these three:

            Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-BlendModes-NormalPass.cginc
            Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-BlendModes-ShadowCasterPass.cginc
            Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Common.cginc

            I will shortly compile a unitypackage (in a zip package so that the forum accepts the upload) which contains only the additional files to be imported to an existing spine-unity 3.8 project.

            The documentation says this is obsolete but I don't know if this applies to Spine 3.8 as the "Upgrade" button that's mentioned is not present.

            Upon testing the shaders I noticed that the latest spine-unity 3.8 runtime already provides the native support for slot blend modes and an Upgrade button at the SkeletonDataAsset, rendering the BlendModeMaterialAssets indeed obsolete. So if you don't see this Upgrade button, you are not using the latest spine-unity 3.8 package.

            Harald Thanks. I've done more experiments and have narrowed it down to some code on our side, but still unsure why it's occuring.

            On our SpineActors we have a script that holds references to different shaders. One of them is the basic tint shader. We change these are run time depending on the situation, but in this case it's I'm just testing with the basic tint shader.

            When these actors are bundled, the tint shader on script is different instance to the one on the material (I can see via debugging). Setting the shader to the one bundled with the script on the actor is causing this issue. Using the one already assigned to the material works as expected. The shader is the same, so I'm not sure why it breaks when bundled? We're changing the shader on the sharedMaterials reference.

            Unfortunately I'm still not able to upload a slice of the project as it's all very much linked.

            So in editor setting the material's shader to the Spine/Skeleton Tint works when not using bundles.
            When using bundles, and using a bundled version of the shader it does not work (doesn't matter if the shader is in it's own shared bundle or if it's an instanced copy). If I use Shader.Find(Spine/Skeleton Tint) and apply that shader, it works. In editor presumably this version is the one on disk.
            Is there something in Spine or the material that cares about whether or not the shader is bundled and/or the same instance?

            @lindsayt A quick guess is that the references from the bundled skeletons to the shader (or Material) are referencing a new asset reference, while the target of the reference are in an asset bundle which is either not loaded when loading the skeletons, or perhaps has not been re-generated with the new shaders and materials. So in other words, it sounds as if the packages containing the references don't match the available packages containing the referenced asset, either of the two seem to have been missing an update. You could have a quick try whether putting the shader into the same bundle as the problematic skeleton resolves the issue for this skeleton. Or you could also add the used shaders to the Always Included Shaders in the Project Settings.

            Or there is a race condition that the skeletons are loaded before the shaders and materials, and the dependency order is not maintained (for whatever reason).

            You could also check in your used version control system whether the .meta files (and therefore the GUIDs) of the used shader or materials have been modified.

            Thanks. I've added the materials to the always included, moved them to the same / different bundles, and tried lots of other things. If the shader is the one in the bundle, it just doesn't work and I get the artifacts. I even changed the shader code to force it to be blue for testing and both the bundled shader and the on disk shader changed colour, so it's definitely the same shader. I've been deleting and rebuilding the bundles over and over and on two different machines so it's not a caching problem.
            You talked about race conditions and such, is there some method I need to call on the skeleton or material to get it to refresh and possibly work again?

            OKAY I have a workaround, but I still don't know why bundles don't work.
            If I put the shaders into "Always Loaded" and DONT bundle the shaders, those shaders aren't put into the asset bundles and the instance ids for the shader references all point to the same location and the artifacts are GONE. I've been testing with Editor bundles so far and will try with an Android build tomorrow, hopefully this works on device too.