• Advertisement
Sign in to follow this  

Texture coordinate problem

This topic is 2622 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
Advertisement
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
Graphics hardware often works with half precision floating point values, so precision errors might occur even earlier.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement