Jump to content

  • Log In with Google      Sign In   
  • Create Account

volumetric fog (FlyFire)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
24 replies to this topic

#1 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 04 September 1999 - 07:15 PM

anyone have any ideas how to implement it?
thanx

Sponsor:

#2 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:07 PM

Only idea - i have not tried it yet.
Implement it as vertex fog
F(x, y, z) - integrated by z axis fog function,
for each lighted vertex V.color = alpha*V.color +
(1-alpha)*F(x,y,z). You should render background fog
also... may be render F(x,y,z) into billboard
grid vertices ?

#3 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:07 PM

hmm, i don't know much about this, though i've looked for stuff on it in the past. i guess there
isn't a whole lot out there on the subject. all i can tell you is that i think, if implemented in
realtime, the stencil buffer is used....

-Nick


#4 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:08 PM

I'll have an article on this topic within a week or
two.

The program will use vertex based multi-pass
blending. (Only one pass for the fog, but it can be
layered on top of other passes). I believe this is
how quake3 does it. It's a good solution for decent
quality, flexibility and speed.

The article will discuss a few other ways of doing it.
particle-based
3d-textures

I hope to expand it to more advanced algorithms,

including animated procedural fog.

I'll post something here when I get it done.

Scott Franke [druid-]
sfranke@usc.edu
druid-'s GLJournal


#5 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:08 PM

i'm beginner in this kind of stuff, so i don't know
some of terms. Can you explain what is stencil buffers?
i heard about them, but didn't find any explanation
thanx

#6 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:08 PM

ok, multipass rendering only good for hardware
rendering, but i was talking about software techniques,
like volumetric fog in Unreal.

#7 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:09 PM

It's a second pass with gouroud shaded polygons.
Doubling the number of polygons, but it could be worse.

You'll notice that having fog in scene will slow down
the Unreal engine quite a bit (check the fps on the
opening shot). I'm not sure what technique they used,
but I'm trying to find out.

Nick:
I'm not familiar with any volumetric fog techniques
that use the stencil buffer. Do you have an example
of one?


#8 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:09 PM

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.

#9 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:10 PM

My article is up. Email me any comments or questions.

#10 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:10 PM

again, can you explain what stencil buffers is?
thanx

#11 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:10 PM

Hmm, looks like a good article (i didn't read it yet
due a lack of time )
But anyway, example works veeery slow on my pc (P166MMX
with S3 ViRGE 3D) - only 1-3 frames per second.

#12 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:11 PM

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.

#13 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:11 PM

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.


#14 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:12 PM

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


#15 Nick Murphy   Members   -  Reputation: 1604

Like
Likes
Like

Posted 14 July 1999 - 08:12 PM

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


#16 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 15 July 1999 - 12:51 AM

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


#17 FlyFire   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 August 1999 - 11:39 PM

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


#18 Phillip Schuster   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 August 1999 - 08:50 AM

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


#19 FlyFire   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 August 1999 - 09:37 AM

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


#20 druid-   Members   -  Reputation: 122

Like
Likes
Like

Posted 12 August 1999 - 10:05 AM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS