Fog not working properly [FIXED]

Started by
2 comments, last by MrDoomMaster 18 years, 7 months ago
Hey guys. I'm trying to get some fog to appear in my OpenGL application, and although the objects are fogged, the empty space doesn't contain fog. Below is a screenshot of the results: http://img.photobucket.com/albums/v356/MrDoomMaster/SS017.jpg And the code:

        // Initialize Fog
        float fogcolor[] = {.5, .5, .5, 1.0};

        glEnable(GL_FOG);
        glFogi(GL_FOG_MODE, GL_EXP);
        glFogfv(GL_FOG_COLOR, fogcolor);
        glFogf(GL_FOG_DENSITY, 0.05f);
        glHint(GL_FOG_HINT, GL_NICEST);
        glFogf(GL_FOG_START, 1.0f);
        glFogf(GL_FOG_END, 100.0f);

[Edited by - MrDoomMaster on September 15, 2005 12:06:52 PM]
Advertisement
try set the fog color to the glClear color or the fog color to the glClear color,
like black in this case.

and you also maybe wanna look into Volumetric Fog.
fog works on the depth values (as the ap saiz set the clear color to the fog colr)
btw
glFogf(GL_FOG_START, 1.0f);
glFogf(GL_FOG_END, 100.0f);
is used for linear fog not exp
if I set both the fog and clear color to (0.5,0.5,0.5), the clear color is always a darker gray than the fog color. The colors don't match at all :(

I don't think setting the clear color works very well. I thought the fog was supposed to fill in the empty space with fog?

Any help is appreciated. Thanks.

::EDIT::

Oops! My calculations were off when setting the colors. This does, in fact, work as it should! Thank you everyone! Problem fixed!

[Edited by - MrDoomMaster on September 15, 2005 12:50:34 PM]

This topic is closed to new replies.

Advertisement