Animating fog using volumetric material

Been playing with the volumetric material today, which certainly has a few limitations - Especially if you’re trying to animate through it.
Along the way I found a relatively simple way of creating a 3D cloud texture in front of the camera, allowing you to animate movement inside a foggy environment.

Anyway, enough talk - the POC runs… They look like ass but you get the idea.

The first test is a more or less forward walk, to see how the fog disperses as you approach objects.

The second is a large lateral shift to see how the material responds to sideways motion and camera rotation.

Seems to work OK. I’ve not bothered tweaking all the various settings to get it to look nice, but given a bit of time I’m sure someone more talented could come up with something totally sweet.

…Getting a bit long, so thought I’d break things up a little.

The trick is to set up a separate scene and link the camera over to it. Then you can parent another obect with a volumetric material set to emit in front of the camera, and fix the density using an empty. Then when the camera moves, the child object follows but the empty remains static, and the material density is updated. This basically gives you a fog/cloud texture directly in front of the camera, and as it’s isolated on a separate scene there are none of the issues with interference from other geometry. All you need to do then is take this generated texture, and apply it to a traditional z-buffer generated fog in the compositor.

Bit long winded, so here’s the blend to look at. Easier than trying to explain further. The compositing hasn’t been thought through on this, it’s a minimal setup to see the technique works.

3D_Fog.blend (1.13 MB)

Also apologies if this has already been done by someone else. And improvements welcome…

Thanks for this Ben, I’ll take a good looke at it when I have finished, Andys Lakes tut (yes another one doing the Nature Academy).

Couple other notes:

For the object parented to the camera which is used to generate the smoke texture, it is worth noting the volume of the object will affect the render time - the larger the object the longer it will take to render a texture. However, the larger the Z dimension the better the illusion of depth in the resulting texture. So this is the usual tradeoff between time and quality… Of course there is also the option of baking the generated cloud textures to a series of image files, and using these within the compositor. This avoids having to re-render everything while working on the main scene.

Also, the Z buffer falloff (or how thick the fog looks) can be controlled simply by using an RGB curve between the Map Value node and the Mix node. I didn’t include that in the blend file’s node setup, and can’t be bothered updating it. :smiley:

I guess you couldn’t do this with a bunch of halos as they would create a hard edge at the floor, but would look similar.

Sorry, I’m not following… What sort of halos are we talking about here? Spot halos, particle halos or the halo material?

Here is a solution:
It’s a stencil blend texture and a cloud texture, so no cheating with empties and parenting (don’t get me wrong, I love this type of cheating), I think it looks quite natural.
Halos render fast, but they have big disadvantages, unfortunately my scene takes almost 5 min per frame on my machine.

how do you embed the vimeo video here?

Very nice, quite understated. How far can you push it? I ran these tests for the sole reason of trying to fake a dense fog, which is why the tests are so OTT.

Beautiful work by the way. You’ve got a good candidate for your next CGTuts tutorial there… :smiley:

As for the embedding… When you post a quick reply, look for the format icons above the text box. Next to all the bold/underline/text stuff are a couple of icons for links, images and videos - if you use these the bbcode tags are formatted for you automatically, and hey presto your video is embedded.

The page with all the BBCode tags is here.

Particle halos or material halos are just cards with a texture on them, so where they intersect with geometry they show a hard edge. Sort of like dipping a plate in water, imagine half of it submerging.

Aha. Particle halos, I understand now. Thanks for the clarification.

Thank You.
I just sent in the fog project as a tutorial to cg.tutsplus, it will be on their site soon, they couldn’t give me a date yet.

No matter, we will look forward to seeing it.

embedding a video(quote it to see the code :slight_smile: )
very nice vid :slight_smile:

So is there a way to animate the “evolution” of the clouds texture? It seems like such a huge oversight. I am trying to make rolling fog.

It would be an oversight if this was a fluid sim, but it’s not. Like a lot of things in CG it’s just another trick to get an approximate effect.

You could always try animating the texture controlling density or apply some other tricks in the volumetric material scene. I suspect you’re after something more along the lines of fluid dynamics though, in which case this method is less likely to be useful. It might be possible to set up a smoke particle system instead of a volumetric material, but that’s a whole other set of issues and compromises.

But is was available in 2.49. I could animate the evolution of the texture via the Z-mapping coordinate of the material. But in 2.5 it does not seem to work with a volume based material. I did animate the density and that got “an effect” but not really what I was looking for.

agreed with atom, an evolution control for noise based textures is a very common tool for animators. i believe it worked in 2.49 because we didn’t have 3d volumetrics, so what it was actually doing was sliding our “viewing” slice of the 3d noise texture through the 2d viewing plane. now that we have an actual 3d viewing space, the noise textures would greatly benefit from a proper 4-th dimension time control.

the best stop gap solution i can think of for now is to add two noise textures with independent animated offsets, and use some sort of blending mode to simulate an evolving form. haven’t tested that idea though.

If all you want to do is control the way the texture influences the material (i.e. make the fog clouds move independent of the camera) you can map the texture controlling the density to an empty and animate the empty. No texture Z mapping required.

@Blender007: That is more of a conceptualized answer but it really does not work. Density is just another term for brightness. So even if you could hook one of the empties location parameters to the single value of density all you could control is the brightness over time. Which could be achieved by animating the field anyway (no need for an empty in this case). What we need is a way to evolve the texture over time. Many 2D and 3D applications offer this. Blender does not, for some reason…?

Please do offer up a BLEND file, I’d love to see a solution.

No, not the density channel, the texture you’re using to control the density. You set the mapping for the texture to “object” (in this case an empty) and leave everything else as is. Then just move the empty around. Rotate it. Scale it. It’s all good. (So with respect to the original post, all you have to do to get moving fog is animate the empty in the “fog” scene.)

This is an example of a static scene using the above technique. Box stays still. Clouds move.

Blend file? Challenge accepted.