Jump to content
  • Advertisement
Sign in to follow this  
kaikai2

Texture coordinate problem

This topic is 2834 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!