mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Fixed SkeletonGraphic TintBlack shader with PMA Vertex Color and CanvasGroup Compatible looking incorrect. Closes #2483.
This commit is contained in:
parent
c33b56872f
commit
41ee663279
@ -619,13 +619,12 @@ namespace Spine.Unity {
|
|||||||
color.r = (byte)(skeletonR * slot.R * c.r * color.a);
|
color.r = (byte)(skeletonR * slot.R * c.r * color.a);
|
||||||
color.g = (byte)(skeletonG * slot.G * c.g * color.a);
|
color.g = (byte)(skeletonG * slot.G * c.g * color.a);
|
||||||
color.b = (byte)(skeletonB * slot.B * c.b * color.a);
|
color.b = (byte)(skeletonB * slot.B * c.b * color.a);
|
||||||
if (slot.Data.BlendMode == BlendMode.Additive) {
|
if (canvasGroupTintBlack) {
|
||||||
if (canvasGroupTintBlack)
|
tintBlackAlpha = (slot.Data.BlendMode == BlendMode.Additive) ? 0 : colorA;
|
||||||
tintBlackAlpha = 0;
|
color.a = 255;
|
||||||
else
|
} else {
|
||||||
|
if (slot.Data.BlendMode == BlendMode.Additive)
|
||||||
color.a = 0;
|
color.a = 0;
|
||||||
} else if (canvasGroupTintBlack) { // other blend modes
|
|
||||||
tintBlackAlpha = colorA;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
color.a = (byte)(skeletonA * slot.A * c.a * 255);
|
color.a = (byte)(skeletonA * slot.A * c.a * 255);
|
||||||
@ -882,7 +881,9 @@ namespace Spine.Unity {
|
|||||||
color.r = (byte)(r * slot.R * regionAttachment.R * color.a);
|
color.r = (byte)(r * slot.R * regionAttachment.R * color.a);
|
||||||
color.g = (byte)(g * slot.G * regionAttachment.G * color.a);
|
color.g = (byte)(g * slot.G * regionAttachment.G * color.a);
|
||||||
color.b = (byte)(b * slot.B * regionAttachment.B * color.a);
|
color.b = (byte)(b * slot.B * regionAttachment.B * color.a);
|
||||||
if (slot.Data.BlendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
if (canvasGroupTintBlack) color.a = 255;
|
||||||
|
else if (slot.Data.BlendMode == BlendMode.Additive) color.a = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
color.a = (byte)(a * slot.A * regionAttachment.A * 255);
|
color.a = (byte)(a * slot.A * regionAttachment.A * 255);
|
||||||
color.r = (byte)(r * slot.R * regionAttachment.R * 255);
|
color.r = (byte)(r * slot.R * regionAttachment.R * 255);
|
||||||
@ -929,7 +930,8 @@ namespace Spine.Unity {
|
|||||||
color.r = (byte)(r * slot.R * meshAttachment.R * color.a);
|
color.r = (byte)(r * slot.R * meshAttachment.R * color.a);
|
||||||
color.g = (byte)(g * slot.G * meshAttachment.G * color.a);
|
color.g = (byte)(g * slot.G * meshAttachment.G * color.a);
|
||||||
color.b = (byte)(b * slot.B * meshAttachment.B * color.a);
|
color.b = (byte)(b * slot.B * meshAttachment.B * color.a);
|
||||||
if (slot.Data.BlendMode == BlendMode.Additive && !canvasGroupTintBlack) color.a = 0;
|
if (canvasGroupTintBlack) color.a = 255;
|
||||||
|
else if (slot.Data.BlendMode == BlendMode.Additive) color.a = 0;
|
||||||
} else {
|
} else {
|
||||||
color.a = (byte)(a * slot.A * meshAttachment.A * 255);
|
color.a = (byte)(a * slot.A * meshAttachment.A * 255);
|
||||||
color.r = (byte)(r * slot.R * meshAttachment.R * 255);
|
color.r = (byte)(r * slot.R * meshAttachment.R * 255);
|
||||||
|
|||||||
@ -44,18 +44,20 @@ VertexOutput vert(VertexInput IN) {
|
|||||||
OUT.texcoord = IN.texcoord;
|
OUT.texcoord = IN.texcoord;
|
||||||
|
|
||||||
OUT.darkColor = float4(IN.uv1.r, IN.uv1.g, IN.uv2.r, IN.uv2.g);
|
OUT.darkColor = float4(IN.uv1.r, IN.uv1.g, IN.uv2.r, IN.uv2.g);
|
||||||
OUT.darkColor.rgb = GammaToTargetSpace(OUT.darkColor.rgb) + (_Black.rgb * IN.color.a);
|
|
||||||
|
|
||||||
#ifdef _CANVAS_GROUP_COMPATIBLE
|
#ifdef _CANVAS_GROUP_COMPATIBLE
|
||||||
// CanvasGroup alpha multiplies existing vertex color alpha, but
|
// CanvasGroup alpha multiplies existing vertex color alpha, but
|
||||||
// does not premultiply it to rgb components. This causes problems
|
// does not premultiply it to rgb components. This causes problems
|
||||||
// with additive blending (alpha = 0), which is why we store the
|
// with additive blending (alpha = 0), which is why we store the
|
||||||
// alpha value in uv2.g (darkColor.a).
|
// alpha value in uv2.g (darkColor.a) and store 1.0 in vertex color alpha.
|
||||||
float originalAlpha = OUT.darkColor.a;
|
float originalAlpha = IN.uv2.g;
|
||||||
OUT.canvasAlpha = (originalAlpha == 0) ? IN.color.a : IN.color.a / originalAlpha;
|
OUT.canvasAlpha = IN.color.a;
|
||||||
#else
|
#else
|
||||||
float originalAlpha = IN.color.a;
|
float originalAlpha = IN.color.a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
OUT.darkColor.rgb = GammaToTargetSpace(OUT.darkColor.rgb) + (_Black.rgb * originalAlpha);
|
||||||
|
|
||||||
// Note: CanvasRenderer performs a GammaToTargetSpace conversion on vertex color already,
|
// Note: CanvasRenderer performs a GammaToTargetSpace conversion on vertex color already,
|
||||||
// however incorrectly assuming straight alpha color.
|
// however incorrectly assuming straight alpha color.
|
||||||
float4 vertexColor = PMAGammaToTargetSpace(half4(TargetToGammaSpace(IN.color.rgb), originalAlpha));
|
float4 vertexColor = PMAGammaToTargetSpace(half4(TargetToGammaSpace(IN.color.rgb), originalAlpha));
|
||||||
|
|||||||
@ -97,7 +97,7 @@ namespace Spine.Unity {
|
|||||||
+ "a) enable 'CanvasGroup Compatible' at the Material or\n"
|
+ "a) enable 'CanvasGroup Compatible' at the Material or\n"
|
||||||
+ "b) disable 'Canvas Group Tint Black' at the SkeletonGraphic component under 'Advanced'.\n"
|
+ "b) disable 'Canvas Group Tint Black' at the SkeletonGraphic component under 'Advanced'.\n"
|
||||||
+ "You may want to duplicate the 'SkeletonGraphicTintBlack' material and change settings at the duplicate to not affect all instances.";
|
+ "You may want to duplicate the 'SkeletonGraphicTintBlack' material and change settings at the duplicate to not affect all instances.";
|
||||||
public static readonly string kCanvasGroupCompatibleDisabledMessage =
|
public static readonly string kCanvasGroupTintBlackDisabledMessage =
|
||||||
"\nWarning: 'CanvasGroup Compatible' is enabled at the Material but 'Canvas Group Tint Black' is disabled at SkeletonGraphic!\n\nPlease\n"
|
"\nWarning: 'CanvasGroup Compatible' is enabled at the Material but 'Canvas Group Tint Black' is disabled at SkeletonGraphic!\n\nPlease\n"
|
||||||
+ "a) disable 'CanvasGroup Compatible' at the Material or\n"
|
+ "a) disable 'CanvasGroup Compatible' at the Material or\n"
|
||||||
+ "b) enable 'Canvas Group Tint Black' at the SkeletonGraphic component under 'Advanced'.\n"
|
+ "b) enable 'Canvas Group Tint Black' at the SkeletonGraphic component under 'Advanced'.\n"
|
||||||
@ -157,16 +157,17 @@ namespace Spine.Unity {
|
|||||||
isProblematic = true;
|
isProblematic = true;
|
||||||
errorMessage += kNoSkeletonGraphicTintBlackMaterialMessage;
|
errorMessage += kNoSkeletonGraphicTintBlackMaterialMessage;
|
||||||
}
|
}
|
||||||
if (settings.canvasGroupTintBlack == true && !IsCanvasGroupCompatible(material)) {
|
bool isCanvasGroupCompatible = IsCanvasGroupCompatible(material);
|
||||||
|
if (settings.canvasGroupTintBlack == true && !isCanvasGroupCompatible) {
|
||||||
isProblematic = true;
|
isProblematic = true;
|
||||||
errorMessage += kCanvasGroupCompatibleMessage;
|
errorMessage += kCanvasGroupCompatibleMessage;
|
||||||
}
|
}
|
||||||
if (settings.tintBlack == true && settings.canvasGroupTintBlack == false
|
if (settings.tintBlack == true && settings.canvasGroupTintBlack == false && isCanvasGroupCompatible) {
|
||||||
&& IsCanvasGroupCompatible(material)) {
|
|
||||||
isProblematic = true;
|
isProblematic = true;
|
||||||
errorMessage += kCanvasGroupCompatibleDisabledMessage;
|
errorMessage += kCanvasGroupTintBlackDisabledMessage;
|
||||||
}
|
}
|
||||||
if (settings.pmaVertexColors == true && IsCanvasGroupCompatible(material)) {
|
if (settings.pmaVertexColors == true && settings.canvasGroupTintBlack == false
|
||||||
|
&& isCanvasGroupCompatible) {
|
||||||
isProblematic = true;
|
isProblematic = true;
|
||||||
errorMessage += kCanvasGroupCompatiblePMAVertexMessage;
|
errorMessage += kCanvasGroupCompatiblePMAVertexMessage;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-unity",
|
"name": "com.esotericsoftware.spine.spine-unity",
|
||||||
"displayName": "spine-unity Runtime",
|
"displayName": "spine-unity Runtime",
|
||||||
"description": "This plugin provides the spine-unity runtime core.",
|
"description": "This plugin provides the spine-unity runtime core.",
|
||||||
"version": "4.2.54",
|
"version": "4.2.55",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user