Jump to content
  • Advertisement
Sign in to follow this  
djsteffey

[xna] multiple images in one texture

This topic is 3676 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 already tried the google thing and didnt find anything to help me. I basically have a tiles terrain. i want to have a different texture image for each tile (ie one square is dirt, one is grass, one is sand, etc..) if i load all three images into separate Texture2D variables then i can draw everything ok. When i try to place all these images side by side in one larger texture (for performance reasons), i have 4 images in one texture: upper left, upper right, lower left, lower right. now when i want to use the upper left image i specify texture coords of (0.0, 0.0) to (0.5, 0.5). now when i draw my terrain i get ugly white lines between all the tiles. i assume this is because the upper right and lower left images are pure white for the moment. so somehow xna is using data past the 0.5 i specify and sampling out of the white areas. i have looked into TextureAddressMode.Clamp but the documentation says it clamps from [0..1] and you cant specify to clamp to say 0.5 any suggestions ?

Share this post


Link to post
Share on other sites
Advertisement
Unless you adjust your texture coordinates, you're going to end up sampling a bit from the texels past the edges of your tile when using bilinear filtering. There's really 2 other solutions to this problem:

-Use point filtering (will make things look very blocky and PS1-ish if magnified or rotated)
-Put a 1-texel-wide buffer between your tiles that won't make things look bad. Usually a color with alpha = 0 is used.

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!