#### Archived

This topic is now archived and is closed to further replies.

# Fog troubles...

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

## Recommended Posts

I've been trying to implement fog into my first-person terrain viewer thing, and well it's not going to well... http://dwarvenale.tripod.com/screenshots.html The recent screenshot is a picture taken from the left-most part of my terrain (so there is more to the right). If you pan to the right, you will see everything that should be there, but everything is colored the fog color... the init code I use is:
glFogf(GL_FOG_MODE, GL_LINEAR
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_DENSITY, 0.8f);
glHint(GL_FOG_HINT, GL_FASTEST);
glFogf(GL_FOG_START, 100.0f);
glFogf(GL_FOG_END, -MAP_SCALE *0.2f);
glEnable(GL_FOG);

Ugh I've tried most everything... It's early but I haven't slept in two days... If I've overlooked something please let me know. And if you can, help! Thanks again, ~Dwarf [edited by - Dwarf with Axe on June 1, 2002 8:03:15 PM]

##### Share on other sites
I think your problem is that you assign GL_FOG_END a negative number (unless MAP_SCALE is also negative), i don''t think that''s legal... (i''m not completely sure)

##### Share on other sites
Even if I assign it a positive number I get the same thing...

##### Share on other sites
>>glFogf(GL_FOG_DENSITY, 0.8f);<< doesnt go with LINEAR FOG

from the screenshots i cant see any fog!
so ill have to guess, r u setting up the camera in the right position see the faq for reasons why this will effect fog

http://uk.geocities.com/sloppyturds/gotterdammerung.html

##### Share on other sites
Hard to say from the small code snippet, but:

1) This negative number seems *very* odd to me, you should definitely make it positive
2) how much is ''MAP_SCALE'' ? Are you sure that the fog end is greater than the fog start (100) ?

##### Share on other sites
Thanks for the replies so far.

I have noticed that my fog is working, and that oddity is the cutoff (I suppose b/c I gave the fog end a 5000.0f value, it stopped at z5000)

Anyway... The problem that I have, really, is that my fog is remaining in a static place. This is very odd to me, because it''s never happened before.

I have a static terrain with a CPlayer that walks around it. It seems as though the fog is set with the terrain once in the beginning then never changed... Very odd indeed.

So I''m just wondering: Do I have to assign my fog start/stop in relationship to the player x/y? If not, I can figure it out on my own.

Thanks!
~Dwarf

##### Share on other sites
You dont put the camera position in the Projectionmatrix, do you?

##### Share on other sites
You dont put the camera position in the Projectionmatrix, do you?

##### Share on other sites
LOL NOOO!! I may have stupid problems, but I myself am not stupid!

Anyway, I think I fixed it now...

I noticed that I read my map data in from a heightfield array and then multiply the values by MAP_X and MAP_Z... Previously, they were each 32, so I incremented them to 64 and voala! My fog is beautiful!

Just one question though:

If something is fogged out (i.e., you cant see it because the fog is blocking it out), is it not drawn? Because I''m not seeing any performance decrease...)

~Dwarf

##### Share on other sites
quote:

If something is fogged out (i.e., you cant see it because the fog is blocking it out), is it not drawn? Because I''m not seeing any performance decrease...)

Everything is still drawn, fog is just a colour blending effect, nothing more. If you want to clip totally fogged geometry, then you''ll have to do it manually. Eg. adjust the far clipping plane, and include the fog range into your higher level drustum clipping.

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011321
• ### Who's Online (See full list)

There are no registered users currently online

×