A small trick not mentioned by the book
For those who don't know this already, texture coordinates are not limited to be between 0 and 1, they actually can be set to any real number between -n and +n, if you set for instance, the vertices that have a 1 value in one of their texture coordinates (usually referred to as UV coordinates) to a value of 2, you'll see that the texture gets tiled twice per axis, play around with this values, some nice tricks can be achieved by using this functionality.
This depends on how they work (can't think of the term off the top of my head). You can set this to act in different ways. Sometimes you get the pixels on the edge repeated from 1 to n (clamp). Othertimes it tiles as you have stated. Theres also a mirrored one too (where as it goes onward to 2, the texture goes back to 0, then back to 1 as it gets to 3 and so on). Of course in a pixel shader its different.
So if i had a texture with an X on it, set the coordinate to 2, it's show up with two X's?
So if i had a texture with an X on it, set the coordinate to 2, it's show up with two X's?
If you had a rectangle as the ones defined in the book sample, and put the larger values of texture coordinates to 2 in one axis you would see two X images compressed within the same rectangle, if you were to set both axis max values to 2, you would see four X within the same rectangle compressed and tiled together.
Best way to understand how texture wrapping works is to fool around with the UV values, try different things, negative values, decimal values, going from 1 to 0 instead of 0 to 1, play with it and it will become much clearer than anyone could explain with words, and in less time too.
That makes sense, I'll have to toy around with it and see what does what. Like Ohforf said, it's essentially texture wrapping.
Perhaps to better understand it you should know what the graphic API does when applying a texture in a polygon.
The values of UV coordinates in the vertices state the position in that exact point, everything in between is linearly interpolated, if we are half way between two vertices, the texture coordinates should be half way between the two values stated at each verices, if the vertices have 0 and 1 as coordinates each, half way is 0.5, if one vertex had 0 and the other had 0.75, the texture coordinate for a pixel that is half way between the two vertices would be 0.375
The values of UV coordinates in the vertices state the position in that exact point, everything in between is linearly interpolated, if we are half way between two vertices, the texture coordinates should be half way between the two values stated at each verices, if the vertices have 0 and 1 as coordinates each, half way is 0.5, if one vertex had 0 and the other had 0.75, the texture coordinate for a pixel that is half way between the two vertices would be 0.375
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement