Results 1 to 4 of 4

Thread: How to avoid crack lines on mapped cube?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    22

    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:
    Code :
    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:
    Code :
    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 ...
    Code :
     
     
        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:
    [img:center]http://dox.bg/files/dw?a=60e6508100[/img]

    From different viewer's angle these crack-lines are not evident:
    [img:center]http://dox.bg/files/dw?a=9d24f96925[/img]

    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?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,135

    Re: How to avoid crack lines on mapped cube?

    You need to alter the texture wrap mode to

    Code :
    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.

  3. #3
    Senior Member Regular Contributor imported_tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    Cambridge, UK
    Posts
    223

    Re: How to avoid crack lines on mapped cube?

    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).

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2009
    Posts
    22

    Re: How to avoid crack lines on mapped cube?

    Thanx guys It works.

Similar Threads

  1. Replies: 3
    Last Post: 06-15-2015, 03:48 AM
  2. Need help normal mapping a cube-mapped sphere
    By NeomerArcana in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 05-31-2015, 10:49 AM
  3. Problem drawing lines correctly in cube vertices
    By The_Notorious in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-17-2015, 01:43 AM
  4. depth-mapped cube maps
    By Siliconfig in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 06-17-2004, 03:29 PM
  5. 3D Tree Trunks/Branches Using Texture-Mapped Lines
    By Heaven in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-23-2001, 08:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean