Browse Source

[cs][xna] Fixed tint black, see #1003. Opened up Triangulator and SkeletonClipping for debug rendering.

badlogic 8 năm trước cách đây
mục cha
commit
791d813bf1

+ 1 - 1
spine-csharp/src/SkeletonClipping.cs

@@ -258,7 +258,7 @@ namespace Spine {
 			return clipped;
 			return clipped;
 		}
 		}
 
 
-		static void MakeClockwise (ExposedList<float> polygon) {
+		public static void MakeClockwise (ExposedList<float> polygon) {
 			float[] vertices = polygon.Items;
 			float[] vertices = polygon.Items;
 			int verticeslength = polygon.Count;
 			int verticeslength = polygon.Count;
 
 

+ 1 - 1
spine-csharp/src/Triangulator.cs

@@ -31,7 +31,7 @@
 using System;
 using System;
 
 
 namespace Spine {
 namespace Spine {
-	internal class Triangulator {
+	public class Triangulator {
 		private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
 		private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
 		private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
 		private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();
 
 

+ 1 - 1
spine-xna/example-content/SpineEffect.fx

@@ -42,7 +42,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
 	float alpha = texColor.a * input.Color.a;
 	float alpha = texColor.a * input.Color.a;
 	float4 output;
 	float4 output;
 	output.a = alpha;
 	output.a = alpha;
-	output.rgb = (1.0 - texColor.rgb) * input.Color2.rgb * alpha + texColor.rgb * input.Color.rgb;
+	output.rgb = ((texColor.a - 1.0) * input.Color2.a + 1.0 - texColor.rgb) * input.Color2.rgb + texColor.rgb * input.Color.rgb;
 
 
 	return output;
 	return output;
 }
 }

+ 2 - 2
spine-xna/example/src/ExampleGame.cs

@@ -85,10 +85,10 @@ namespace Spine {
 			skeletonDebugRenderer.DrawClipping = true;
 			skeletonDebugRenderer.DrawClipping = true;
 
 
 			// String name = "spineboy-ess";
 			// String name = "spineboy-ess";
-			String name = "goblins-pro";
+			// String name = "goblins-pro";
 			// String name = "raptor-pro";
 			// String name = "raptor-pro";
 			// String name = "tank-pro";
 			// String name = "tank-pro";
-			// String name = "coin-pro";
+			String name = "coin-pro";
 			String atlasName = name.Replace("-pro", "").Replace("-ess", "");
 			String atlasName = name.Replace("-pro", "").Replace("-ess", "");
 			if (name == "goblins-pro") atlasName = "goblins-mesh";
 			if (name == "goblins-pro") atlasName = "goblins-mesh";
 			bool binaryData = false;
 			bool binaryData = false;

+ 6 - 1
spine-xna/src/SkeletonRenderer.cs

@@ -163,8 +163,13 @@ namespace Spine {
 
 
 				Color darkColor = new Color();
 				Color darkColor = new Color();
 				if (slot.HasSecondColor) {
 				if (slot.HasSecondColor) {
-					darkColor = new Color(slot.R2, slot.G2, slot.B2);
+					if (premultipliedAlpha) {
+						darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a);
+					} else {
+						darkColor = new Color(slot.R2 * a, slot.G2 * a, slot.B2 * a);
+					}
 				}
 				}
+				darkColor.A = premultipliedAlpha ? (byte)255 : (byte)0;
 
 
 				// clip
 				// clip
 				if (clipper.IsClipping()) {
 				if (clipper.IsClipping()) {