Archived

This topic is now archived and is closed to further replies.

ARB_TEXTURE_CUBE_MAP

This topic is 5154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a simple question about this extension. In the spec file, it says that I have to use the texture matrix to rotate the texgen created reflection if you are using static cube maps. Does this men I have to do it everytime I change the camera''s position? If not, what does it pertain to?

Share this post


Link to post
Share on other sites
quote:
Original post by tHiSiSbOb
Does this men I have to do it everytime I change the camera''s position?

Do "it" everytime ? Please what do you mean by "it" ?

Share this post


Link to post
Share on other sites
I think it's best explained with a diagram:

Looking at front face of cube:
________
|........|
|........|
|........|
|........|
|_______|

....|
....|
....v



Looking at side of cube:

________
|........|
|........|
|........|-----------v
|........|
|_______|




In eye space, where the view vector intersects the cube is the same co-ordinate: Therefore the cubemap will return the same value for both diagrams. You take account of this in the texture matrix.
If you don't you'll always be looking at the +z face of the cube map.


[edited by - MessageBox on November 7, 2003 3:20:45 PM]

Share this post


Link to post
Share on other sites
I came up with what I thought was a decent way to do it a while back. I could never get anyone to tell me if it was 100% mathematically sound, but it sure looked right .

Set up the camera, get the ModelView matrix, reset everything except the upper left 3x3 submatrix (the rotation info), and take the inverse (which, conveniently for a rotation matrix, is the transpose). Use this as the matrix when you manipulate the texture matrix stack.

Nutty''s opengl site has dynamic cube map demo. His implementation was pretty much the same as mine, only I was using a camera class that could set the view matrix, hence why I wanted to explicitly use matrix multiplication.

Share this post


Link to post
Share on other sites

Matrix m, t;
glGetFloatv(GL_MODELVIEW_MATRIX, (float*)&m);
t = m.GetTranspose();

glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadMatrixf((float*)&t);
glMatrixMode(GL_MODELVIEW)


Just get the modelview matrix, get the transpose of it, load it into the the texture matrix and then switch back to the modelview matrix. Don''t forget to reset the texture matrix when you''re done with it.

Share this post


Link to post
Share on other sites