PDA

View Full Version : Cube Maps flipped at origin



Artus
10-23-2002, 01:34 PM
I'm trying to use Cube Maps in one of my programs, but I have a problem.

A object before the origin shows a diffrent side of the cube map than a object behind the origin, though both face in the same direction.
That means if I rotate a sphere around the origin it shows one time the part of the cube map behind me and one time the part in front of me.

Any ideas why?

jwatte
10-23-2002, 03:33 PM
I don't think your texgen mode is correct. It should be in REFLECTION_MAP or NORMAL_MAP mode.

Note that you may have to take into account what the rotation of the camera relative to the object relative to the world is, too, for it all to work right. If this is your problem, try making the object spin around slowly and see if the environment map spins with it -- it shouldn't (as the camera isn't spinning).

Artus
10-24-2002, 12:53 PM
I'm using the following Code ro enable reflection mapping:



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_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_NORMALIZE);


When I spin the Objectaround it's own axis the reflection stays constant. But if the object has a certain distance to the origin and I spin it around the origin it reflects opposite parts of the cubemap, depending on whether it is before or behind the orign.

jwatte
10-24-2002, 01:33 PM
Which origin are you talking about? The origin is always in the camera. If you adjust the origin using the projection matrix, all kinds of bad things may happen.

Artus
10-24-2002, 09:45 PM
I'm talking about the point (0,0,0) in Worldspace not in cameraspace.
Can't the projection Matrix be used, to move the origin of the scene?

Mazy
10-25-2002, 12:11 AM
You screw up all kinds of things if you play with the projectionmatrix..
to simulate a camera that moves around the object, just put the inverse of the camera rotation into the texturematrix for the textureunit that contains the cubemap.

Artus
10-27-2002, 01:51 AM
You were right. I put the camera movement in the modelview matrix and now the problem is gone.