PDA

View Full Version : volumetric fog flying around



HamsterofDeath
12-18-2003, 08:46 AM
i've read the nehe-tutorial about volumetric fog, hoping that it would be a cube, floating in 3d-space, adding fog.
it wasn't.
it's simply adding a fog-value to every vertex, depending on the distance to the viewer.
so my question, how to create volumetric coulds that just fly around in the world, remain unanswered.
can it be done via an invisible cube using volumetric fog after the whole scene has been rendered, and blending enabled ?

HamsterofDeath
12-18-2003, 09:02 AM
short question : is it possible to add a fog factor to a vertex in a vertex array, like the color pointer, normal pointer etc ?

Ostsol
12-18-2003, 09:26 AM
Check out the spec:

void glFogCoordPointer (enum type, sizei stride, void *pointer);

HamsterofDeath
12-18-2003, 01:19 PM
Originally posted by Ostsol:
Check out the spec:

void glFogCoordPointer (enum type, sizei stride, void *pointer);

stupid question : where is the spec ?

Ostsol
12-18-2003, 01:54 PM
http://www.opengl.org/documentation/specs/version1.5/glspec15.pdf

sebh
12-18-2003, 02:46 PM
real volumetric fog cannot be done with this simple technique because you cannot render fog volum that not intersect with no surface.(my opinion is that fog coord are very bad).

A great method is explained on nVidia's developer site : it use multiple rendering in texture (world , back and front face of fog volum) and by calcul on texel, you are able to render a per pixel volumetric fog who can be store in a 1D texture.(also you need fragment program).

I hope it will help you

http://developer.nvidia.com/object/FogPolygonVolumes.html

Humus
12-18-2003, 05:07 PM
There's a volumetric fogging demo on my site. http://esprit.campus.luth.se/~humus/

The database have gone down though, but it should be up again within 8 hours.

HamsterofDeath
12-18-2003, 10:27 PM
real volumetric fog cannot be done with this simple technique because you cannot render fog volum that not intersect with no surface.(my opinion is that fog coord are very bad).

thats why i wanted to use a cube of invisible textures, blending on, and then fog the invisible textures. how would this look ?

sebh
12-19-2003, 12:06 AM
Try it!!!

But i think that there will be problem if you get to close of the cube surfaces (this fog is per vertex and this is a bad thing) and particulary if you are in the cube.

So you can have a volumetric fog but problem will appear...

HamsterofDeath
12-19-2003, 12:16 PM
i think i'll put the floating volumetric fog on my todo-list and come back to it later.
first, i'll do the easy, simple non-pixel-shader-program-fragment-whatever-stuff.

JustHanging
12-19-2003, 01:06 PM
Hi,

Particles are also an option, perheps render them with half resolution and scale it up if you're running out of fill rate.

-Ilkka

HamsterofDeath
12-19-2003, 02:15 PM
wouldn't particles look like a lot of circles ?

well, i think i won't get around the advances stuff to make my fog fly free and look good...

btw there where some volumentric fog clouds in unreal, on the good old 3dfx voodoo.
how was this done ?

Tom Nuydens
12-19-2003, 03:20 PM
You can texture the particles, so they don't have to look like circles.

I'm not sure about the specifics of what Unreal did, but I believe Q3A only allowed fog volumes that were axis-aligned boxes with only one entry/exit (i.e. you couldn't walk into the fog box on one side and back out on the other). Other than that, the effect probably just involved plenty of raycasting to calculate fog densities, followed by the rendering of alpha-blended polygons. It's not as general a method as what you're looking for.

-- Tom

JustHanging
12-20-2003, 03:59 AM
Particles can look good if you do them right. Like Tom said, you can texture them to look like little clouds, and also make them big enough to overlap so they look like one big cloud. It does require a lot of fill rate to get it right, though.

I think Unreal calculated the fog in software into a low resolution texture and then projected it onto the geometry, doesn't sound like the best idea on today's hardware.

You could also try a simplified vesion of the NVidia's algorithm, render the fog on backfaces of the fog volume into alpha and subtract the frontface fog from that. Then use a fullscreen quad to apply the fog based on destination alpha. This'll work ok for as long as the fog volumes are convex.

-Ilkka

HamsterofDeath
12-20-2003, 12:29 PM
Originally posted by sebh:
Try it!!!

But i think that there will be problem if you get to close of the cube surfaces (this fog is per vertex and this is a bad thing) and particulary if you are in the cube.

So you can have a volumetric fog but problem will appear...

what about this :
i calculate the fog-factors by distance for every vertex of a cube. this cube is drawn with an 100%alpha texture, blending enabled.
(will the fog even be rendered, or is it applied with the textures alpha ? )
this will (if it works) result in a cube that will apply the more fog, the more you look in it's center. when you are inside, i just set all fog values to the maximum, and you won't see anything.
if you move towards the "exit", i'll let the fog values shrink, so you get the illusion of the fog getting less dense.