# Terrain And Fog

My terrain engine has a cull distance of 25.0, i want there to be for to cover up the culling of the terrain tiles. But i want the fog ONLY to be close to the culling distance, so that there is no fog between say 0.0 and 23.0 or something, but i cant seem to do this, as no metter that i set the start and end distance of the fog, its all the same… is it possible to mame the fog start at 23.0?? so that everything between 0.0 and 23.0 is perfectly clear??
my code atm:;

float FogColor[] = { 0.75, 0.75, 1.0 };
float FogStart = 23.0;
float FogEnd = 40.0;
float FogDensity = 0.8;

// We wil use a different fog depending on time of day.
if(day == 1){
FogColor[0] = 0.8;
FogColor[1] = 0.8;
FogColor[2] = 0.9;
}
else{
FogColor[0] = 0.3;
FogColor[1] = 0.3;
FogColor[2] = 0.35;
}

// Set the fog properties.
glFogi(GL_FOG_MODE, GL_EXP2);
glFogfv(GL_FOG_COLOR, FogColor);
glFogf(GL_FOG_DENSITY, FogDensity);
glFogf(GL_FOG_START, FogStart);
glFogf(GL_FOG_END, FogEnd);
glEnable(GL_FOG);
glHint(GL_FOG_HINT, GL_NICEST);

The results dont seem to change at all if i vary start and end distances.

Increase the fog_end distance to something like 200 or something…
That would probably help…

There are two types of fog; linear and exponential (though there are two types of exponential for also, but let’s forget about that for now).

Linear fog has a start and end distance. That means you control the fog by changing the GL_FOG_START and GL_FOG_END parameters.

Exponential fog is instead controlled by the GL_FOG_DENSITY parameter. This is becasue the way the exponential fog works. There are no “end” to the exponential fog, it just approaches full density, but mathematicall it will never reach full density.

That means, with exponential fog, GL_FOG_START and GL_FOG_END has no effect, and in linear fog GL_FOG_DENSITY has no effect.

So, unless you already figured it out, you are using exponential fog, and the start and end values have no effect on the fog in your code.

Good catch Bod, I did not see that GL_EXP thingy…

But linear fog is not particularly good for hiding the far clip plane… It is good atmospheric distortion… I tried linear fog, you can still easily see the far clip plane how it clips the polygons. Even if i set the density to 10000 or whatever…

Density has no effect on liner fog…
Only start/end values affect linear fog…

What you want is to have your fog start at 20.0 or 23.0 or somthing and end at 25.0 I think.