mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[libgdx] Fixed non-PMA rendering in SkeletonRenderer. Colors were always premultiplied by alpha.
This commit is contained in:
parent
cdc335d41b
commit
221372e409
@ -78,10 +78,11 @@ public class SkeletonRenderer {
|
|||||||
region.computeWorldVertices(slot.getBone(), vertices, 0, 5);
|
region.computeWorldVertices(slot.getBone(), vertices, 0, 5);
|
||||||
Color color = region.getColor(), slotColor = slot.getColor();
|
Color color = region.getColor(), slotColor = slot.getColor();
|
||||||
float alpha = a * slotColor.a * color.a * 255;
|
float alpha = a * slotColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
|
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
|
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * slotColor.r * color.r * alpha));
|
| (int)(r * slotColor.r * color.r * multiplier));
|
||||||
float[] uvs = region.getUVs();
|
float[] uvs = region.getUVs();
|
||||||
for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
|
for (int u = 0, v = 2; u < 8; u += 2, v += 5) {
|
||||||
vertices[v] = c;
|
vertices[v] = c;
|
||||||
@ -173,10 +174,11 @@ public class SkeletonRenderer {
|
|||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Color slotColor = slot.getColor();
|
Color slotColor = slot.getColor();
|
||||||
float alpha = a * slotColor.a * color.a * 255;
|
float alpha = a * slotColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float c = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * slotColor.b * color.b * alpha) << 16) //
|
| ((int)(b * slotColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * slotColor.g * color.g * alpha) << 8) //
|
| ((int)(g * slotColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * slotColor.r * color.r * alpha));
|
| (int)(r * slotColor.r * color.r * multiplier));
|
||||||
|
|
||||||
BlendMode slotBlendMode = slot.data.getBlendMode();
|
BlendMode slotBlendMode = slot.data.getBlendMode();
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
@ -284,16 +286,17 @@ public class SkeletonRenderer {
|
|||||||
if (texture != null) {
|
if (texture != null) {
|
||||||
Color lightColor = slot.getColor();
|
Color lightColor = slot.getColor();
|
||||||
float alpha = a * lightColor.a * color.a * 255;
|
float alpha = a * lightColor.a * color.a * 255;
|
||||||
|
float multiplier = premultipliedAlpha ? alpha : 255;
|
||||||
float light = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
float light = NumberUtils.intToFloatColor(((int)alpha << 24) //
|
||||||
| ((int)(b * lightColor.b * color.b * alpha) << 16) //
|
| ((int)(b * lightColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * lightColor.g * color.g * alpha) << 8) //
|
| ((int)(g * lightColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * lightColor.r * color.r * alpha));
|
| (int)(r * lightColor.r * color.r * multiplier));
|
||||||
Color darkColor = slot.getDarkColor();
|
Color darkColor = slot.getDarkColor();
|
||||||
if (darkColor == null) darkColor = Color.BLACK;
|
if (darkColor == null) darkColor = Color.BLACK;
|
||||||
float dark = NumberUtils.intToFloatColor( //
|
float dark = NumberUtils.intToFloatColor( //
|
||||||
((int)(b * darkColor.b * color.b * 255) << 16) //
|
((int)(b * darkColor.b * color.b * multiplier) << 16) //
|
||||||
| ((int)(g * darkColor.g * color.g * 255) << 8) //
|
| ((int)(g * darkColor.g * color.g * multiplier) << 8) //
|
||||||
| (int)(r * darkColor.r * color.r * 255));
|
| (int)(r * darkColor.r * color.r * multiplier));
|
||||||
|
|
||||||
BlendMode slotBlendMode = slot.data.getBlendMode();
|
BlendMode slotBlendMode = slot.data.getBlendMode();
|
||||||
if (slotBlendMode != blendMode) {
|
if (slotBlendMode != blendMode) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user