Jump to content
  • Advertisement
Sign in to follow this  
ZaiPpA

OpenGL Texel-centers and texture coords

This topic is 3657 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

Hi! :) Just a very basic question, i hope some kindhearted person knows the answer to... In OpenGL, which texture-coords corresponds to the exact centers of the texels in a texture map? This is important if you use linear filtering, and you want to get the exact texel-value, and not some interpolated value between the texel and its neighbors. For example, if i want to access the bottom-left texel, which texture-coord should i use to do that? - texcoord = (0,0) - texcoord = (0.5/textureWidth, 0.5/textureHeight) - texcoord = (0.5/(textureWidth-1), 0.5/(textureHeight-1)) - something else? Thanx!

Share this post


Link to post
Share on other sites
Advertisement
OpenGL questions are asked in the OpenGL forum, so moving it there at the same time.

The texel color is defined at the exact center of the texel. That means X coordinate 0 is the left edge of the left-most texel, and 1 is the right edge of the right-most texel. For a texture with N texel, 0.5/N is the center of the first texel, 1.5/N of the second, and so on. So your second option looks correct.

Share this post


Link to post
Share on other sites
Thanx!

Sorry, for posting in the wrong forum. I thought such basic questions should go in the beginners forum :)

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!