Loopable Chaos - Volumes!

In my previous tutorial, I discussed a method of using combinations of 3D textures to create a sequence of 2D images which could be looped, yet still appear to be ongoing chaotic change. However, that technique won't work if what you want to create is a 3D volume, resulting in a 3D movie you want to be able to loop. For example, a fire in a fireplace, with logs and all. If you try to employ my previous technique, you end up with a dancing volume that appears to have at least 2 distinct portions to it: some sliding up and some sliding down.

In order to emulate a fire in a fireplace, the texture needs to move up and only up. Any downward motion just wouldn't look right. However this leads to a serious problem - you can move a 3D fractal texture up all you like and you're not likely going to hit a space where the pattern starts over. You'll never make a loop.

Let's start with some basics: create a new scene, place the default distant light at 0,0,0 and point it straight up. Then, open the property panel for it, select "Volumetric Lighting" (remember, you need to also enable volumetric lights in the global Render options panel), and then click "Volumetric Light Options." To save a little time, load this preset. I then changed things a bit: set the Radius and Height to 1m, and Attenutation to 40%. There, that clears out some of the grunt work. On to the real meat.

Move your camera in reasonably close and render frame 0. Looks reasonably like a flame in a fireplace. Once again, if you should render out several frames, the texture won't move at all because we haven't animated it yet. Open the Volumetric Options panel for the light again and click "Edit Texture". You'll see three layers to this texture. The Gradient layer controls color output so we're not going to play with it at all. For the two Turbulence layers, apply an envelope to the Z channel and have frame 0 at 0m, and frame 120 at 10m. For me, this results in the right speed for flickering flames in a confined fireplace. If you render out frames 1 to 120 (don't start at frame 0), you'll get yourself a nice fire movie. Only, it won't loop nicely. Once again, there's no relationship in the texture between the first and last frames.

Here's where we'll get tricky: what we need to accomplish is a method of getting the texture to repeat itself. Since only the Ripples texture intrinsically loops, and we're not using that texture, we need to fake it out. Add a null object to the scene, name it Fader, and place it at 0,0,0. Then at frame 120, place it at x=1km. Now go back to the volumetric texture panel and add a new gradient texture to the top of the list. Give it an Alpha mapping mode, an Input Parameter of "Distance to Object", the ref object of "Fader" and give it two keys: 0m all white, 100% alpha, and at 1km, all black, 100% alpha. If you render out the sequence again, you'll see the flame slowly fading away.

Now, clone the light once. On the clone, edit the volumetric texture and invert the keys on the alpha gradient. If you render out the sequence again, you'll notice it looks exactly like the first render you did. In this case, the first light is slowly fading out, while the second light is slowly fading in. The two combined result in the original 100%. But it still doesn't loop.

What we need to do is make it so the end of the animation of the second light matches the beginning of the animation of the first light. Once again, open the volumetric texture panel for the second light, and change the Z location keys of the two Turbulence layers such that they move from -10m at frame zero up to 0m at frame 120. If you render frame 0 and frame 120, you'll see they're identical. Now render out the sequence (remember, frames 1 to 120 - don't include frame 0). If you loop it, you'll get something like this.

Note that this technique is also useful for creating loopable 2D image sequences: Since we're making a volumetric texture that repeats in a series of frames, you can take any 2D slice of that texture and get a repeating sequence of images.

(I've discovered a Lightwave bug: it won't save the scene properly, and reloading it won't render stuff out correctly. It loses the reference object for the two Distance to Object gradients. Load the saved scene file in a text editor and search for "Distance to Object". The following line will be 'ItemName ""'. Insert the word Fader in the pair of double quotes - do it for both instances! The scene will now load correctly, and oddly, save correctly too.)

Comments (2) -

  • Great Work David, yeah this works fantasticly, I'd like to see this applied to emitters as well for smoke and snow etc. I have the next few days off and will play with it some. Muhahaha

Add comment