@esotericsoftware/spine-webgl 4.3.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14968,10 +14968,12 @@ void main () {
14968
14968
  twoColorTint = false;
14969
14969
  renderable = new Renderable([], 0, 0);
14970
14970
  clipper = new SkeletonClipping();
14971
- temp = new Vector2();
14972
- temp2 = new Vector2();
14973
- temp3 = new Color();
14974
- temp4 = new Color();
14971
+ /**
14972
+ * Batches additive slots together with normal slots by rendering additive slots with premultiplied alpha RGB and zero alpha,
14973
+ * while using normal PMA blending. This reduces draw calls for normal/additive/normal sequences with the same texture.
14974
+ * Disable this if rendering to a transparent target and the accumulated destination alpha from additive blending must be preserved.
14975
+ */
14976
+ pmaAdditiveBatching = true;
14975
14977
  constructor(context, twoColorTint = true) {
14976
14978
  this.twoColorTint = twoColorTint;
14977
14979
  if (twoColorTint)
@@ -15050,7 +15052,9 @@ void main () {
15050
15052
  finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r * alpha;
15051
15053
  finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g * alpha;
15052
15054
  finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b * alpha;
15053
- finalColor.a = alpha;
15055
+ const slotBlendMode = slot.data.blendMode;
15056
+ const additiveBlend = this.pmaAdditiveBatching && slotBlendMode === 1 /* Additive */;
15057
+ finalColor.a = additiveBlend ? 0 : alpha;
15054
15058
  const darkColor = this.tempColor2;
15055
15059
  if (!pose.darkColor)
15056
15060
  darkColor.set(0, 0, 0, 1);
@@ -15060,9 +15064,9 @@ void main () {
15060
15064
  darkColor.b = pose.darkColor.b * alpha;
15061
15065
  darkColor.a = 1;
15062
15066
  }
15063
- const slotBlendMode = slot.data.blendMode;
15064
- if (slotBlendMode !== blendMode) {
15065
- blendMode = slotBlendMode;
15067
+ const batchBlendMode = additiveBlend ? 0 /* Normal */ : slotBlendMode;
15068
+ if (batchBlendMode !== blendMode) {
15069
+ blendMode = batchBlendMode;
15066
15070
  batcher.setBlendMode(blendMode);
15067
15071
  }
15068
15072
  if (clipper.isClipping() && clipper.clipTriangles(renderable.vertices, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint, vertexSize)) {
@@ -15077,7 +15081,7 @@ void main () {
15077
15081
  verts[v] = finalColor.r;
15078
15082
  verts[v + 1] = finalColor.g;
15079
15083
  verts[v + 2] = finalColor.b;
15080
- verts[v + 3] = alpha;
15084
+ verts[v + 3] = finalColor.a;
15081
15085
  verts[v + 4] = uvs[u];
15082
15086
  verts[v + 5] = uvs[u + 1];
15083
15087
  }
@@ -15086,7 +15090,7 @@ void main () {
15086
15090
  verts[v] = finalColor.r;
15087
15091
  verts[v + 1] = finalColor.g;
15088
15092
  verts[v + 2] = finalColor.b;
15089
- verts[v + 3] = alpha;
15093
+ verts[v + 3] = finalColor.a;
15090
15094
  verts[v + 4] = uvs[u];
15091
15095
  verts[v + 5] = uvs[u + 1];
15092
15096
  verts[v + 6] = darkColor.r;