PDA

View Full Version : cubemap always reflects same direction.


NYGhost
2006.07.06, 04:09 PM
Hello all
I'm trying to get cubemap texture working.
I have the texture setup and it works fine, but even when I turn around the object it reflects the same area :???: .

Do I have to provide a texture matrix or arientation vector?

OneSadCookie
2006.07.06, 05:28 PM
You'll usually use a cube map with OpenGL's texture coordinate generation facilities...

akb825
2006.07.06, 06:02 PM
In order to have it reflect differently, such as when you rotate around the object, you will need to dynamically create the 6 sides of the cube map.

OneSadCookie
2006.07.06, 06:29 PM
Um, you should only have to dynamically generate the cube map if the surroundings are changing, not if the object is rotating on the spot, or the viewpoint is changing...

NYGhost
2006.07.06, 06:43 PM
well for now I just have a static one, but I though that if the map represented a room and ther was a sphere in the center of the room that sphere would reflect whatever is on the back of the viewer position.

this is what I'm doing


glDisable (GL_TEXTURE_2D);
glEnable (GL_TEXTURE_CUBE_MAP_ARB);
glBindTexture (GL_TEXTURE_CUBE_MAP_ARB, textureID );
glEnable (GL_TEXTURE_GEN_S);
glEnable (GL_TEXTURE_GEN_T);
glEnable (GL_TEXTURE_GEN_R);
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);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glLoadIdentity();

akb825
2006.07.06, 07:20 PM
Um, you should only have to dynamically generate the cube map if the surroundings are changing, not if the object is rotating on the spot, or the viewpoint is changing...
Is it dependent on the modelview matrix that is present when you enable it? Otherwise, despite its orientation, the reflected cubemap would look the same regardless of the orientation of the object. (no matter where you put it, it would look like the object rotated but the environment it's reflecting didn't)

NYGhost
2006.07.06, 09:56 PM
I think I've found the solution, this sort of worked out well.
I may need to play more with the matrix orientation.
thanks for the help :)


glActiveTextureARB(GL_TEXTURE0_ARB);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisable (GL_TEXTURE_2D);
glEnable (GL_TEXTURE_CUBE_MAP_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glBindTexture (GL_TEXTURE_CUBE_MAP_ARB, textureID);
glEnable (GL_TEXTURE_GEN_S);
glEnable (GL_TEXTURE_GEN_T);
glEnable (GL_TEXTURE_GEN_R);
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);

glLoadIdentity();
Matrix *t;
MatrixCopy( cameraRef->GetTransformRef(), &t);
MatrixSetTranslation3f(&t, 0,0,0);
glMultMatrixf(&t);
RenderSphere();


http://shamrock.med.nyu.edu/~garcij01/pic1.png
http://shamrock.med.nyu.edu/~garcij01/pic2.png