View Full Version : How to use fog correctly in opengl application?

03-21-2006, 01:51 AM
Hi all,
I meet a problem when i use GL_FOG in opengl application. Perhaps i misunderstand the param "GL_FOG_START" and "GL_FOG_END".

here is the related code :

GLfloat fogColor[4] = {1.0f,1.0f,1.0f,1.0f};

glFogfv(GL_FOG_COLOR, fogColor);
//glFogf(GL_FOG_DENSITY, 1.0f);
glFogf(GL_FOG_START, 2000.0f); // Fog Start Depth
glFogf(GL_FOG_END, 8000.0f); // Fog End Depth

gluPerspective(30.0, 1, 500.0f, 8000.0f);

gluLookAt(0, 0, -4500, 0, 0, 0, 0,1,0);

let me explain now, In my application, there are two Sphere (radius=30) in my scene, In the World coordinate system, SphereA is at point(250, 100, 0), sphereB is at point(350, 200, -3500), Why the fog can effect sphereB? the SphereB is out of the range of the fog!

Who can tell me Why? and how to set the fog param to affect all the object in the appointed range (for example Z=1000 ~ 2000) ?
Thanks a lot!

03-21-2006, 05:59 PM
it shouldnt be affected (unless its has a large radius, say greater than 900units )
perhaps post a screenshot.