cubemap always reflects same direction.

Member
Posts: 157
Joined: 2002.12
Post: #1
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 Huh .

Do I have to provide a texture matrix or arientation vector?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You'll usually use a cube map with OpenGL's texture coordinate generation facilities...
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
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...
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #5
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

Code:
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();
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
OneSadCookie Wrote: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)
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #7
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 Smile

Code:
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();

[Image: pic1.png]
[Image: pic2.png]
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cubemap lookup with normalmap "bumps" TomorrowPlusX 15 6,608 Jan 13, 2009 08:13 AM
Last Post: TomorrowPlusX
  Panorama -> CubeMap TomorrowPlusX 2 2,744 Jan 4, 2009 07:52 AM
Last Post: TomorrowPlusX
  Can someone point me in the right direction? Jake 6 2,784 Jul 7, 2003 02:20 PM
Last Post: Jake