How to avoid crack lines on mapped cube?

Hi, I just created an enviroment texture. I mapped a 3D cubemap to a big cube. Here is what I did:

1.Loading 3D cubemap texture:


GLuint _enviroment_tex_cube = SOIL_load_OGL_single_cubemap	(
	"stormydays_large_cube.jpg",
	"NESWUD",
	SOIL_LOAD_AUTO,
	SOIL_CREATE_NEW_ID,
	SOIL_FLAG_MIPMAPS
);

2.Mapping texture to a cube:


void drawEnviroment()
{
    glEnable(GL_TEXTURE_CUBE_MAP);
    glBindTexture(GL_TEXTURE_CUBE_MAP, _enviroment_tex_cube);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    glBegin(GL_QUADS);

    //Top face
    glColor3f(1.0f, 1.0f, 1.0f);
    glNormal3f(0.0, 1.0f, 0.0f);
    glTexCoord3f(-1.0f, 1.0f, -1.0f);
    glVertex3f(-ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2, -ENVIROMENT_BOX_SIZE / 2);
    glTexCoord3f(-1.0f, 1.0f, 1.0f);
    glVertex3f(-ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2);
    glTexCoord3f(1.0f, 1.0f, 1.0f);
    glVertex3f(ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2);
    glTexCoord3f(1.0f, 1.0f, -1.0f);
    glVertex3f(ENVIROMENT_BOX_SIZE / 2, ENVIROMENT_BOX_SIZE / 2, -ENVIROMENT_BOX_SIZE / 2);



… Repeating for each side of the cube. That is 6 sides …




    glEnd();
    glDisable(GL_TEXTURE_CUBE_MAP);
}

The cube is mapping correctly. Except a little detail … the edges of the cube doesen’t look stick together. There are tiny crack-lines along the ecach cube’s edges where the two adjacent sides from the cube are supposed to meet. It looks like that:

From different viewer’s angle these crack-lines are not evident:

I remember from my teen-age gaming experience that some games have had similar problems, but I’m not sure if this problem is still common and whether in modern games it may be found?

You need to alter the texture wrap mode to


glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

That should do it.

You can improve cubemap filtering in two ways. First, where supported, you can enable seamless cubemaps, see http://www.opengl.org/registry/specs/ARB/seamless_cube_map.txt. Alternatively, you can inset texcoords for corners, by for example one half texel, absolute value will be dependent on texture resolution. Finally you can combine offset with manipulated texture images, add one texel border to cubemap faces, duplicating texels from neighbor face (could be that texel inset amount needs to be adjusted with this).

Thanx guys :slight_smile: It works.