View Full Version : How can I get seamless tiles using texture mapping

04-20-2011, 04:01 PM
I have a grid of 8 X 8 points and want to overlay an image on it. I divide the inner grid of 6 X 6 into 4 equal sub-parts of size 3 X 3 each. Let us call this sub-part as tile. The idea is to render these tiles along with their corresponding textures. I divide the grid into tiles because in future I want to test it on a larger grid.
I have done it using following approach but I get seams along the edges. I can't figure out why the seams appear.

First the tiles have corresponding starting co-ords as {(0,0),(0,3),(3,0),(3,3)}.

I have an image of 8 X 8 size which I want to overlay on the super_grid and I store its rgba values in some super_data(8 X 8).

While rendering the tiles I draw them as quads and then overlay the corresponding texture on them. So, if (a,b) are starting co-ords for a particular tile, then I initialize the quad vertices ={
and if xs = 1/(tileWidth+1)=1/(3+1)=1/4 and
ys =1/(tileHeight+1)=1/4, then texture Coordinates are

So, for first tile
and its textureCoords=

Before, passing a texture for the tile I initialize the texture : image = new int[tileWidth+2][tileHeight+2] by using the super_data. We take these dimensions because some part of tile texture overlap with the adjacent tiles(that is the reason why we account for this part while calculation of quadVertices).

Finally, use
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tileWidth + 2, tileHeight + 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, image); to generate the texture.
and use :

Everything above works fine, I get a grid with image overlayed on it. However, I get seams at the edges. Please let me know how can I get rid of the seams?

04-20-2011, 09:41 PM
Have u tried using nearest filtering?

04-21-2011, 05:57 AM

04-21-2011, 08:17 AM
Yes, I have tried using nearest filtering but it only gives a blurred image with seams persisting as before.