Advertisement

Help with fog ...

Started by May 15, 2002 04:41 AM
17 comments, last by Wolfman 22 years, 9 months ago
Can someone tell me why my fog is doing this? As you can see, its fogging properly the background, but its also doing the same thing for the foreground, leaving a strip in the middle thats not fogged. And ideas? The code im using to set up the fog is: float fl_FogColour[4] = {0.5f, 0.8f, 0.9f, 1.0f}; glClearColor(fl_FogColour[0], fl_FogColour[1], fl_FogColour[2], fl_FogColour[3]); glEnable(GL_FOG); glFogfv(GL_FOG_COLOR, fl_FogColour); glFogi(GL_FOG_MODE, GL_EXP); glFogf(GL_FOG_DENSITY, 0.005f); glFogf(GL_FOG_START, 0.0f); glFogf(GL_FOG_END, 2000.0f); Thanks in advance, -wolfman [edited by - Wolfman on May 15, 2002 5:41:52 AM]
-wolfmanThe End is only the Beginning of the End
Not 100% what you wanted to know, but GL_EXP and GL_EXP2 fog out the entire screen with that dirty kind of fog. I suggest using GL_LINEAR (which is also the nicest ) for your fog.

Also... I wouldnt recommend setting your GL_FOG_START value to 0.0f, move it back a little bit (I havent tried this, but if your near clipping distance is at 1.0f, would setting near-fogging distance at 0.0f cause problems? something to look into.)
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
Advertisement
Weird effect, looks like layer fog

Just a few notes: GL_FOG_START and GL_FOG_END don''t have any effect when you use GL_EXP or GL_EXP2, they are only used with GL_LINEAR. The fog density in exponential modi is controlled through GL_FOG_DENSITY alone.

I would not use GL_LINEAR, GL_EXP is a lot more realistic IMO, but well, it boils down to personal preference. The effect you got is somewhat interesting. It could come from the fact, that most current 3D cards compute the internal fogfactor per-vertex and not per-pixel. What 3D card do you use ? If it is an nVidia, try turning off eye radial fog distance computation, and switch to the eye-plane distance. The radial mode (that is default on nVidia cards, AFAIK) behave strangely on poorly tesselated geometry.

BTW: newest drivers installed ? Just to be sure

/ Yann
Well, ive tried linear fog with these parameters:

glEnable(GL_FOG);
glFogfv(GL_FOG_COLOR, fl_FogColour);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_DENSITY, 0.9f);
glFogf(GL_FOG_START, 400.0f);
glFogf(GL_FOG_END, 500.0f);

And this is the result it gives me:



And the above screenshot was taken on a computer at university (with a G450), whereas the first screenshot was taken on my home PC which has a GF2 Ti.

Any ideas? (Thanks for the prev comments as well - even tho they havnt sorted the prob yet!)

-wolfman


-wolfmanThe End is only the Beginning of the End
Are you using AV? With EXT_fog_coord enabled?

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
AV?

-wolfman
-wolfmanThe End is only the Beginning of the End
Advertisement
sorry ... i was thinking VA (Vertex Arrays)

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Er ..... I dont think I do.

What I currently use is a series of TRIANGLE_STRIPs. I know this isnt the best way of doing terrain, but I wanted to get something working before I moved onto the harder stuff like LOD - as I havnt that much experience in advanced techniques.

Any other ideas?

-wolfman
-wolfmanThe End is only the Beginning of the End
That is awfully wierd.

How are you setting up your projection and translations?

I''m thinking if some normalization process treats the frustum as ranging from 0 to 1, maybe you got it to range from -1 to 1 or something, so the closest points have a fog value applied too.

I''m just spitting out ideas here.
It's not what you're taught, it's what you learn.
Have to agree with Waverider there, I have never seen such a weird fog effect. It looks as if the effect was created using some kind of vertex shader.

Wolfman:
This effect happens on different 3D cards ? Can you post your code to setup the projection matrix, and your call to glDepthRange (if you have one) ? Are you using any special extensions dealing with fog, such as fogcoords, vertex programs, etc. ?

/ Yann

This topic is closed to new replies.

Advertisement