• RuntimesUnity
  • SkeletonGraphic renders with wrong color when CanvasGroup Compatible enabled.

Hi there, as the title says, when I use SkeletonGraphic with a CanvasGroup Compatible Materials, some additive slots of the animation rendered incorrectly.

The above chest is rendered correctly, with SkeletonGraphicDefault material, PMA Vertex colors enabled.

The bottom chest is rendered incorrectly (the light emitted from the chest is darken), with a custom material whose CanvasGroup Compatible checked and PMA Vertex color disabled.

The version I'm using is spine-unity-4.1-2023-07-19

image is exported with PMA enabled.

Note: I did disable PMA Vertex colors

Here is the Unity project to reproduce this problem:

spinebug.zip
8MB

Here is the animation I'm using:

common3.zip
624kB
Related Discussions
...

It seems like the issue you're experiencing with the additive slots rendering incorrectly when using a CanvasGroup Compatible material with PMA Vertex Colors disabled is related to how Spine and Unity handle premultiplied alpha (PMA) and transparency, especially in conjunction with CanvasGroup components.

When using a material with the CanvasGroup Compatible setting enabled for a SkeletonGraphic component, it's crucial to disable Advanced - PMA Vertex Colors to avoid a double-darkening effect of semi-transparent parts, as mentioned in the spine-unity documentation. However, this setup can lead to issues with rendering additive slots correctly because disabling PMA Vertex Colors affects how colors and transparency are calculated and rendered.

@ZumiKua Sorry to hear you're having troubles, thanks for sending the reproduction project up front.

The problem here is as follows:
While it's correct (on spine-unity 4.1) to disable Advanced - PMA Vertex colors when having Canvas Group Compatible enabled at the material, you can't use PMA for additive slots (unless when using SkeletonGraphic TintBlack). Thus at the _SkeletonData asset, you need to enable Blend Mode Materials - Apply Additive Material so that a separate additive material is used for additive slots instead of a single material. Then at the SkeletonGraphic Inspector you can enable Advanced - Multiple Canvas Renderers and right below under Additive Material assign the SkeletonGraphicAdditive material. Note that this additive material needs to have CanvasGroup Compatible enabled (you might want to create a copy SkeletonGraphicAdditive-CanvasGroup of the material if you need it elsewhere as well):

We're sorry that this is somewhat complicated with the spine-unity 4.1 runtime.
The good news is that with spine-unity 4.2 things have become much easier, with lots of Detect buttons to auto-configure parameters based on the skeleton and assign pre-made materials for you.

Listing the relevant documentation sections here for reference as well, in case it helps anyone:
https://esotericsoftware.com/spine-unity#CanvasGroup-alpha
And the parameter documentation on PMA Vertex Colors in the following section, a bit further down:
https://esotericsoftware.com/spine-unity#Parameters

    Harald Thanks for your help! With these modifications, the animation renders correctly.

    Maybe this solution should be mentioned in the documents?

    BTW, I got another question, does the change to Blend Mode Materials - Apply Additive Material have effects on SkeletonAnimation? I.e, does the SkeletonAnimation use the same _skeletonData will use additional draw call to render additive slots?

    If that is true, can I create a new _skeletonData with the same atlas and Skeleton Json but different setting on Blend Mode Materials - Apply Additive Material to prevent this behaviour? (just curious, currently no animation is used both on SkeletonGraphics and SkeletonAnimation.)

      ZumiKua

      ZumiKua Maybe this solution should be mentioned in the documents?

      You are right, this is not sufficiently explained, we will add that to the documentation accordingly.

      ZumiKua BTW, I got another question, does the change to Blend Mode Materials - Apply Additive Material have effects on SkeletonAnimation? I.e, does the SkeletonAnimation use the same _skeletonData will use additional draw call to render additive slots?

      Yes, unfortunately if you are using SkeletonGraphic and SkeletonAnimation with the same SkeletonDataAsset, Apply Additive Material will affect both. We would have liked to keep this independently configurable, but unfortunately SkeletonGraphic requires the SkeletonData to be set up accordingly so that it contains the additive Material reference.

      ZumiKua If that is true, can I create a new _skeletonData with the same atlas and Skeleton Json but different setting on Blend Mode Materials - Apply Additive Material to prevent this behaviour? (just curious, currently no animation is used both on SkeletonGraphics and SkeletonAnimation.)

      Yes, there should be no problem with it. If you encounter any issues, please do let us know.