1
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ I am not exactly sure, what your problem is. The UV set does not make sense, but it is a legal UV set nontheless. Perhaps you should specify why you find this to not make sense. $\endgroup$ – Tare Nov 21 '19 at 14:23
  • $\begingroup$ all point should be recalculated $\endgroup$ – x-rw Nov 21 '19 at 14:50
  • $\begingroup$ @Tare: See edit $\endgroup$ – mic Nov 21 '19 at 15:50
  • 1
    $\begingroup$ 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: learnopengl.com/Getting-started/Textures $\endgroup$ – Tare Nov 21 '19 at 15:58
  • 1
    $\begingroup$ 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 $\endgroup$ – Simon F Nov 22 '19 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.