Jump to content
  • Advertisement
Sign in to follow this  
RexHunter99

OpenGL Fog not working as it should?

This topic is 3530 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

I've been trying to use fog to make the maximum view radius fade away into the background color... now my first problem is that the fog color isn't the same as the background color ( even though I use the same values) and that it's starting at the point I indicate, nor ending where I want. CODE: float fr = float(RSC.bg_1rgb[0]/255.0f); float fg = float(RSC.bg_1rgb[1]/255.0f); float fb = float(RSC.bg_1rgb[2]/255.0f); glClearColor(fr,fg,fb,1.0f); fogColor[0] = fr;fogColor[1]=fg;fogColor[2]=fb;fogColor[3]=1.0f; glFogi (GL_FOG_MODE, GL_EXP2); // Fog Mode glFogfv (GL_FOG_COLOR, fogColor); glFogf (GL_FOG_DENSITY, 1.0f); glHint (GL_FOG_HINT, GL_DONT_CARE); glFogf (GL_FOG_START, 0.0f); glFogf (GL_FOG_END, ViewR*RenDist); yes I enabled the Fog >.< I'm not a retard. Now here is what I get with that: Now, it seems to render a line of non-fogged geometry at the point that the center of the camera is focused on. What I want it to do is to start near the very edge of the view distance, and end at the edge, to make the geometry there fade away. What am I doing wrong? Or is OpenGL as bad as the DirectX lovers say it is?

Share this post


Link to post
Share on other sites
Advertisement
>>What am I doing wrong?<<

not reading the instructions perhaps ;)

this
glFogi (GL_FOG_MODE, GL_EXP2); // Fog Mode
+
glFogf (GL_FOG_START, 0.0f);
glFogf (GL_FOG_END, ViewR*RenDist);

dont go together

//start+end go with linear, (exp/exp == density)

Share this post


Link to post
Share on other sites
glFogf (GL_FOG_END, ViewR*RenDist); -> Which values did you try?

What is your value for GL_FOG_COORD_SRC? GL_FOG_COORD or GL_FRAGMENT_DEPTH ?

Try GL_FOG_COORD_SRC = GL_FRAGMENT_DEPTH, GL_FOG_START = 0.0f and GL_FOG_END = 1.0f;

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil
glFogf (GL_FOG_END, ViewR*RenDist); -> Which values did you try?

What is your value for GL_FOG_COORD_SRC? GL_FOG_COORD or GL_FRAGMENT_DEPTH ?

Try GL_FOG_COORD_SRC = GL_FRAGMENT_DEPTH, GL_FOG_START = 0.0f and GL_FOG_END = 1.0f;


ViewR = 24 (int)
RenDist = 10.0f (float)

... what do those do >.< stupid OpenGL tutorial doesn't make any mention of those... I haven't set them at all infact... I wonder if they need a value other than the default?

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!