public static Vector2 InterpolateUV(this VertexTriangle triangle, Vector3 screenPosition) { float w1, w2, w3; triangle.InterpolateWeight(screenPosition, out w1, out w2, out w3); return(w1 * triangle.Vertexs[0].UV + w2 * triangle.Vertexs[1].UV + w3 * triangle.Vertexs[2].UV); }
public static Color InterpolateColor(this VertexTriangle triangle, Vector3 screenPosition) { float w1, w2, w3; triangle.InterpolateWeight(screenPosition, out w1, out w2, out w3); float colorR = w1 * triangle.Vertexs[0].Color.R + w2 * triangle.Vertexs[1].Color.R + w3 * triangle.Vertexs[2].Color.R; float colorG = w1 * triangle.Vertexs[0].Color.G + w2 * triangle.Vertexs[1].Color.G + w3 * triangle.Vertexs[2].Color.G; float colorB = w1 * triangle.Vertexs[0].Color.B + w2 * triangle.Vertexs[1].Color.B + w3 * triangle.Vertexs[2].Color.B; return(Color.FromArgb((int)colorR, (int)colorG, (int)colorB)); }