<p>To use generalized barycentric coordinates to map between these two polygon (one n-sided and the other square), you can add artificial vertices around the square so you are mapping one $n$-sided polygon to another. For example, <a href="https://i.stack.imgur.com/OFWvv.png" rel="nofollow noreferrer">this image</a> shows an eight-sided polygon and a square augmented with side midpoints to also have eight vertices.</p>

<p>Then on the original polygon, you define some generalized barycentric coordinates:</p>

<p>x = L1(x) v1 + L2(x) v2 + ... + Ln(x) vn</p>

<p>The specific functions L1, L2, ..., Ln are defined by which ever generalized barycentric coordinate you select, e.g., mean value Wachspress, etc. </p>

<p>Corresponding generalized barycentric coordinates are also defined for the square with the extra matching vertices identified, i.e.,</p>

<p>y = M1(y) w1 + M2(y) w2 + ... + Mn(y) wn</p>

<p>Now, given a point x in the polygon, we compute the associated point y in the square (i.e. the (u,v) that we can look up the texture from) using the barycentric coordinates from the polygon but the vertex positions in the square,</p>

<p>y= L1(x) w1 + L2(x) w2 + ... + Ln(x) wn</p>

<p>A couple notes:</p>

<ul>
<li>Following this approach, you probably don't want to use Wachspress coordinates. They don't behave well when adding these extra vertices in the middle of straight edges. <a href="https://i.stack.imgur.com/1KZrk.png" rel="nofollow noreferrer">This image</a> (from <a href="https://arxiv.org/pdf/1111.5588.pdf" rel="nofollow noreferrer">here</a>) shows how Wachpress coordinates work poorly in this situation.</li>
<li>There are still decisions to be made about where exactly to split the sides of the square to get a matching number of vertices, and how to associate the vertices between the polygon and the square. These decisions will definitely impact how the texture gets stretched and skewed.</li>
</ul>
Get proper UV at barycentric coordinates with interpolation
<p>I'm trying to implement proper texturing of convex polygons. I have a polygon with n triangles, for each triangle i'm calculating barycentric coordinates which are uv of each one but in [0..1] of each triangle, not entire polygon. How to interpolate each uv so it stretches (wraps and not repeats as it is now) entire texture ? </p>

<p>Now it looks like this: </p>

<p><img src="https://i.stack.imgur.com/JTe3M.png" alt="enter image description here"></p>

<pre><code>//region.triangulatedVectors = List&lt;Vector2&gt; // triangle points in CCW

//foreach triangle 
for (int i = 0;i&lt;region.triangulatedVectors.size();i+=3){
    float aX = region.triangulatedVectors.get(i).x;
    float aY = region.triangulatedVectors.get(i).y;
    float bX = region.triangulatedVectors.get(i+1).x;
    float bY = region.triangulatedVectors.get(i+1).y;
    float cX = region.triangulatedVectors.get(i+2).x;
    float cY = region.triangulatedVectors.get(i+2).y;
    Vector2 bary0 = new Vector2();
    Vector2 bary1 = new Vector2();
    Vector2 bary2 = new Vector2();
    Vector2 a = new Vector2(aX, aY);
    Vector2 b = new Vector2(bX, bY);
    Vector2 c = new Vector2(cX, cY);
    GeometryUtils.barycentric(a, a, b, c, bary0);
    GeometryUtils.barycentric(b, a, b, c, bary1);
    GeometryUtils.barycentric(c, a, b, c, bary2);
    //first point 
    texCoords[k++] = bary0.x;
    texCoords[k++] = bary0.y;
    texCoords[k++] = bary1.x;
    texCoords[k++] = bary1.y;
    texCoords[k++] = bary2.x;
    texCoords[k++] = bary2.y;
    //TODO , interpolate
}
</code></pre>

<p>It seems that there are 3 ways of dealing with 2D. Wachspress, Discrete harmonic and Mean value. </p>