View Full Version : Localised fog

11-16-2000, 12:15 PM
How do I make a localised patch of fog in a scene, I want to have a world with fog floating over a sea. Normal glFog depends only on the distance to the object from the viewer, correct? Cheers for your help.

11-16-2000, 02:51 PM
One suggestion would be to use semi transparent textures to simulate fog?

Antonio www.fatech.com/tech (http://www.fatech.com/tech)

Glenn Upton
11-16-2000, 07:36 PM
Volumetric fog. try gamedev.org

11-17-2000, 12:34 AM
'gamedev.org' that site isn't up and running yet, do you know of any others?

11-18-2000, 06:43 AM

perhaps you have to increase or decrease the distance with each cam-modification
that means, when moving into the fog, do a

#define FOGSIZE 3
float x;


and decrease x when moving away


but i think you search something like the intro of unreal.....a qube-fog....
perhaps use a cube with a white (or grey) texture and alpha-blending (also dependent from distance cam-fog)

but i hope somebody knows how to do a REAL localized fog, like in unreal....
cause the problem is, with GL_FOG_START & END you only can change the depth of the fog....I miss something like GL_FOG_POS and GL_FOG_HEIGTH




Michael Steinberg
11-18-2000, 07:55 AM
I don't think that Unreal uses glFog at all. I think that quake uses Volumetric fog. That is, you can specify a box filled with fog. You then need to calculate the fog values for the backfaces of that cube and blend it over the scene. Might be that you'll have to use smaller quads than the actual backface. Afterwards, if you're outside the fog, you need to calculate for any vertex in the fog volume, the length of the way, the viewer ray goes through the volume and then set the vertices color value to an according color. You'll have to use GL_MODULATE texturing for that. If you're inside the fog volume, you'll only need the distance to that point.

11-20-2000, 02:59 AM
yes, but i only wanted to give some suggestions :-)
i know that such a fog-effect isn't possible with glFog.
the next problem I found in my suggestions is, if you use the distance to the FOG-start and put this into GL_FOG_START, it will look good, if you have an angle of 90 degrees to the fog (look direct into it http://www.opengl.org/discussion_boards/ubb/smile.gif ) but if your angle changes, it'll look ****y....(cause OpenGL "think" your angle is 90° http://www.opengl.org/discussion_boards/ubb/frown.gif )
but I'll try your way :-)

thanx 4 help http://www.opengl.org/discussion_boards/ubb/smile.gif


Michael Steinberg
11-20-2000, 06:15 AM
Hey, don't misunderstand me, I don't want to offense anyone. I've only been remembered to the good old board's time a year ago, when coco and the others were still there.
I'm sorry if I sound insulting, that is mostly because of my bad way of english.

11-20-2000, 03:30 PM
I know exactly what do you want.., you can do it, using the gl_extfog
email-me if you want a piece of code to do that



11-22-2000, 02:40 AM
Michael: I think we have a little bit "aneinandervorbeigeredet" http://www.opengl.org/discussion_boards/ubb/smile.gif
The problem is, that you can't express emotions via e-mail..... http://www.opengl.org/discussion_boards/ubb/smile.gif
I don't thought that you want to offense me (or someone else) http://www.opengl.org/discussion_boards/ubb/smile.gif

Bruno: yes, please give me some code!


11-22-2000, 03:37 AM
Cheers Bruno,
The code is a great help, but is there no way of doing it without using extensions?


11-22-2000, 10:35 AM
Yes , it's possible, just blend a plane from the nearest fog to the farthest, with the plane that is far way less transparent than the one that is near., but that would be slower than using the extensions!


Michael Steinberg
11-22-2000, 11:42 AM
Sorry, didn't get what you mean Bruno, could you explain it to me?

Hey mcbastian: Was geht? Wie wärs wenn wir uns n spaß machen und auf Deutsch kommunizieren? http://www.opengl.org/discussion_boards/ubb/smile.gif

11-22-2000, 12:35 PM
Well, look at this lousy draw

| - | 0.7
| --- | 0.6
| ----- | 0.5
| ------- | 0.4
| --------- | 0.3
|-----------| 0.2

X (camera)

Disable Textures, enable the fog color you want, then draw some planes where you want the fog, and as they go away from the camera, draw them smaller, and more solid (glcolor4f ) than the ones that are closer to the camera. You should also blend them to the walls, so that when you are inside the fog, you see the walls, of the color of the fog.
I think this should work.

Did you understood ?


11-22-2000, 12:36 PM
hmm.., the spaces i had in the ASCII drawing disappeared..., hope you understand it like it is http://www.opengl.org/discussion_boards/ubb/smile.gif