Jump to content
  • Advertisement
Sign in to follow this  
bartkusa

Fog won't change w/ camera

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

If you intended to correct an error in the post then please contact us.

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);
	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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!