The distance-based weighting approach is an interesting one, though I think it’d have a somewhat strange effect when a triangle was scaled between skinny and fat.

Since nobody else has posted, I’ll briefly state how to do plane equations and barycentrics.

Plane equations:

Each component of color is a plane equation of the form

f = Ax + By + C

We know that

f1 = A(v1.x) + B(v1.y) + C(v1.z)

f2 = A(v2.x) + B(v2.y) + C(v2.z)

f3 = A(v3.x) + B(v3.y) + C(v3.z)

or

|f1| | v1.x v1.y v1.z | | A |

|f2| = | v2.x v2.y v2.z | | B |

|f3| | v3.x v3.y v3.z | | C |

So if we rewrite this as

```
| v1.x v1.y v1.z |
```

M = | v2.x v2.y v2.z |

| v3.x v3.y v3.z |

Then the plane equation is

| A | | f1 |

| B | = (M^1) | f2 |

| C | | f3 |

This and numerous other interesting observations are noted in http://www.cs.unc.edu/~olano/papers/2dh-tri/ .

Barycentric equations:

Barycentric is just a weighted average, so

f = A*f1 + B*f2 + C*f3.

But the weights are based on distance from each edge. A vertex v on edge(v2,v3) has an A weight of 0. And the general formula is

A = dist( v, edge(v2,v3) ) / dist( v1, edge(v2,v3) )

B = dist( v, edge(v3,v1) ) / dist( v2, edge(v3,v1) )

C = dist( v, edge(v1,v2) ) / dist( v3, edge(v1,v2) )

For points inside a triangle, it’s true that A+B+C==1, which can be useful.

The interesting thing about Barycentric weights is that they’re independent of the attribute being interpolated, so once you’ve computed them they work for all attributes.

But, you have to compute new barycentric weights for each point in the triangle.

Anyway, I hope this helps.

Thanks -

Cass