Jump to content
  • Advertisement
Sign in to follow this  
SKonen

Texture Offsets

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

I'm in the process of expirementing with the creation of a C++ 2D engine and am having some fustrations dealing with texture offsets for sprites. Currently I'm loading a texture from an image which has four 32x32 boxes in a row (128x32). Then jumping down the road abit I set the texture coordinates for a square like this: left = (1.0f/fFullTextureWidth)*(float)m_rectTexture.left; right = (1.0f/fFullTextureWidth)*(float)m_rectTexture.right; So for example if the texture width is 128 and m_rectTexture.left is 32 and m_rectTexture.right is 64, left will be 0.5 and right will be 0.75. This all works perfectly for the sprites with a scale of x = 1, y = 1. But if I change it to say: 1.5 and 1.5, I get a vertical line of 1 pixel width from the previous 32x32 square. Stangely, if I set x scaling to 1.5, and y to 1, it'll work just fine without any "bleeding". Various scalings will work fine such as 2 and 2, but others won't. How do I fix this? Is there a way to "bind" the UV coordinates to ensure nothing outside of them is used (though I thought that was the entire point of UV coordinates). Thanks in advance. If I get a really helpful answer, I may be willing to "donate" some funds ;)

Share this post


Link to post
Share on other sites
Advertisement
The 1 pixel out thing sounds like the "Directly Mapping Texels to Pixels" problem.
Search on "Directly Mapping Texels to Pixels" in the SDK help file.

HTH,
Cambo_frog

Share this post


Link to post
Share on other sites
It might also have to do with texture filtering. Try setting the sampler states' min/mag filters to point. Only problem is then the sprites look kind of "pixelated" when scaled.. hmm..

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!