Jump to content
  • Advertisement
Sign in to follow this  
MrDoomMaster

OpenGL Fog not working properly [FIXED]

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!