fix dark in both pma and non-pma (#993)

This commit is contained in:
Ivan Popelyshev 2017-09-28 12:22:48 +03:00 committed by Mario Zechner
parent 69923111b9
commit 8506e16f2d
2 changed files with 14 additions and 5 deletions

View File

@ -253,9 +253,8 @@ module spine.webgl {
void main () {
vec4 texColor = texture2D(u_texture, v_texCoords);
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 = texColor.a * v_light.a;
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
}
`;

View File

@ -122,8 +122,18 @@ module spine.webgl {
finalColor.b *= finalColor.a;
}
let darkColor = this.tempColor2;
if (slot.darkColor == null) darkColor.set(0, 0, 0, 1);
else darkColor.setFromColor(slot.darkColor);
if (slot.darkColor == null)
darkColor.set(0, 0, 0, 1.0);
else {
if (premultipliedAlpha) {
darkColor.r = slot.darkColor.r * finalColor.a;
darkColor.g = slot.darkColor.g * finalColor.a;
darkColor.b = slot.darkColor.b * finalColor.a;
} else {
darkColor.setFromColor(slot.darkColor);
}
darkColor.a = premultipliedAlpha ? 1.0 : 0.0;
}
let slotBlendMode = slot.data.blendMode;
if (slotBlendMode != blendMode) {