Results 1 to 4 of 4

Thread: Problem with fog

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2006
    Posts
    16

    Problem with fog

    I have a problem when i use fog. I think that the fog starts to appear too soon. I use

    glFogf (GL_FOG_START, 200000.);
    glFogf (GL_FOG_END, 500000.);

    so the fog should starts at 200000, but it seems starts at 20 (apox.). I change the value of GL_FOG_START, but there aren't changes. Anyone can help me? Thanks.

    Image

    code:

    float fog_colour[4] = {0.6f,0.58f,0.79f,0.0f};
    float fog_density = 0.03f;

    glFogf (GL_FOG_START, 200000.);
    glFogf (GL_FOG_END, 500000.);

    glFogfv(GL_FOG_COLOR, fog_colour);
    glFogf (GL_FOG_DENSITY, fog_density);
    glFogi (GL_FOG_MODE, GL_EXP2);

    glEnable(GL_FOG);

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: Problem with fog

    There may be hardware issues on your platform, often fog is derived from z, especially for per pixel stuff. This can lead to issues with the flexibility of near z and can be worse with exponential modes.

    You could try this with linear fog just as a test, but in this case YMMV depending on hardware & maybe driver release version.

    Make sure that your problem now is not caused by only having vertex based fog with vertices near the eye & way out there, without a vertex in the middle distance.

    Conversely if this is a pixel fog issue per vertex fog may work better for you if you have a reasonable vertex count

  3. #3
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: Problem with fog

    Code :
    glFogi (GL_FOG_MODE, GL_EXP2);
    Exponential fog always start at 0. GL_FOG_START and GL_FOG_END are for GL_LINEAR fog only.
    If you need exponential fog starting from different point than 0 then you will have to use shader, or create a 1-D texture with predefined fog values for different distances and map it to your scene using tex gen.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2006
    Posts
    16

    Re: Problem with fog

    If i use GL_LINEAR then the fog works well. So,
    i'll do with this mode.

    A lot of thanks!!

Similar Threads

  1. Replies: 1
    Last Post: 09-23-2016, 02:24 PM
  2. Shading problem? (pyglet-problem?, my problem?)
    By H2OBrain in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2009, 08:31 AM
  3. Replies: 4
    Last Post: 09-27-2004, 06:27 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