Results 1 to 3 of 3

Thread: Everything is fog , when i enable fog

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    19

    Everything is fog , when i enable fog

    just like the thread`s name says, i don`t understand why , but after i enable fog , my scene isn`t visible anymore , the only thing i see is dense grey fog ...

    i use fog in my recently started opengl app , so far i`ve got some models , which i made in 3ds max , and i imported, using the GLM library into my opengl app. my models are a terrain , a skydome and a castle , which are also textured.

    i`ve managed to rotate , scale and translate the objects so that every one is at they`re correct place in the scene .

    i also can move "the camera" through the scene with W A S D keys and look around with the mouse.

    i also defined a simple directional light.

    my light code:

    GLfloat ambientLight[]={0.1, 0.1,0.1,1.0};
    GLfloat diffuseLight[]={0.8,0.8,0.8,1.0};
    GLfloat specularLight[]={0.2,0.2,0.2,1.0};
    GLfloat lightPos[]={1.0 , 1.0 , 1.0 , 0.0};
    GLfloat specularReflection[]={1.0,1.0,1.0,1.0};

    glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
    glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
    glLightfv(GL_LIGHT0,GL_SPECULAR,specularLight);
    glLightfv(GL_LIGHT0,GL_POSITION,lightPos);


    glMaterialfv(GL_FRONT, GL_SPECULAR, specularReflection);
    glMateriali(GL_FRONT,GL_SHININESS,12;

    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight); glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
    glShadeModel(GL_SMOOTH);

    my fog code :

    GLfloat fogColor[4]= {0.5f, 0.5f, 0.5f, 1.0f};
    GLfloat density = 0.3;

    glEnable (GL_FOG);
    glFogi (GL_FOG_MODE, GL_EXP2);
    glFogfv (GL_FOG_COLOR, fogColor);
    glFogf (GL_FOG_DENSITY, density);
    glHint (GL_FOG_HINT, GL_NICEST);


    if anyone has an ideea , please help

    i also added pictures

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Everything is fog , when i enable fog

    First, do you see something with :
    glFogf (GL_FOG_DENSITY, 0.0f);

    If true, then you may have a problem with model scale.
    Try with very low values, such as 0.0000001 : is it any better ? Try 10x etc.

    You may have a transformation problem, remember there are different matrix stacks in OpenGL, and doing modelview transformations in GL_PROJECTION matrix (instead of the correct GL_MODELVIEW) can mess the fog.
    Search for "fog" in this page :
    http://www.opengl.org/resources/faq/...al/viewing.htm

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2010
    Posts
    19

    Re: Everything is fog , when i enable fog

    thanks a lot ZbuffeR , by reducing the density to 0.0 made fog invisible , after that i set the density to 0.005 , which made the scene and also the fog visible.

    but now the fog is through the whole scene , and i would like to make the fog vizible on the y axis only as high as the terrain , so that the skydome is perfectly visible with no fog , otherwise the fog makes the sun unrecognisible

    i tried with :
    glFogf(GL_FOG_START, 1.0f);
    glFogf(GL_FOG_END, 100.0f);

    but that would be the depth ... changed the params. but dindn`t notice any changes

    how could i do that ?


    also added pix:

Similar Threads

  1. How to enable SLI operation?
    By Tzupy in forum OpenGL: Advanced Coding
    Replies: 18
    Last Post: 01-25-2005, 11:57 AM
  2. Can't enable culling
    By Seamoon in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-10-2003, 07:14 AM
  3. How do you enable a w-buffer?
    By CGameProgrammer in forum OpenGL: Advanced Coding
    Replies: 26
    Last Post: 04-23-2002, 11:17 PM
  4. Can't enable GL_POLYGON_SMOOTH. Can you HELP?
    By Sergei in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 10-16-2000, 10:25 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