• RuntimesUnity
  • SkeletonGraphic (Unity UI Canvas) setup, blend modes, and performance issues.

Hi, I am setting up SkeletonGraphic component to render animated characters inside Unity canvas.
I was able to find most answers by checking the documentation, however some important specifics are not really clear.

Versions:
spine-unity Runtime 4.1.0
spine-csharp Runtime: 4.1.0

Multiple atlas pages
It appears that older documentation mentions that this setup is not supported, but recent updates suggest that it can be achieved by enabling multiple canvas renderers. However, the specifics are unclear, especially when considering a scenario where a character uses multiple skins, each packed into its own atlas page. The question remains whether SkeletonGraphic can utilize one atlas at a time without requiring multiple canvas renderers? Is there an example scene with that kind of setup?

CanvasGroup Alpha
For context:
We're having some trouble with fading canvases in and out, especially when characters are nested inside. The nitty-gritty details are in the documentation https://esotericsoftware.com/spine-unity#CanvasGroup-alpha . To fix it, I basically copied the SkeletonGraphic material, ticked the CanvasGroup Compatible box, and slapped it under each SkeletonData asset. Just wanted to share this tidbit in case it helps with the rest of the setup!

Blending mode
My characters are currently imported with a separate material for each blending mode, such as Additive, and are utilizing the Skeleton PMA Additive shader. To set up multiple blend modes correctly, is it necessary to employ multiple canvas renderers? Additionally, How does this approach negatively impact performance?

PMA Vertex Colors or not
It was kind of hard to understand by reading documentation,
here is my understanding of that parameter by reading this : https://esotericsoftware.com/spine-unity#Parameters

If CanvasGroup is enabled in the SkeletonGraphic material - Dissable PMA vertex colors
If a shader is SkeletonGraphic shader and or a thirdparty shader which uses PMA additive blend mode Blend One OneMinusSrcAlpha - then Enable PMA vertex color.

What if it's using SkeletonGraphic with Canvas group enabled and we are using Blending additive blend mode ?

Layout Scale mode
-That doesn't look like it is an option in newer versions, please confirm.

  • Harald hat auf diesen Beitrag geantwortet.
    Related Discussions
    ...

    Nay spine-unity Runtime 4.1.0

    Does the Unity Package Manager read 4.1.0? If it reads 4.1.0, it is very old already, as the current 4.1 version is 4.1.36 (see here). How did you install the spine-unity package, where did you get the version number 4.1.0 from?

    Nay It appears that older documentation mentions that this setup is not supported

    Could you please describe what "that older documentation" you are referring to? The spine-unity documentation page is kept up to date with the latest beta version releases (so currently 4.2-beta), it should never be more than a week behind, after feature commits it may lag behind a few days.

    but recent updates suggest that it can be achieved by enabling multiple canvas renderers.

    Yes. Please also see the message at the bottom of your screenshot, we've implemented multiple messages of this kind to detect incorrect setup and describe the possible solutions.

    The question remains whether SkeletonGraphic can utilize one atlas at a time without requiring multiple canvas renderers? Is there an example scene with that kind of setup?

    What do you mean by "one atlas at a time"? Do you mean that you have 5 atlas pages, but always only require a single atlas page through active attachments never needing the other pages? If so, then you could use SkeletonGraphic with a single CanvasRenderer, then there is no need to enable Multiple Canvas Renderers, yes.

    Note however that that does not seem to be the case with your SkeletonGraphic component in the screenshot, as the message is only displayed when the skeleton mesh actually requires two or more submeshes. Likely there are some attachments from another atlas page active, or you're using attachments with different blend modes.

    Regarding example scenes: that's demonstrated in the example scene Spine Examples/Other Examples/Blend Modes.

    I can see that the SkeletonGraphic documentation section about multiple canvas renderers is missing to mention that multiple active blend mode materials require additional canvas renderers just as multiple atlas pages do, thanks for bringing this to our attention!

    Nay To fix it, I basically copied the SkeletonGraphic material, ticked the CanvasGroup Compatible box, and slapped it under each SkeletonData asset.

    By "slapped it under each SkeletonData asset", do you mean in the Inspector of the SkeletonGraphic component you assigned it at the Material property? If so, that's correct. if not, please explain what you mean by this sentence.

    Nay To set up multiple blend modes correctly, is it necessary to employ multiple canvas renderers?

    Basically yes. CanvasRenderer is limited to a single material and a single texture. Whenever multiple materials or multiple textures are required, you need to enable Multiple Canvas Renderers. If your skeleton's active attachments require multiple textures or materials (blend modes), you thus need to enable Multiple Canvas Renderers. That's what the warning message in your screenshot tells you.

    Additionally, How does this approach negatively impact performance?

    General Unity rules apply here, it requires additional draw calls as normal when different materials are used.

    Nay If CanvasGroup is enabled in the SkeletonGraphic material - Dissable PMA vertex colors
    If a shader is SkeletonGraphic shader and or a thirdparty shader which uses PMA additive blend mode Blend One OneMinusSrcAlpha - then Enable PMA vertex color.

    This is correct, yes.
    Sorry that the documenation was hard to understand. We will change the wording so that it's easier to understand.

    Nay What if it's using SkeletonGraphic with Canvas group enabled and we are using Blending additive blend mode ?

    If you enable CanvasGroup compatible (because you need CanvasGroup alpha blending), you need to disable PMA Vertex Colors. As a result, you can't handle additive blending via the main SkeletonGraphic shader but instead require a separate material like SkeletonGraphicAdditive, which you should see automatically assigned at your Advanced - BlendModeMaterials property in the Inspector. At all your assigned blend mode materials (including SkeletonGraphicAdditive), you also want to have CanvasGroup Compatible enabled, so you will want to create duplicates of these blend mode materials and assign them at the respective Additive/Multiply/Screen Material property.

    Sorry that this setup is quite complicated, and I can see that this combination also needs to be mentioned in the documentation accordingly.

    In general thanks for sharing all your issues with the documentation with us, we're always happy to improve it and make it clearer where possible! I've created an issue ticket here to improve the documentation:
    EsotericSoftware/spine-runtimes2464

    Nay Layout Scale mode
    -That doesn't look like it is an option in newer versions, please confirm.

    If it's mentioned on the spine-unity documentation page, it's present in the latest beta version. This property is also present in the latest 4.1 spine-unity runtime release. If you don't see this property, you're using an old spine-unity runtime version. Please update.

    First of, thank you so much for such a detailed reply! I truly appreciate that!
    That's A+ customer support!

    Unity packages, here are the screenshots,
    I assume this was just installed via git hub link. It was before my time on the project.


    I think it shouldn't be harmful to upgrade spine-runtime?
    We can still do round of testing to see if anything broke. Let me know if you have advices on that.

    Documentation:
    You are correct, I am probably just looking at the older forum replies.

    Atals pages:

    Do you mean that you have 5 atlas pages, but always only require a single atlas page through active attachments never needing the other pages?

    Yes that is correct. Always only require a single atlas page. Currently I do have skins that are separated by folder, but I was still trying to fit everything in a single atlas. I do have some follow up packing questions but I can will post a separate question regarding packing.

    By "slapped it under each SkeletonData asset", do you mean in the Inspector of the SkeletonGraphic component you assigned it at the Material property?

    Hah I should word my questions better. Yes.I have assigned it at the Material property.

    And lastly:

    If you enable CanvasGroup compatible (because you need CanvasGroup alpha blending), you need to disable PMA Vertex Colors. As a result, you can't handle additive blending via the main SkeletonGraphic shader but instead require a separate material like SkeletonGraphicAdditive, which you should see automatically assigned at your Advanced - BlendModeMaterials property in the Inspector. At all your assigned blend mode materials (including SkeletonGraphicAdditive), you also want to have CanvasGroup Compatible enabled, so you will want to create duplicates of these blend mode materials and assign them at the respective Additive/Multiply/Screen Material property.

    Ok here is that setup:
    This is the character

    This is SkeletonGraphic component:

    This also created 3 sub Renderers:


    Unsure what material goes in here?

    • Harald hat auf diesen Beitrag geantwortet.
    • Nate gefällt das.

      Nay First of, thank you so much for such a detailed reply! I truly appreciate that!
      That's A+ customer support!

      Thanks for your kind words!

      Nay Unity packages, here are the screenshots,
      I assume this was just installed via git hub link. It was before my time on the project.

      If the Unity Package Manager window displays 4.1.0, it is indeed quite an old version that you are using.

      Nay I think it shouldn't be harmful to upgrade spine-runtime?
      We can still do round of testing to see if anything broke. Let me know if you have advices on that.

      We always recommend to back up the project before updating the runtimes to be on the absolute safe side. However, breaking changes don't get integrated in the stable branch (4.1 currently), only into the beta branch (4.2-beta). So it's quite unlikely that anything will break by updating just the patch version.

      Nay This is SkeletonGraphic component:

      This is correct.

      Nay Unsure what material goes in here?

      Sorry for the confusion, the SkeletonSubmeshGraphic components don't need any material assigned, they are automatically managed by the SkeletonGraphic component. We will write custom Inspector code to hide the properties to be less confusing. Thanks for pointing that out!

      • Harald hat auf diesen Beitrag geantwortet.

        Great, thank you so much for your support.
        Going to leave the Sub-mesh Graphic as is.
        Curious why it creates so many subMesh canvas components, we only have one extra additive material.

        • Harald hat auf diesen Beitrag geantwortet.

          Harald We will write custom Inspector code to hide the properties to be less confusing.

          This change has just been pushed to the 4.1 and 4.2-beta branches.
          EsotericSoftware/spine-runtimes8046059
          New spine-unity 4.1 and 4.2-beta unitypackages have also just been released:
          https://esotericsoftware.com/spine-unity-download
          Some documentation improvements will follow, hopefully in the next few days.