Our artist is encountering an interesting issue that occurs whenever some SkeletonAnimation component's 'PMA Vertex Colors' checkbox is disabled. It seems to me that under these conditions, the Spine/Skeleton shader neglects to correctly apply slot alpha values (specifically the bug we're experiencing is that there's no change in rendered opacity even though our animations should be fading/disappearing various different attachments, & we've found our animations DO cause opacity changes so long as this toggle stays enabled).
I already have some familiarity with the ins and outs of PMA in Spine! I'm pretty sure for this project we indeed desire this checkbox to read 'false', since we're going for the Linear Color + non-PMA graphics setup (so to this end we're unchecking 'PMA Vertex Colors' on our SkeletonAnimations, exporting our Spines without PMA, and also checking the 'Straight Alpha Texture' box on all our Spine materials).
I played a little with the Skeleton shader code & was able to get what looked to me like correct color compositing. Here's the original version of the fragment shader, as it exists in Spine:
float4 frag (VertexOutput i) : SV_Target {
float4 texColor = tex2D(_MainTex, i.uv);
#if defined(_STRAIGHT_ALPHA_INPUT)
texColor.rgb *= texColor.a;
#endif
return (texColor * i.vertexColor);
}
All I did was rearrange where we multiply in the vertexColor, like so:
float4 frag (VertexOutput i) : SV_Target {
float4 texColor = tex2D(_MainTex, i.uv) * i.vertexColor;
#if defined(_STRAIGHT_ALPHA_INPUT)
texColor.rgb *= texColor.a;
#endif
return (texColor);
}
It's my understanding this shader supports both yes-PMA and no-PMA via employing the blendmode 'One OneMinusSrcAlpha' (the PMA-friendly one) & then in the case of no-PMA, doing the 'multiply SrcColor by SrcAlpha' step here within this frag function. I think what's happening is that the 'vertexColor' variable's alpha value (the thing we're currently animating lots!) never gets multiplied into the final rgb channels.
Part of me thinks the shader has to be fine actually, & it's us doing something incorrect elsewhere (since I and many other users have obvs been using this shader fine for years). So I wanted to ask you Spine folks for your opinion about it!