I have enabled the fog in my program with the follwoing code:
glEnable( GL_FOG );
glFogfv( GL_FOG_COLOR, fogColor );
glFogi( GL_FOG_MODE, GL_EXP2 );
glFogf( GL_FOG_DENSITY, 0.007 );
This code has no problem in my Geforce card. But in another system with ATI Radeon 7000 display driver it has some problems. I think that it’s better that i show 2 pictures to you. here’s the first picture rendered with the ATI radeon 7000 card:
And here’s another picture when i rotate the camera:
the problem is in the sky. Sometimes the fog does not cover th sky. But in my geforce card, there’s no such a problem.
Another question is about the fog and blending. I have used from the blending to draw the river in this demo. When i add the fog color to ny program, i see a bad result in the color of the river–As you see in the picture.
I can only guess here, but i assume your sky is a single large quad. When using fog you should use much smaller primitives because the fog coordinates are allowed to be computed at for the vertices only, and interpolated over the polygon. You can also try to use glHint(GL_FOG_HINT, GL_NICEST), which may the problem on some system, but higher tesselation is the safer bet.
As for the river, i assume you are using some kind of additive blending. As the fog applies to both objects being blended, you start adding the fog color twice. Try setting the fog color to black while rendering the river.
You are correct. I have used from a big quad to draw the sky. But how can i solve this problem?
Try subdividing the single large sky quad into a bunch of smaller quads (like a chess board). You’ll have to experiment a bit to find a quad size that gives a good tradeoff between fog quality and polygon count.
Given that the problem is fog calculations per vertex, you may wqant to try per pixel fog. That’s what the GL_NICEST hint already suggested will do.
This may be slow on some cards however.
Subdivision will not affect performance provided you keep it reasonably coarse. With something as big as your sky polygon some small ammount of subdivision will not affect performance but will improve appearance.
An alternative is to not fog the sky at all, draw a skydome that fades to fog color on the horizon (takes some subdivision) and you will have better control over the junction between the horizon and the sky.
The reasone i used from a big square was the game * delta Force land warrior*. Here’s an screenshot of the its sky:
In far distances, i guess that they have used from fog–As you see in the picture. But i couldn’t simulate such a fog.
I’m sure that with a sky dome i will get better results.