<p>After watching some Youtube tutorials I thought I had understood the concept of UV mapping:<br>
I have a net of triangles, and I have an image representing my texture.<br>
Now I tell the GPU which point of the image shall be mapped to which point of my triangle net, and then some magic happens inside the GPU to generate a textured object.<br>
IF I move a point of a triangle, the mapped texture is distorted accordingly.<br>
Correct so far?<br>
Now I read somewhere the following "specification" regarding UV mapping on a planar surface:<br></p>

<p>A three pixel wide texture belongs to every single triangle.<br>
Per triangle the following UV mapping shall be used:<br>
triangle point A: UV(0.2, 0.5)<br>
triangle point B: UV(0.5, 0.5)<br>
triangle point C: UV(0.8, 0.5)</p>

<p>My problem is that I don't understand what the author means:<br>
I have a three pixel wide texture, values are... whatever... 2,4,6. <br>Let's define coordinate 0, 0 for the left pixel and 1, 0 for the right one.<br> Then UV(0.2,0.5) means that point A of my triangle shall have value (0.8 * 2) + (0.2 * 4) = 2.4, point B then has value 4 (it's in the middle) and point C has value (0.2 * 4) + (0.8 * 6) = 5.6. 
<br>Is it so?<br>
And all other points of the triangle are interpolated according to their coordinates based on these three corners? Or what happens to them?</p>

CC BY-SA 4.0
2019-11-21T14:50:58.137Z
all point should be recalculated
information
CC BY-SA 4.0
2019-11-21T15:58:35.243Z
`And all other points [...] are interpolated[...]?` Actually that is up to you and your application. You can set up to have a linear filtering, in which case, yes, everything would be interpolated (although I think the 2.4 and 5.6 values you calculated might be wrong). You can also set up to always read out the nearest value, in which case your point A would read only the value 2 and see, it is closest, therefore just take it. Then you wouldn't have any interpolation. E.g: Take a look at this tutorial, showing the difference: https://learnopengl.com/Getting-started/Textures
Tare
CC BY-SA 4.0
2019-11-21T16:09:18.667Z
@Tare: Thanks for the link! (I wonder why the heck all my google search on UV mapping didn't bring this up). But how would you calculate the texture values in my example?
mic
CC BY-SA 4.0
2019-11-22T14:18:37.857Z
*Let's define coordinate 0, 0 for the left pixel and 1, 0 for the right one.*
Not quite.  If you imagine a 3x1 texel texture as a rectangle, then (0.0, 0.0) is the top left corner, and (1.0 , 1.0)  is the bottom right. (Err... I might have this upside down but bear with me).   Location  (1.0/6.0, 0.5) is the centre of the leftmost texel, (0.5, 0.5), the centre of the middle texel, and (5.0/6.0, 0.5), the rightmost.  These coordinates are then important when applying (e.g) bilinear filtering
Simon F
<uv-mapping>
UV mapping on triangles
mic
# UV mapping on triangles

(Asked by: username_0 on 2019-11-21)

After watching some Youtube tutorials I thought I had understood the concept of UV mapping:  
I have a net of triangles, and I have an image representing my texture.  
Now I tell the GPU which point of the image shall be mapped to which point of my triangle net, and then some magic happens inside the GPU to generate a textured object.  
IF I move a point of a triangle, the mapped texture is distorted accordingly.  
Correct so far?  
Now I read somewhere the following "specification" regarding UV mapping on a planar surface:

A three pixel wide texture belongs to every single triangle.  
Per triangle the following UV mapping shall be used:  
triangle point A: UV(0.2, 0.5)  
triangle point B: UV(0.5, 0.5)  
triangle point C: UV(0.8, 0.5)

My problem is that I don't understand what the author means:  
I have a three pixel wide texture, values are... whatever... 2,4,6.   
Let's define coordinate 0, 0 for the left pixel and 1, 0 for the right one.  
 Then UV(0.2,0.5) means that point A of my triangle shall have value (0.8 \* 2) + (0.2 \* 4) = 2.4, point B then has value 4 (it's in the middle) and point C has value (0.2 \* 4) + (0.8 \* 6) = 5.6.
  
Is it so?  
And all other points of the triangle are interpolated according to their coordinates based on these three corners? Or what happens to them?

**Tags:** uv-mapping

> **Comments:**
> **username_1**: all point should be recalculated  
> **username_2**: `And all other points [...] are interpolated[...]?` Actually that is up to you and your application. You can set up to have a linear filtering, in which case, yes, everything would be interpolated (although I think the 2.4 and 5.6 values you calculated might be wrong). You can also set up to always read out the nearest value, in which case your point A would read only the value 2 and see, it is closest, therefore just take it. Then you wouldn't have any interpolation. E.g: Take a look at this tutorial, showing the difference: https://learnopengl.com/Getting-started/Textures  
> **username_0**: @username_2: Thanks for the link! (I wonder why the heck all my google search on UV mapping didn't bring this up). But how would you calculate the texture values in my example?  
> **username_3**: *Let's define coordinate 0, 0 for the left pixel and 1, 0 for the right one.* Not quite.  If you imagine a 3x1 texel texture as a rectangle, then (0.0, 0.0) is the top left corner, and (1.0 , 1.0)  is the bottom right. (Err... I might have this upside down but bear with me).   Location  (1.0/6.0, 0.5) is the centre of the leftmost texel, (0.5, 0.5), the centre of the middle texel, and (5.0/6.0, 0.5), the rightmost.  These coordinates are then important when applying (e.g) bilinear filtering  

---

## 0 answers

