I want to find the texture coordinates for point P. I have the vertices of the triangle and their corresponding uv coordinates.

The numbers in the little squares in the texture represent color values.

What are the steps of computing the uv coordinates of P?

enter image description here


1 Answer 1


You need to convert the point into barycentric coordinates and then use those points to interpolate the u, v coordinates.

Here is a previous answer that can help calculate the coordinates: What's the most efficient way to find barycentric coordinates?

With the barycentric coordinates, you then interpolate the UVs and get a weighted sum of the three vertices:

If your barycentric coordinates are defined as u,v,w then using the following equation (once for uv.X and once for uv.Y):

Point.UV.x = u * P0.uv.x + v * P1.uv.x + w * P2.uv.x
Point.UV.y = u * P0.uv.y + v * P1.uv.y + w * P2.uv.y

This works to linearly interpolate any property of each vertex across the triangle. Beware that interpolating normals linearly doesn't do what you want it to do as the normal becomes denormalized. This isn't an issue in your case.

  • 1
    \$\begingroup\$ i found the barymetric coordinates. Now what points should I interpolate and what kind of interpolation do you mean ? \$\endgroup\$
    – john john
    Jan 5, 2016 at 17:31
  • \$\begingroup\$ @johnjohn You need to interpolate. There's a question and answer over on Math SE about how to do this. Steven also included the code in his answer. \$\endgroup\$ Jan 5, 2016 at 20:12
  • \$\begingroup\$ @johnjohn I've updated the answer to include the interpolation code. \$\endgroup\$
    – Steven
    Jan 5, 2016 at 20:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .