tearing (gaps between tiles) ?
Hi
Im doing a topdown rts in a tilebased world. When i pan my map, sometimes there is a one-pixel gap between rows of tiles, so the background is shown.
If i move my pan a couple of pixels, the gap disappears. These gaps show up and disappear when i move to different positions, and i see no pattern. What is this and can i solve it?
(if i make the graphics of the tiles 43x43 pixels (all calc are done with 42 pixels tile-dimentions) i never get the gaps, but instead most of the time tiles will now overlap instead as i only have the gaps sometimes)
Thanks
Erik
Do you use integer values for the coordinates of the tiles, but float for the offset (pan) value?
I'm not sure which API you are using, but this should work for OpenGL.
In your texture creation code, you need to put these lines:
You probably already have these lines, but with GL_REPEAT instead of GL_CLAMP. GL_REPEAT wraps the texture around, which can sometimes cause banding because the rightmost column of pixels drawn is actually from the leftmost part of the texture. GL_CLAMP stops this.
If this doesn't work, changing your texture coordinates to something slightly different than (0,1) usually works. Say, (0.01f, 0.99f).
Good luck,
In your texture creation code, you need to put these lines:
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
You probably already have these lines, but with GL_REPEAT instead of GL_CLAMP. GL_REPEAT wraps the texture around, which can sometimes cause banding because the rightmost column of pixels drawn is actually from the leftmost part of the texture. GL_CLAMP stops this.
If this doesn't work, changing your texture coordinates to something slightly different than (0,1) usually works. Say, (0.01f, 0.99f).
Good luck,
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement