# Fog won't change w/ camera

This topic is 4993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

http://www.ews.uiuc.edu/~bartkus/damnfog.JPG The camera starts in the far corner of the map, from which the fog looks fine. I've moved across the terrain to exacerbate the effect of the bug. Basically, the fog seems to be solely a function of distance from the axis x=0. Here's what I initiate my scene with:
glClearColor(
(float)(160.0/255.0),
0.85f,
1.0f,
0.0f);

GLfloat fogColor[] = {
(float)(160.0/255.0),
0.85f,
1.0f,
1.0f};

// Camera
glMatrixMode(GL_PROJECTION);

glEnable (GL_FOG);
glFogi (GL_FOG_MODE, GL_EXP);
glFogfv (GL_FOG_COLOR, fogColor);
glFogf (GL_FOG_DENSITY, 0.00003);

gluPerspective(45.0, 4.0/3.0, 500, cam.depth );
gluLookAt(...

It doesn't seem to change, no matter where I put the fog code. Help?

##### Share on other sites
Basic glfog is simple based on the distance a given point is from the camera (more often the distance to the plane perpendicular to the direction the camera is facing). That said, I'm not quite sure what problem you are having.

##### Share on other sites
Quote:
 Original post by falkoneBasic glfog is simple based on the distance a given point is from the camera (more often the distance to the plane perpendicular to the direction the camera is facing). That said, I'm not quite sure what problem you are having.

Look at the picture. The fog is blue. The near polygons are blue. The far polygons are the proper color. This is the opposite of how it should work.

I move the camera in my program, but the coloring done by the fog is static after initialization. It's not recomputing the fog coloration between frames.

##### Share on other sites
gluPerspective(45.0, 4.0/3.0, 500, cam.depth );gluLookAt(...

I sincerely hope that you have a glMatrixMode call between those two lines.

Enigma

##### Share on other sites
This is one of the reasons why you shouldn't put the viewpoint transform in the projection matrix unless you know what you're doing. The viewpoint transform belongs to the modelview matrix.

##### Share on other sites
i may misunderstood, but i think you should use volumetric fog for your problem. or making a point and changing the GL_FOG_DENSITY with the distance of camera and this point. or you may use soe blended quads to maek a good fog effect. (i works well for terrains)
and i am not sure, maybe helps: there is a tutorial about terrains with volumetric fog @gametutorials.com
i said; i think i misunderstand you.

edit: i see you reply. i think there ise a problem with fog_end. increase it.

##### Share on other sites
Aha! Much improved.

This is what I get for shifting around spaghetti code. Thanks.

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 16
• 12
• 20
• 12
• 18
• ### Forum Statistics

• Total Topics
632160
• Total Posts
3004500

×