diff --git a/spine-cocos2dx/src/spine/SkeletonRenderer.cpp b/spine-cocos2dx/src/spine/SkeletonRenderer.cpp index bb55557d4..cde7ce45e 100644 --- a/spine-cocos2dx/src/spine/SkeletonRenderer.cpp +++ b/spine-cocos2dx/src/spine/SkeletonRenderer.cpp @@ -227,6 +227,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t Color4F color; Color4F darkColor; + float darkPremultipliedAlpha = _premultipliedAlpha ? 255 : 0; AttachmentVertices* attachmentVertices = nullptr; TwoColorTrianglesCommand* lastTwoColorTrianglesCommand = nullptr; for (int i = 0, n = _skeleton->slotsCount; i < n; ++i) { @@ -317,6 +318,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t darkColor.g = 0; darkColor.b = 0; } + darkColor.a = darkPremultipliedAlpha; color.a *= nodeColor.a * _skeleton->color.a * slot->color.a * 255; // skip rendering if the color of this attachment is 0 @@ -482,7 +484,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t vertex->color2.r = (GLubyte)(darkCopy.r * 255); vertex->color2.g = (GLubyte)(darkCopy.g * 255); vertex->color2.b = (GLubyte)(darkCopy.b * 255); - vertex->color2.a = 1; + vertex->color2.a = (GLubyte)darkColor.a; } } else { for (int v = 0, vn = batchedTriangles->getTriangles().vertCount, vv = 0; v < vn; ++v, vv += 2) { @@ -498,7 +500,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t vertex->color2.r = (GLubyte)darkColor.r; vertex->color2.g = (GLubyte)darkColor.g; vertex->color2.b = (GLubyte)darkColor.b; - vertex->color2.a = 1; + vertex->color2.a = (GLubyte)darkColor.a; } } } else { @@ -528,7 +530,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t vertex->color2.r = (GLubyte)(darkCopy.r * 255); vertex->color2.g = (GLubyte)(darkCopy.g * 255); vertex->color2.b = (GLubyte)(darkCopy.b * 255); - vertex->color2.a = 1; + vertex->color2.a = (GLubyte)darkColor.a; } } else { for (int v = 0, vn = batchedTriangles->getTriangles().vertCount; v < vn; ++v) { @@ -540,7 +542,7 @@ void SkeletonRenderer::draw (Renderer* renderer, const Mat4& transform, uint32_t vertex->color2.r = (GLubyte)darkColor.r; vertex->color2.g = (GLubyte)darkColor.g; vertex->color2.b = (GLubyte)darkColor.b; - vertex->color2.a = 1; + vertex->color2.a = (GLubyte)darkColor.a; } } } diff --git a/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp b/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp index 46b92e922..fa3e55149 100644 --- a/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp +++ b/spine-cocos2dx/src/spine/SkeletonTwoColorBatch.cpp @@ -143,8 +143,8 @@ varying vec2 v_texCoord; void main() { vec4 texColor = texture2D(CC_Texture0, v_texCoord); float alpha = texColor.a * v_light.a; - gl_FragColor.a = alpha; - gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb; + gl_FragColor.a = alpha; + gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb; } );