• Create Account

### #ActualAressera

Posted 03 February 2013 - 04:27 PM

You could calculate the barycentric coordinates of the point you are interested in and then use the barycentric coordinates to weight the vertex values.

The barycentric coordinates of a point P for a triangle (v0, v1, v2) have the following relationship:

P = a0*v0 + a1*v1 + a2*v2

where (a0,a1,a2) are scalar weights for the vertices. For colors, etc just replace (v0,v1,v2) with (c0,c1,c2) to get the interpolated value at that point.

This even works for points outside of the triangle (which will produce negative weights), so it will handle your bounding box corners.

### #1Aressera

Posted 03 February 2013 - 02:20 PM

You could calculated the barycentric coordinates of the point you are interested in and then use the barycentric coordinates to weight the vertex values.

The barycentric coordinates of a point P for a triangle (v0, v1, v2) have the following relationship:

P = a0*v0 + a1*v1 + a2*v2

where (a0,a1,a2) are scalar weights for the vertices. For colors, etc just replace (v0,v1,v2) with (c0,c1,c2) to get the interpolated value at that point.

This should work fine if you are only interested in random points within the triangle. If you're trying to do rasterization, there is a more efficient way using bilinear interpolation.

PARTNERS