borders around lightmaps

I have terrain divided to patches of size 33x33.
I calc lightmap coordinates for every vertex:


for (i=0;i<vx;i++)
for (j=0;j<vz;j++)
lightcoords[i+j*vx].u=(float)i/vx; lightcoords[i+j*vx].v=(float)j/vz;

every lightmap is texture with size 32x32

So I draw 32x32 texture on 33x33 vertex array. I use multitexturing.

I think lightmaps are generated correctly, becouse they look OK on hills. However, there is a problem. There is “border” on every lightmap. Two lightmaps almost fit together, but there are vertical and horizontal lines around patches.

Have you ever had something like this? I have seen someone asked this question 2 years ago on Usenet, but he haven’t solved his problem.

You problem is related to texture filtering, because the renderer can’t filter outside of the edges of the texture. Look into texture borders, which would be one solution. The other solution is, to average out the borders of your lightmaps with their neighbours, to make sure the filtering result of the left edge of one map is the same as the result of the right edge of its left neighbour. The latter solution is fairly easy to implement, looks good if you do it right and doesn’t require texture borders which might hit a software path on some hardware.

Problem has been fixed! I changed GL_REPEAT to GL_CLAMP.