🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

volumetric fog (FlyFire)

Started by
23 comments, last by Nick Murphy 24 years, 10 months ago
Another idea - for fog with cylindrical symmetry
u can precalculate a set of map (it will be one -
parametrical) and between the map use linear
blending; the corresponding (to From ->To vectors) map
applied to object either as second texture or as
quad + stencil (here is a stencil buffer)template.
Advertisement
You can try this...

Get the source code, take out the part that renders
the texture (it's bilinear filtered, which is slow as
hell in software). Then try turning down the
tesselation level. It's in the tessBox function -
lines 391-3 in scene.c. It's 8 right now, start at
one and go up if it runs decently.

Since i don't have VC installed, so i can't recompile
your example. i'll belive your words.

I have read your article. The only thing i can suggest
is to make some kind of terms glossary for the words
like "The actual volumetric fog computations is a _line
integral_ through 3D space, which integrates a _spatial
lighting function_"
or strips and fans.
Some of them is not clear for me (and, i think, other
people too, who just starting to go into 3d secrets and
tricks).

P.S. Doom doesn't use BSP Trees (introduction - line
13) Hope this is just mistake

Well, I'll consider making those changes myself and
posting a low-end version. I'll also consider putting
together a glossary for my web page with those terms
and any others people ask about. That's a good idea.

Doom does use BSP trees actually. Download the source
and see for yourself. Just because it's a 2d bsp
doesn't mean it's not a bsp.

look at :
r_bsp.c & r_bsp.h

Hi all,

Yesterday I was thinking about a way to do volumetric fog. And i have some ideas for it.

Most of the time people use 'fog spheres' to do volumetric fog. Because I worked with people who worked very close to the development of Unreal I know that Unreal does fogging also probably using fogspheres.

You need to create a texture (the way Unreal does)and map that on the world with a special blendmode. The texture contains the fogsphere texture and is view dependent. So you have to recalc/upload the texture every time the viewport changes. And since texture uploading on hardware is not really fast this slows down Unreal pretty much. (Unreal's bottleneck were also the enormous texture uploads)

Basicly the intensity of the fog is calculated like this:
density * (fogEnd - fogStart)
If we use a sphere with a constant radius, it is quite simple. It doesnt matter how you view the sphere but it will always result in a texture which is intense in the center and fading to the borders. Like a phongmap sometimes used in fast environment mapping.
Now you need to calculate the density. Maybe you can base that on the distance to the center of the sphere or whatever.

After you created the right texture you will also need to map it on the world. I haven't really thought about this yet. At the moment I'm just thinking about about the generation of the volumetric fogsphere texture.

Well, this were some idea's of me. I hope other people can work this idea out to a working volumetric fog model.

- John van der Burg
Programmer of Oxygen3D http://www.mysticgd.com

I get your idea about fog-spheres and i think i know how to basicly implement it. Also i found one good looking fog phere in Unreal. But how to be with ground fogging?
For example, fog over a water surface, like in the starting intro in Unreal?
Place many fog spheres? That seems to be very slow and will not looking good.

FlyFire/CodeX
http://codexorg.webjump.com

Hi !

I can simply answer your question. Spherical Volumetric Fog is done by calculating the distance between two intersection points of a sphere. These intersection points are computed by casting a ray from a vertex to the camera, when the ray hits the sphere you get two (or one if a tangent by the way) intersection points. Calculating the distance is used to calculate the fogging of the vertex.

But this is not the only way to do fogging. Basically as said before everything comes down to calculate two intersection points (where the ray enters and leaves the fog). But you can calculate the two intersectíon points with spheres, boxes, 3D Meshes and so on. Spheres are normally used because calculating intersection points is very easy and quite fast. In order to do ground fog, just use a box which starts and is some value high. That's it. Calculate the intersection points with the box and do the rest the same as with spheres.
You can also do that with 3D Meshes, but then calculating intersection points get's quite slow and complicated.

I don't know if Unreal is able to use different Volumes than spheres, but basically this is a way to do very, very nice ground fog.

I will soon post an article (give me 3 or 4 days) which will very detailed explain, how it works, the basics and how to do it in a program. There will also be Source Code and an executable. It will explain spherical fog, but you will also see a few ideas how to do it with other volumes.

When my article is up, I will post it here.

Bye now,

Phillip Schuster

Phillip Schuster
I think if we will use spheres, updating lightmaps will be quite fast. Because sphere always result on a polygon highlight in center that fades to borders, we can store initual fog density and then just calculate new one at the center and at the border, and then fade it using simple quadratic equation.
This idea is still not clear for me, but i think this might be fast.

Also, make vertex fog is easy, but how to be with lightmaps fog? (foggin every pixel). At /opengl i found some words about space tesselation, but i didn't get how to do this.

Thanx,
FlyFire
http://codexorg.webjump.com

In the little volumetric fog article I wrote a while back, I used axis aligned boxes (not neccessarily square). This makes calculating the intersection trivial. My density calculations treat the box as it if was an ellipsoid (linear or quadratic fall-off along each axis from the center).

Don't feel restricted to using only spheres for your fog volumes. You can generalize the intersection algorithm to work with ellipsoids fairly easily.

------------------
Scott Franke [druid-]
sfranke@usc.edu
druid-'s GL Journal
http://www.gamedev.net/opengl


Not that its any of my business, but why is Nick talking to himself at the top of the article, it is very confusing to decipher what he is trying to say.

This topic is closed to new replies.

Advertisement