Sign in to follow this  
Funkymunky

actual tex coords in pixel shader

Recommended Posts

Funkymunky    1413
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?

Share this post


Link to post
Share on other sites
xycsoscyx    1149
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.

Share this post


Link to post
Share on other sites
51mon    342
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this