Ok, I had an application where i had a car driving around on a flat ground. I decided to add fog. Not knowing how to do this, i decided to visit gametutorials.com for the fog tutorial. Ok, I cut and pasted the fog code, adjusted the beginning and end depths for the fog and behold, there was fog.
Now here his my question, do I have to update the fog begin/end depths every frame? When my car moves around, my camera follows using gluLookAt. The fog seems to only stay in one position. I can drive straight through the fog and when I pass the end depth for the fog, it ends. and there is no fog.
Am I wrong to think that you should never be able to drive through the fog completely?
Shouldn’t it stay at a certain depth into the screen. In any FPS with fog, you never end up walking through the fog (unless volumetric).
If you have called glMatrixMode(GL_PROJECTION) without calling glMatrixMode(GL_MODELVIEW) again before gluLookAt the fog won’t work.
You don’n need to update your fog begin/end every frame.
It should look someting like this;
glMatrixMode(GL_PROJECTION);
//Sett upp you projetion matrix here
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, …);
and the rest of the code here.
[This message has been edited by teknicida (edited 03-20-2002).]
I’m guessing teknicida is right. If you try and do “camera-like” transforms in the projection matrix, you can mess up the fog calculations. Just using the wrong fog mode wouldn’t cause what you are seeing.