Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Luke Hodorowicz, posted on November 08, 2000




Image Description, by Luke Hodorowicz



Here's a shot of the volumetric fog that I recently implemented in my 3D engine. It's based on arbitrary fog volumes which are set up as a BSP model. Fogmaps are then generated by casting rays from the viewpoint through the BSP tree. The parts of the ray that fall into the solid parts of the BSP tree are found, and their total distance is used with a density scalar to compute how much fog hits a point.

More screenshots and info at http://gollum.flipcode.com


[prev]
Image of the Day Gallery
www.flipcode.com

[next]

 
Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
civax

November 08, 2000, 10:47 AM

Cool fog! :) Any future features you're going to add?

 
SLUDGE

November 08, 2000, 11:05 AM

One time in an interview previous to Quake, John Carmack was talking of a fog of sorts that could be knee high, and that parts when you throw grenades in it. Such an active fog would definately add to immersion. Something to aim for.

That's a very slick scene, by the way.

 
shadd

November 08, 2000, 11:06 AM

Hey, this looks sweet !
are there any good articles/books about Volumetric Fog for modern 3d hardware ? Or, could you explain your approach a bit more ?

> Fogmaps
So you are using some kind of 'lightmaps' for every poly behind or in the fog? Or do you use the approach described on your hp, where there are only textures on the fog-volume?
You have to calculate them in realtime, right? Or is it possible to update them every few frames only (hm, could look a bit strange though)?

Thanks,
shadd

 
MK42

November 08, 2000, 11:29 AM

Looking great :)

I really like the way your engine is progressing. I downloaded a version from your site a day or two ago. Looking pretty sweet! I really liked the spinning 'holograms' you had in there. That was an idea I didn't notice in other projects before.

Anyways, keep coding cool stuff,

MK42

 
Marco Al

November 08, 2000, 11:50 AM

Ah I was wondering how you were mixing this with hardware rendering, your journal does a good job of describing your method...

Couldn't you project the vertices from the planes delimiting the fog, then generate extra vertices where projected edges from the planes intersect and then raycast all those vertices? (all the other parts of the fog map can then be generated by interpolation I think)

IMO volumetric effects should be hardware accelerated, if you have the Z-buffer content in a software engine calculating the depth in a volume can be done rather easily by rendering the planes delimiting the volume and calculating the depth in an extra buffer. You could do the same thing using stencil and alpha in hardware, but alpha just doesnt have the precision to store the depth accurately enough I think. Maybe with DX9 pixelshaders (as I understand it DX8 pixelshaders cant access the Z-buffer yet).

Marco

 
Marco Al

November 08, 2000, 12:42 PM

Missed the update in your journal where you said that entities could be inside the fog volume now.

 
The Wolf

November 08, 2000, 01:31 PM

very nice!! how much does it affect the FPS?

 
John Ketchpaw

November 08, 2000, 01:43 PM

iirc, the light falloff through constant density fog is proportional to e^x.....(x being the distance through the fog)

are you doing this, or just (as your post implies) doing it linearly?

it looks pretty effective, either way.

--
John Ketchpaw
kungfu@cmu.edu

 
Timothy Barnes

November 08, 2000, 01:50 PM

oh man. That's awesome.

 
DarkReaper

November 08, 2000, 03:40 PM

Very, Very Nice. How long did it take you to get the engine to that point? How long did just the fog take? How did you learn? Feel free to e-mail me at darkreaper@planetunreal.com

 
Shattered Soul

November 08, 2000, 06:24 PM

Looks really neat buddy. Reminds me distinctly of Quake III fog.

I wonder what the difficulties would be to shift fog when you threw an object through it? Something to ponder I guess.

 
David Frey

November 08, 2000, 07:55 PM

Hmmm! -idea- Voxel fog. Does this exist? I see it in my head at least. If Delta Force 2 (?) can use voxels for grass, what is to stop one from using them for disruptable fog?

 
Luke Hodorowicz

November 08, 2000, 08:04 PM

To answer some questions:

'Any future features you're going to add? '
In the immediate future I'm working on and plan to work on a particle system, lens flares and coronas around lights, mesh models, and curved surfaces

'I wonder what the difficulties would be to shift fog when you threw an object through it? '
I don't think I would have any problems writing a system that could render it. The problem I see is speed. In just the few seconds I've thought about it, I would partition the fog volume into small cubes. Each cube would have a fog density value in it, and i would have to cast a ray through this to find the fog colors. I could probably code it in a day or so if I had nothing else to do.

The other problem I would have is the realistic movment of the fog densities in relation to one another - hopefully you could get away with something like the famous water filter that 2d demos use.

'So you are using some kind of 'lightmaps' for every poly behind or in the fog'
Yes. Every face that is determined to be visible that lies behind the fog volume gets an additive pass with the fogmap on it. Lots and lots of ray casting.

'how much does it affect the FPS?'
Very much. It decreases the framerate by 20-30 FPS, depending on scene complexity. The biggest problem is the raycasting through the fog. The function right now is recursive and doing many many calculations, So i can probably simplify it if I make it iterative and change the math of intersection tests to something more precalculatable (i don't think thats a word)

'How long did it take you to get the engine to that point? How long did just the fog take?'

I've been working on the engine since the very end of august. The fog only took me 1 day to implement as most of the mapping functions existed because of lightmap support. All I had to do was write the raycaster and upload the new textures to 3d hardware every frame.

-Luke

 
David Frey

November 08, 2000, 08:05 PM

MMMM, just thought of another idea. How about using multiple small fog volumes to 'tile' a room's volume. And when an entity enters the room, have the fog volumes near the entity and in the direction of motion of the entity, flock away from the entity, but otherwise tend to flock back into the equilibrium position when not near an entity. Sounds like that might look good. Too bad that also sounds like a major drain on the CPU.

 
Alex Taylor

November 08, 2000, 09:15 PM

Shoot me down in flames if you will, but it seems that there is a lot of interest in getting the fog to interact with other objects. My suggestion is using a simple spring simulation just above the ground. Set up a regular grid of springs, and pull down parts where objects hit. I think it would look rather interesting. It probably wouldn't be as efficient as a BSP but it should look kinda cool. Opinions?

 
Khrob

November 08, 2000, 11:03 PM

Not meaning to be appear as though my upbringing has left me pedanticated, but I think the word is probably 'precalulable'

That said, the accuracy of my supposition may be highly questionable, as a suitable source for checkable information is not currently available, so a degree of error may be presentable.

(in other words, I dont have a dictionary handy!)


Excellent work though, especially that water/fog shot!

 
This thread contains 16 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.