Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Meaning of Texture Coordinate in obj Files

So here's the question: what do the values of texture coordinates represent? For example, in my obj file, texture coordinates look like these:

vt 0.474178 0.050139
vt 0.477308 0.050139
vt 0.480438 0.050139
vt 0.483568 0.050139

The size of my texture (bmp file) is 640*360. Does that mean (0.474178, 0.050139) in the obj file correspond to the (0.474178*640, 0.050139*360) point in the bmp file? That is, texture coordinates indicate the point position in bmp file by doing:

 u*width_of_the_bmp,  v*height_of_the_bmp

And if I'm wrong, how can I get the corresponding correlation between vt and bmp point position? Because I want to get the RGB values for every vertex, and I can get the RGB values for every pixel in the bmp file, how to link these data together to get what I want?

like image 206
lilliam.C Avatar asked Jul 14 '16 09:07

lilliam.C


Video Answer


1 Answers

That is correct.

Usually, texture coordinate 0,0 is pixel coordinate 0,0, and texture coordinate 1,1 is the opposite corner. Texture coordinates greater than 1 wrap around the texture, so if you go from 0,0 to 2,0, you go around the texture twice.

Of course, some programs might interpret them differently. There's no rule that it must be this way, but it usually is the case.

like image 99
user253751 Avatar answered Oct 03 '22 11:10

user253751