Sign in to follow this  

Texture coordinate problem

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,
I have a simple 2x2 texture in nearest mode. If I fetch texel at uv position (0.4999, 0.) like this:

texture2D(tex, vec2(0.4999, 0.))

it returns the texel at position ij (1,0). I was expecting the following mapping:
u in [0-0.5[ => i=0
u in [0.5-1.0] => i=1

I get this strange result on a ATI(HD5870). Not on nvidia.

Do you have an explanation?
Thank you.

Share this post


Link to post
Share on other sites
I can't say why 0.4999 get's rounded to 0.5, but I guess it's not unbelievable that it could happen.

What are you doing that you need to have such exact floating point calculation? If you want per-pixel lookup I'd use a samplerRect (direct pixel access), instead of using floating point.

Share this post


Link to post
Share on other sites

This topic is 2547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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