Results 1 to 7 of 7

Thread: Terrain And Fog

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    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.
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Terrain And Fog

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

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Terrain And Fog

    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.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Terrain And Fog

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

  5. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Terrain And Fog

    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...
    :: Sleep is a poor substitute for caffeine ::

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Terrain And Fog

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

  7. #7
    Guest

    Re: Terrain And 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.

Similar Threads

  1. Terrain Generation / Displaying terrain
    By _Syndic in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 05-06-2013, 04:29 AM
  2. Terrain
    By Rodrix in forum OpenGL: Advanced Coding
    Replies: 31
    Last Post: 09-14-2006, 10:25 AM
  3. Terrain Following
    By Night Hacker in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-22-2004, 06:45 AM
  4. Terrain
    By thanhnt in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 05-22-2002, 03:43 AM
  5. Terrain
    By MrShoe in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-30-2001, 04:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean