PDA

View Full Version : Cube mapping artifacts



dletozeun
03-02-2008, 02:07 PM
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:

http://img504.imageshack.us/img504/4893/capturevr7.th.png (http://img504.imageshack.us/my.php?image=capturevr7.png)

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.

-NiCo-
03-02-2008, 02:15 PM
Which minification/magnification filters and what wrapping mode are you using?

dletozeun
03-02-2008, 02:20 PM
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.

-NiCo-
03-02-2008, 02:23 PM
Do your textures have a border? You can try using GL_CLAMP_TO_EDGE.

dletozeun
03-02-2008, 02:28 PM
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...

-NiCo-
03-02-2008, 02:36 PM
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 (http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node64.html)'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.

dletozeun
03-02-2008, 02:53 PM
Thank you, now it is clear.