Environment

When one starts to deal with large amount of datas, it is essential to load only the needed mesh parts. Clipping of the terrain may lead to unpleasant edges. One way to overthrow the problem is by using fog which hides parts we don't want. This environmental effect also adds to the scene's realism. We implemented fog directly in the Cg shaders (like the gradient based one), as it may be interesting for some of these not to have that kind of effect (like Atlas 3D where it doesn't add useful informations).

Principle in making uniform colored fog is not really difficult. One just have to calculate length between observer's position and a point we would like to apply fog on, then one have to calculate a coefficient linked to that distance. This is done in the vertex program where an intensity is also chosen, then the product between the two is sent to the fragment shader.

Finaly in the fragment shader, the fog's color is defined and the final fog factor too (the original value is divided by 1000 to reduce fog's appearance distance) then this value is interpolated with terrain's color already calculated.

We can see in the screenshots below the result of adding fog to the scene.

fogavant
Rendering without fog effect
fogapres
Rendering with fog effect