Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Cube mapping artifacts

  1. #1
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Cube mapping artifacts

    Hello,

    I am using cube mapping in an openGL demo and when I render just a solid sphere which reflects perfectly the cube map, I see some artifacts showing the cube borders:



    The cube map is loaded from a vertical cross picture. I coded a special function that extract each side of the cube to give it to openGL. In my opinion this function works well, I don't see anything bad in it (I won't post the code here for now because it is a little complicated, but I can do it if someone wants).

    Just seeing the attached screenshot, does someone know the problem?

    thank you for your help.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Cube mapping artifacts

    Which minification/magnification filters and what wrapping mode are you using?

  3. #3
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Cube mapping artifacts

    Hello,

    This is all I do after calling, glTexImage2D for the cube map:

    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);

    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
    glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);

    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glEnable(GL_TEXTURE_GEN_R);


    glEnable(GL_TEXTURE_CUBE_MAP_ARB);
    glEnable(GL_NORMALIZE);

    I obtain the same thing with GL_LINEAR for the minification/magnification filters.

    If I change the wrap mode to GL_REPEAT, the artifact color change but is still visible.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Cube mapping artifacts

    Do your textures have a border? You can try using GL_CLAMP_TO_EDGE.


  5. #5
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Cube mapping artifacts

    Yes! Thank you it works with GL_CLAMP_TO_EDGE ! ^^
    You are very fast!

    But I don't have any borders in my cube map. I don't see why it did not work...

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Cube mapping artifacts

    There's a difference between the texture border color and an actual texture border. If no texture border is present, GL will use the texture border color which is set to black by default. Here's some more info on texture borders. GL_CLAMP_TO_EDGE makes sure you don't sample border pixels (if present) nor the texture border color.

  7. #7
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Cube mapping artifacts

    Thank you, now it is clear.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •