volumetric fog flying around

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 ?

short question : is it possible to add a fog factor to a vertex in a vertex array, like the color pointer, normal pointer etc ?

Check out the spec:

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

Originally posted by Ostsol:
[b]Check out the spec:

void glFogCoordPointer (enum type, sizei stride, void *pointer);[/b]

stupid question : where is the spec ?

http://www.opengl.org/documentation/specs/version1.5/glspec15.pdf

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

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.

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 ?

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…

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.

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

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 ?

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

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

Originally posted by sebh:
[b]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…[/b]

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.