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.
Which minification/magnification filters and what wrapping mode are you using?
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);
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.
Do your textures have a border? You can try using GL_CLAMP_TO_EDGE.
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…
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.
Thank you, now it is clear.