actual tex coords in pixel shader

Started by
2 comments, last by 51mon 17 years ago
If texture coordinate values range from 0 to 1, how do you figure out exactly which pixel is related to which value? Is 1 the last pixel in the row/column, or is it more like a bound that is never reached? in other words if you have a texture 256 units wide, then the first pixel's x is at 0/256, the second pixel's is at 1/256, etc. right? In this way a texture coordinate of 1.0 will only be interpolated towards, in the pixel shader, right?
Advertisement
It calculates this on the video card, it knows the texture is 256 pixels wide, so a texture coordinate of 1 will equate to a pixel at 256. You can check this yourself in the shader by using constants, setting the value equal to the texture size and multiplying it, but why? All output from vertex shader is expected to be between 0 and 1 (mostly, there were issues before with non power of two textures and their coordinates if I remember). All conversion to actual sizes is done on the video card, no fuss no muss.
what I'm really getting at is, is a texture coordinate value of 1 actually represented as a pixel in the texture, or is it just a value that is interpolated toward?
If the coordinate is maped directly to a single texel depends on which filtering method you are using. You have to use point sampling to be sure to read from just one texel. The texture coordinate can take any value, what happends when the coordinate extends the [0, 1] bounds is determined by the wraping mode. I think this text would clear things up for you a bit.

This topic is closed to new replies.

Advertisement