Jump to content
  • Advertisement
Sign in to follow this  
AzraelilMeraz

OpenGL [Texture Mapping] Relation between float and short Texture coordinate formats?

This topic is 3715 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 GameDev how do float and short texture coordinates relate to each other in OpenGL? It appears to me as if openGL tried to map the texture between 0 and 1. even with short. How do I change the range?

Share this post


Link to post
Share on other sites
Advertisement
Oh I meant something different - if i have a texture coordinate of, for example, 3, then I get a repeated or clamped texture. What I want is to use short texture coordinates and to be able to adress texels which lie somewhere in the middle of the texture. Is this even possible with short as tex coord type?

Share this post


Link to post
Share on other sites
Yes, of course. As I said, it depends on whether you told OGL to normalize your coordinates or not. In the former case, everything will be remapped into the -1 to 1 range. Otherwise, it's the raw short value, ie. -32768 to 32767.

After that, you're completely free to remap these two ranges to anything you might need, by using an appropriate texture matrix or just a simple multiply+add in the vertex shader. For example [-10..10] or [0..65535]. Just keep an eye on the precision, which will always be lower than if you took a float.

If memory is the reason to switch to shorts, you might want to look into half-floats. They take up the same space as shorts (ie. 16 bit per channel), but they have a much wider dynamic range and precision.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!