I have tried to use static environment mapping with cubemap. I load 6 textures of a skybox and i disply a cube which reflects it.
But i have a 2 problems. Look at this picture: http://texel3d.free.fr/bugs/cubmap.jpg
Or the program here: http://texel3d.free.fr/bugs/cubmap.zip (255Ko)
Has you can see:
-
The SkyBox is not reflected in the right way on the cube (the sky is in the bottom and the ground is in the top).
-
The texture coordinates are not well generated by opengl. There is a “break” in the horizon of the sky, which follow an invisible line between 2 vertices of each quads. This “break” is not static and move. This problem is not visible on a sphere.
It seems to be a problem of texture coordinates generation.
How can i solve this 2 problems?
I use this code to create my cubemap:
void abysseSDK_CreateCubeMap(void)
{
int i;glEnable(GL_TEXTURE_CUBE_MAP_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);for (i = 0; i < 6; i++)
{
AbysseSDK_CubMapTexture[i]=CreateGLTexture(cubefaces[i],skyBoxTex[i]);
}glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP);glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_NORMALIZE);}
And i display my cube with face normal.
Thanks.