PDA

View Full Version : glFogCoordfEXT problem



Poons
06-02-2003, 02:02 PM
hello,

i am trying to use this fog extension, but it don?t works right ... i think.

i have tried to render a cube (with one side open) and gave every vertex
of the cube a fog value with glFogCoordfEXT(..). when rendering the cube
only the faces are shaded. but should not be the hole cube filled with fog?

has any body some idea what i am doing wrong or did i unterstand the
extension wrong?

thanks,
poons

maybe some code is usefull:

PFNGLFOGCOORDFEXTPROC glFogCoordfEXT = NULL;
glFogCoordfEXT=(PFNGLFOGCOORDFEXTPROC)wglGetProcAd dress("glFogCoordfEXT");
....
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_LINEAR);
glFogfv(GL_FOG_COLOR, fogColor);
glFogf(GL_FOG_START,1.0f);
glFogf(GL_FOG_END,0.0f);
glFogi(GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDIN ATE_EXT);
....
glDisable(GL_TEXTURE_2D);
glColor4f(1.0f,1.0f,1.0f,1.0f);
glEnable(GL_BLEND);
glBegin(GL_QUADS);
glFogCoordfEXT(0.0f);glVertex3f(-4000,0,-4000);
glFogCoordfEXT(0.0f);glVertex3f(-4000,0,-4000+200);
glFogCoordfEXT(0.0f);glVertex3f(-4000+200,0,-4000+200);
glFogCoordfEXT(0.0f);glVertex3f(-4000+200,0,-4000);
.....

jwatte
06-02-2003, 07:38 PM
OpenGL only shades the geometry you give to it. It sounds as if you expect it to do volumetric rendering. It does not.

morbac
06-02-2003, 10:11 PM
It absolutly normal !! What do you expect to have ? Your (and mine http://www.opengl.org/discussion_boards/ubb/wink.gif graphic card can only display triangles... and fog must be applied on something.
To simulate volumetric fog, you just must play with triangles and apply fog on them.

Now to have same (or similar) volumetric fog as quake3, I tried using the glFogCoordEXT() but it was not good looking because fog was static. I mean it looked well when camera was out of the fog volume, but it was looking wrong when camera was going in the volume. Moreover, it was not dependent on distance to camera.
Better fog effect could be obtained by applying fog as second pass. You create a fog texture (typically a 256 grey colors gradient). Then, for each vertex you get the distance to camera and choose a texture coordinate in the fog texture, depending on that distance.

Poons
06-02-2003, 11:12 PM
ok. thanks.

that was my problem.