• Unity
  • Are Attachments rendered when Slot color alpha = 0?

Are attachments rendered if their Slot has its color alpha value set to 0?

Mostly just curious - I have a Slot that has a couple attachments, and in Unity I'm checking which attachment is selected and doing stuff based on that. Also in Unity, I'm setting the Slot's color alpha to 0, since I don't want to actually see the attachments (just using them to drive some code). So was wondering if the selected Attachment is still getting rendered.

This is only being used for 2 Slots, so it isn't an optimization crisis or anything if they are still being rendered with 0 alpha haha 😃

Thanks!

Related Discussions
...

Unfortunately no, an alpha value of 0 still adds the attachment with the respective vertex colors. You would need to disable the attachment to prevent it from being drawn. I would immediately add such a check, but unfortunately it would not be semantically correct, since the alpha value means that the vertex color gets a certain color.A value assigned, which could still be interpreted specifically in a custom shader. While it's an unlikely use case, we can't quite be sure that no-one uses it that way. But of course feel free to modify the MeshGenerator class accordingly! 8)

Thanks Harald! Yeah, was thinking the exactly same thing with a custom shader still potentially doing stuff. Thanks for the info! :nerd:

You're very welcome! 🙂

2 ans plus tard

While I'm hesitant to necro a year-old thread, the title is just too perfect to not post it here:

We've just pushed a (breaking) optimization commit to the 4.2-beta branch to no longer render Attachments at Slot alpha 0 (fully transparent). Thus the behaviour mentioned in the above discussion has changed from this 4.2-beta commit onwards.

This optimization feature is enabled by default via
#define SLOT_ALPHA_DISABLES_ATTACHMENT in MeshGenerator.cs : line 42
You can comment out this line to revert to previous behaviour. You may only need this option disabled when utilizing a custom shader which uses vertex color alpha for purposes other than transparency, which is quite rare.

A new spine-unity 4.2-beta unitypackage is available for download here as usual:
https://esotericsoftware.com/spine-unity-download#spine-unity-4.2-beta

@Jamez0r Thought you might be interested in the above 4.2-beta update, since you've perhaps integrated similar MeshGenerator.cs changes in your local spine-unity installation. 🙂

    5 jours plus tard

    Harald Ooo, very neat! Thanks for letting me know!