View Full Version : fog and matrix : please, help me !
Y try to do fog effect with standard method. Y use the PROJECTION matrix to move the camera in the world space, because it permit to move the point of view without lights. My problem is that the fog is applyed at the center of the world, and not take care of my camera position trough the PROJECTION matrix transforms... How can y do ?
11-13-2000, 04:17 AM
The camera position translation needs to be in the modelview matrix, not the projection matrix. The projection matrix should generally only have either an Ortho or a Frustum transform.
Fog is computed in eye coordinates, so if you don't translate by the negative camera position in modelview you'll get fog centered at the center of the world, as you are observing.
ut what about my light position ? If y do my camera moving with the model view matrix, my light are fixed in the camera space, no ? So, i have to move and rotate the lights with a top stack camera matrix before rendering ? And what about texGen ?
How do you done this ?
Gaby / Z-OXYDE France
If you use gluLookAt (or any other transform command used for setting up the viewpoint), you just need to declare the light position (glLightfv(GL_LIGHTx,GL_POSITION,Position)) BEFORE these commands i.e.:
// Optional : gluPickMatrix(...) (Matt, you forgot this one ! That's not only gluPerspective or glOrtho !).
gluPerspective or glFrustrum or glOrtho...
If the coordinate system you want to use is not the same than OpenGL (i.e. my worlds all have Z as the altitude while OpenGL has got Y as the altitude), you might have a glRotate just after the glLoadIdentity (the one for the modelview matrix !!!).
Hope this helps !
P.S. : arrete d'utiliser des abreviations phonetiques ; c'etait marrant sur minitel mais sur internet ca rend la lecture des posts difficile ! (for non-french speakers, that was just a remark...).
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.