• Advertisement
Sign in to follow this  

Question about OpenGL Fog.

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

Hello all, I think this is one of my first posts... In any case, let me go ahead and ask my question. I am trying to teach myself OpenGL, and I have run into something when making fog. Now, here is the code.
GLfloat fogColor[4] = {1.0, 1.0, 1.0, 1.0}; // R, G, B, ?

glFogfv(GL_FOG_COLOR, fogColor);
My question is, when I am declaring the fog color, what is the fourth value there? I know that the first three are the red, green, and blue values, but what is the last one? I was thinking that it was alpha, but I wasn't exactly sure. Thank you for whoever can clarify what it is for me.

Share this post


Link to post
Share on other sites
Advertisement
I don't think anyone knows what it is, you can even use use fogColor[3] which is just RGB, I think because they are all automatically set to 0 and the fourth variable doesn't change anything whether it's set to 0 or 1.

People suggest using 1 as the fourth number, but I doubt it makes a difference.

If I'm wrong however, I'd love the hear what its real purpose is.

Share this post


Link to post
Share on other sites
Quote:
Original post by dalindeck
Hello all, I think this is one of my first posts... In any case, let me go ahead and ask my question. I am trying to teach myself OpenGL, and I have run into something when making fog. Now, here is the code.


GLfloat fogColor[4] = {1.0, 1.0, 1.0, 1.0}; // R, G, B, ?

glFogfv(GL_FOG_COLOR, fogColor);


My question is, when I am declaring the fog color, what is the fourth value there? I know that the first three are the red, green, and blue values, but what is the last one? I was thinking that it was alpha, but I wasn't exactly sure. Thank you for whoever can clarify what it is for me.



Could be, even the official doc mentioned little:

GL_FOG_COLOR
params contains four integer or
floating-point values that specify C ,
the fog color. Integer values are f
mapped linearly such that the most
positive representable value maps to
1.0, and the most negative representable
value maps to -1.0. Floating-point
values are mapped directly. After
conversion, all color components are
clamped to the range [0,1]. The initial
fog color is (0, 0, 0, 0).

Fog blends a fog color with each rasterized pixel fragment's
posttexturing color using a blending factor f. Factor f is
computed in one of three ways, depending on the fog mode.
...
Regardless of the fog mode, f is clamped to the range [0,1]
after it is computed. Then, if the GL is in RGBA color
mode, the fragment's color C is replaced by
r
C ' = fC +(1-f)C
r r f

Share this post


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

  • Advertisement