Results 1 to 3 of 3

Thread: Fog

  1. #1
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Fog

    How can I create a fog? Just something easy, nothing fancy. Code is appreciated...

    Thanx
    CyBBe

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2000
    Location
    Portugal
    Posts
    237

    Re: Fog

    HI
    here it is a piece of code to enable fog
    this one should clear the screen on the color of the fog you have defined
    glClearColor(0.3f,0.3f,0.3f,1.0f);

    glFogi(GL_FOG_MODE, GL_LINEAR); //
    Instead of GL_LINEAR you can also try GL_EXP and GL_EXP2

    glFogfv(GL_FOG_COLOR, fogColor);
    the fogcolor variable should be on the same color as the one from glClearColor

    glFogf(GL_FOG_DENSITY, 0.15f);
    This one defines the density of the fog

    glHint(GL_FOG_HINT, GL_DONT_CARE);
    This one i really don't know

    glFogf(GL_FOG_START, 1.0f);
    glFogf(GL_FOG_END, 5.0f);

    Fog_start and Fog_end, is from where the fog begin and where it ends.
    glEnable(GL_FOG);

    I believe using fog, makes the render more realistic and much faster, because objects that are behind the fog are not computed
    hope this helps

    Bruno

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    102

    Re: Fog

    Thanx! Just the kind of answer I wanted.
    CyBBe

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