Avoiding join lines in repeated textures (GLSL)

I am building a dynamic sky box for my game and I am adding clouds now. The idea is to use a repeating tiled texture for (several layers of) clouds and then move these by moving the texture coordinates, or alter the cloud thickness by passing in a parameter to the shader.

My clouds are drawing OK, but I get lines where each tile joins. I’ve heard of the problem before but I haven’t found the right googling combination for an answer. Also I am using some arcane stuff to tile the image (it seems modulus on float is not supported on GLSL 100? - anyway, that is the error I get, so I do some wierd casting to int).

Here is my tiling code:

vec4 cloudColor; vec4 cloudColor1; float cloudTransparency; if (dir.y < -0.03) { float xTextCoord = (int(1024 * dir.x / dir.y / 4.0) % 1024) / 1024.0; float zTextCoord = (int(1024 * dir.z / dir.y / 4.0) % 1024) / 1024.0; cloudColor = texture2D(m_CloudMap, vec2(xTextCoord, zTextCoord)); cloudColor1 = vec4(cloudColor.r, cloudColor.g, cloudColor.b, 1.0); cloudTransparency = cloudColor.a; } else { cloudColor = m_SkyColor; cloudTransparency = 0.0; }

Here is what it looks like:


http://farm9.staticflickr.com/8533/8750595984_9ed18ac198.jpg

Game2 by agnes_clarke, on Flickr