Fog problems

Hi everybody,

Fog seems to be very easy to implement in openGL but I got some visualization problems when I use it in my program. There isn’t a nice fog everywhere on the screen but only some spots on the ground and I don’t understand why.

I enable the fog in the initGL function, after enabling the lighting, the textures… I put all the fog parameters but it’s not working.

I tried the fog in another program, an easier one, with the same parameters, and I get a great fog.
I don’t know what can come the problem from.

Thanks for your answers,

Giloo

Hi, where is u’r fog node in the graph scene ???

I had this problem once and it was because the fog was the last node added in the graph…

The fog should the first rendered node.

Hope it will help

I’m going to try!!!

Thanks

Giloo

Also, fog seems to be calculated for each polygon and interpolated over it’s surface for each pixel. So if you have one huge quad for the ground, it won’t look good at all. Tesselation of any sort makes for better fog effects.

-Ray

I tried to enable the fog at the beginning of my program but I still have the same problems.
Firthermore, my ground is complex with hills and holes, so with many polygons. I also draw a sphere for the sky.

In fact, those ugly spots of fog move when I move the camera.
I hope I’m going to have some answers!

Giloo

Are you trying to do your camera movement using the GL_PROJECTION matrix? If you are you should be using the GL_MODELVIEW matrix for camera movement. Using glTranslate/glRotate/glScale is usually not wise to use with the GL_PROJECTION matrix. One reason is that it can mess up fog calculations.