Jump to content

  • Log In with Google      Sign In   
  • Create Account


A small trick not mentioned by the book


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 26 January 2011 - 10:08 AM

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.
Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



Sponsor:

#2 Nanoha   Members   -  Reputation: 296

Like
0Likes
Like

Posted 26 January 2011 - 10:24 AM

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.

#3 Ohforf sake   Members   -  Reputation: 1788

Like
0Likes
Like

Posted 26 January 2011 - 10:28 AM

can't think of the term off the top of my head.

Texture wrapping

#4 Kyle Brechin   Members   -  Reputation: 128

Like
0Likes
Like

Posted 27 January 2011 - 12:48 PM

So if i had a texture with an X on it, set the coordinate to 2, it's show up with two X's?

#5 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 27 January 2011 - 01:14 PM

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.


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272



#6 Kyle Brechin   Members   -  Reputation: 128

Like
0Likes
Like

Posted 27 January 2011 - 01:20 PM

That makes sense, I'll have to toy around with it and see what does what. Like Ohforf said, it's essentially texture wrapping.

#7 NEXUSKill   Members   -  Reputation: 456

Like
0Likes
Like

Posted 27 January 2011 - 01:30 PM

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


Game making is godlike

LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS