Subdivide a triangle along its UVs I'm looking into a problem that first occured very trivial to me, but i got stuck and it's becoming a major issue right now. I'd like to subdivide a triangle by its given UVs, e.g. if the UVs are going from -n...+m or if they are greater than 1. So for example if i have a U coordinate from -1.5 ... 4 i'd like to subdivide at -1.0, 0.0, 1.0, 2.0, 3.0. Here's a visualization of the polygons that can be generated. Triangulation is trivial of course. 



My idea was to subdivide each edge separately for U and V and then find intersections and use these intersections to spawn triangles. However, i can't even find the rule how each line is constructed. Maybe someone can shed some light?

Thanks!
You can use barycentric coordinates to calculate points inside the triangle with a determinate value for uv.

The process is easy =>

Let's say that the UV coordinates of each vertex of the triangle are:

vertex 0 => u0,v0

vertex 1 => u1,v1

vertex 2 => u2,v2

A point inside the triangle has UV coordinates value expressed in function of its barycentric coordinates:

u coord = p0 * u0 + p1 * u1 + p2 * u2

v coord = p0 * v0 + p1 * v1 + p2 * v2

where p0,p1,p2 are the barycentric coordinates of this point.

As barycentric coordinates has the property:

p0 + p1 + p2 = 1

you can calculate the barycentric coordinates of a point with a specific value for UV just by solving these equations. I mean, for example, you want to know which point inside the triangle has

UV = (1,2)

To calculate such a point just do:

1 = p0 * u0 + p1 * u1 + p2 * u2

2 = p0 * v0 + p1 * v1 + p2 * v2

p0 + p1 + p2 = 1

as you know the values for (u0,v0), (u1,v1) and (u2,v2),  you can easily calculate the barycentric coordinates of this point, (p0, p1, p2).

Once you have the barycentric coordinates, you can calculate the coordinates (px,py,pz) of the point:

(px,py,pz) = p0 * vertex0 coordinates + p1 * vertex 1 coordinates + p2 * vertex 2 coordinates