mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 10:16:54 +08:00
[cocos2d-objc] Ported new tint black shader. See #1003.
This commit is contained in:
parent
f9245031a6
commit
3f242450cf
@ -88,7 +88,7 @@ void main() {
|
|||||||
vec4 texColor = texture2D(texture, v_texCoord);
|
vec4 texColor = texture2D(texture, v_texCoord);
|
||||||
float alpha = texColor.a * v_light.a;
|
float alpha = texColor.a * v_light.a;
|
||||||
gl_FragColor.a = alpha;
|
gl_FragColor.a = alpha;
|
||||||
gl_FragColor.rgb = (1.0 - texColor.rgb) * v_dark.rgb * alpha + texColor.rgb * v_light.rgb;
|
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -192,7 +192,7 @@ static bool handlerQueued = false;
|
|||||||
unsigned short* triangles = 0;
|
unsigned short* triangles = 0;
|
||||||
int trianglesCount = 0;
|
int trianglesCount = 0;
|
||||||
float r = 0, g = 0, b = 0, a = 0;
|
float r = 0, g = 0, b = 0, a = 0;
|
||||||
float dr = 0, dg = 0, db = 0;
|
float dr = 0, dg = 0, db = 0, da = _premultipliedAlpha ? 1 : 0;
|
||||||
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
|
||||||
spSlot* slot = _skeleton->drawOrder[i];
|
spSlot* slot = _skeleton->drawOrder[i];
|
||||||
if (!slot->attachment) continue;
|
if (!slot->attachment) continue;
|
||||||
@ -336,7 +336,7 @@ static bool handlerQueued = false;
|
|||||||
dark.r = dr;
|
dark.r = dr;
|
||||||
dark.g = dg;
|
dark.g = dg;
|
||||||
dark.b = db;
|
dark.b = db;
|
||||||
dark.a = 1;
|
dark.a = da;
|
||||||
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
for (int i = 0; i * 2 < verticesCount; i++, verts++) {
|
||||||
spColor lightCopy = light;
|
spColor lightCopy = light;
|
||||||
spColor darkCopy = dark;
|
spColor darkCopy = dark;
|
||||||
@ -353,7 +353,7 @@ static bool handlerQueued = false;
|
|||||||
verts->z = vertex.position.z;
|
verts->z = vertex.position.z;
|
||||||
verts->w = vertex.position.w;
|
verts->w = vertex.position.w;
|
||||||
verts->color = ((unsigned short)(lightCopy.r * 255))| ((unsigned short)(lightCopy.g * 255)) << 8 | ((unsigned short)(lightCopy.b * 255)) <<16 | ((unsigned short)(lightCopy.a * 255)) << 24;
|
verts->color = ((unsigned short)(lightCopy.r * 255))| ((unsigned short)(lightCopy.g * 255)) << 8 | ((unsigned short)(lightCopy.b * 255)) <<16 | ((unsigned short)(lightCopy.a * 255)) << 24;
|
||||||
verts->color2 = ((unsigned short)(darkCopy.r * 255)) | ((unsigned short)(darkCopy.g * 255)) << 8 | ((unsigned short)(darkCopy.b * 255)) << 16 | ((unsigned short)(255)) << 24;
|
verts->color2 = ((unsigned short)(darkCopy.r * 255)) | ((unsigned short)(darkCopy.g * 255)) << 8 | ((unsigned short)(darkCopy.b * 255)) << 16 | ((unsigned short)(darkCopy.a * 255)) << 24;
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -366,7 +366,7 @@ static bool handlerQueued = false;
|
|||||||
verts->z = vertex.position.z;
|
verts->z = vertex.position.z;
|
||||||
verts->w = vertex.position.w;
|
verts->w = vertex.position.w;
|
||||||
verts->color = ((unsigned short)(r * 255))| ((unsigned short)(g * 255)) << 8 | ((unsigned short)(b * 255)) <<16 | ((unsigned short)(a * 255)) << 24;
|
verts->color = ((unsigned short)(r * 255))| ((unsigned short)(g * 255)) << 8 | ((unsigned short)(b * 255)) <<16 | ((unsigned short)(a * 255)) << 24;
|
||||||
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(255)) << 24;
|
verts->color2 = ((unsigned short)(dr * 255)) | ((unsigned short)(dg * 255)) << 8 | ((unsigned short)(db * 255)) << 16 | ((unsigned short)(da * 255)) << 24;
|
||||||
verts->u = uvs[i * 2];
|
verts->u = uvs[i * 2];
|
||||||
verts->v = 1 - uvs[i * 2 + 1];
|
verts->v = 1 - uvs[i * 2 + 1];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user