mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[cocos2d-x] Ported new tint black shader. See #1003.
This commit is contained in:
parent
2c45dd2f1e
commit
f9245031a6
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user