Jump to content
  • Advertisement
Sign in to follow this  
BennettSteele

OpenGL OpenGL texture tileset, colors overlapping

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

So i finnaly decided it was time to use a tileset, but now when i dont use GL_NEAREST as the drawing quality, it shows a little bit of tiles i dont want to see at the edges. When i use GL_NEAREST though, it does what i want: only that tile, no other edges of tiles. how would i fix this so you cant see colors of the other part of the texture?

Share this post


Link to post
Share on other sites
Advertisement
It is a common problem when using a texture atlas(=putting many textures on a single texture). There're some ways to avoid it, but it will get harder when you try to use mipmaps.

Imagine a texture build up of 4 different tiles, then you would use the texture coords (0,0)... (0.5,0.5) to render the first tile and (0,0.5) ..(0.5,1.0) for the second tile etc. As you can see, the 0.5 coord is shared between both tiles, when using a linear interpolation, the border pixel will be a mix of two tiles.

Therefor one solution would be to adjust your texture coord by a half pixel dx = 0.5/texture_width and dy = 0.5/texture_height. Your texture coords would be like (0+dx,0+dy)...(0.5-dx,0.5-dy).

An other often used solution would be to use some border. When your tile is 256x256, make them smaller like 240x240 and use a border of 8 pixel. The border should represent the texture, i.e. a mirrored version or continue a tiled texture. Don't forget to adjust the texture coords accordingly. This will even hold up against mipmapping problems (you need to thicken the borders accordingly when encountering artifacts). Try to use some kind of 2^n tiles and borders for better mipmap handling.

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!