Advertisement

ARB_TEXTURE_CUBE_MAP

Started by November 06, 2003 03:25 PM
7 comments, last by tHiSiSbOb 21 years, 4 months ago
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?
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
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" ?
Advertisement
"It" means use the texture matrix to rotate the tex-gen created values for the reflection.
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
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]
k. And, do u know of n e good tuts that have a code implementation of how to do it?
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
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.
Advertisement
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.
You mean to transpose the upper-left 3x3 matrix isn''t it ? Transposing the 4x4 matrix will yield to strange results
Thanx an ass load guys.
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.

This topic is closed to new replies.

Advertisement