Fog won't change w/ camera

Started by
5 comments, last by bartkusa 19 years, 4 months ago
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);
	glLoadIdentity();

	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?
Advertisement
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.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
Quote:Original post by falkone
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.


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.
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
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.
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.
+-+-+-+-+-STR
Aha! Much improved.


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

This topic is closed to new replies.

Advertisement