Animated Snow Trails

This tutorial shows a technique I came up with to create displaced trails in the snow. (I won't claim to be the first ever person to invent this, since most good ideas are usually not new ideas!).
If you want to see what the result looks like, then jump to the final page of this tutorial where you can download the animation at the bottom of the page.

The Problem

- I need to create trails in the snow
- The trails need to react to the characters feet and also to the cloth simulation that is running on the characters clothes.
- It needs to be repeatable and pretty much automatic so that if the model or the animation changes, I won't have to repeat a huge amount of work.
- It also needs to work on a surface that can vary in height, i.e. not a perfectly flat surface.
Doesn't sound easy huh! Well it is, and I'm going to tell you how to do it.
You'll need a copy of Digital Fusion to follow this tutorial, but all decent compositing packages have the features that I describe. To be honest I reckon you could even do it in Photoshop now that CS has scripting support. (I wouldn't like to try it using Photoshop Actions, but if you manage to get it to work, let me know!)

Setup

To do this tutorial you need a snow surface and something with which to create trails in the snow. I'm going to just use a simple Sub-D plane for the snow and a ball to make the trails. I'm using simple objects so that I can provide you with complete scene files to download as this tutorial progresses. I can assure you that this technique easily scales to work with objects with as many polygons as you like.

The snow surface is a 10m x 10m grid in the XZ plane, subdivided 10 times along each direction, and I've pressed TAB to turn it into a subdivided surface. The ball is just a tesselated sphere (sometimes called a geosphere) subdivided at level 5 with a radius of 0.75m. Both objects are centered at the origin.

You can download the objects here;

Start Lightwave Layout and load both objects. Since we want an undulating snow surface, we're going to apply some fractal noise to the grid as a displacement texture to the snow surface.

Firstly, make sure you set the subdivision order to "After Displacement" in the Object Properties->Geometry tab. Now go to the Object Properties->Deform tab and click on the "T" button next to Displacement Map. Set a procedural texture layer to the following settings:

Layer Type: Procedural Texture
Displacement Axis:Y

Procedural Type: Turbulence
Texture Value: 1.0
Frequencies: 3
Contrast: 100 %
Small Power: 1

Scale X: 5 m
Scale Y: 5 m
Scale Z: 5 m

Animate the ball moving across the snow surface, so that it intersects it in several places. Wherever the ball intersects is where the snow trails will be formed (or at least they will later when we've finished). I animated my ball over 180 frames, but you may want to do fewer to speed things up.

Initial Setup

Initial Setup

Now that we've got the geometry set up, we need to sort out how we're going to render this scene to generate the information we need.

What we want to obtain is a depth map for each frame showing how much the object has penetrated the snow surface. If it were a flat surface, this would be simple, but since our surface undulates, we're going to have to do something a little more sophisticated. For the moment however we'll ignore this, since we can solve this problem later in Digital Fusion.

So first of all, we need to set all of the objects to white and 100% luminosity. You must also set diffuse, specularity, and reflection to 0% as otherwise this will adversely affect the result.

Now modify the camera position, rotation, and zoom factor to the settings shown below. If you switch to camera view, the whole viewport should be covered exactly by the snow surface.

Camera

X = 0 m
H = 0 deg
Y = -500 m
P = -90 deg
Z = 0 m
B = 0 deg

Zoom Factor 100

If you're not using the objects that I've provided and you've used a different shaped surface, then adjust the zoom factor so that you can only just see the entire snow surface (be exact, it makes life easier later). You should also set your image size to use the same proportions as the snow surface, in this case square. I set my image to be 800 pixels x 800 pixels. This minimises image wastage on the rendered output.

We are moving the camera far away from the surface so as to minimise perspective distortion, since the camera in Lightwave doesn't provide orthographic projections.

Fog

What we want is for surfaces that are closer, to appear whiter. Basically, we want to create a depth map and we're going to use standard Lightwave fog to achieve this, since it gives us the most control.

Working out fog range

Working out fog range

We want the final image sequence to use as much color range as possible to maximise accuracy. The image above shows the ball at it's lowest position in the animation (Y =-0.494 m). The furthest distance visible from the camera will be at the highest position of the snow surface (Y = 1 m approximately).

Since the radius of the ball is 0.75m, then the lowest position of the lowest point on the ball during animation will be -0.494m - 0.75 m = -1.244 m. We also have to remember that the camera is at Y = -500 m. So the shortest distance from the camera will be 500 m - 1.244 m = 498.756 m. The furthest distance from the camera is 500 m + 1 m = 501 m.

Go to the volumetrics tab and change the fog settings to the following:

Fog Type: Linear
Min Distance: 498.756 m
Max Distance: 501 m
Min Amount: 0%
Max Amount: 100%
Fog Color: 000 000 000 (Black)

I've rounded down the Minimum Distance setting just to ensure that we don't clip the color range. This guarantees that the colors will always be darker than white in the final image sequence.

Go to the Camera Properties window and set your anti-aliasing to Extreme, and set motion blur to Dithered with Blur Length set to 100%. If you don't have much time, you might want to set the anti-aliasing to a lower setting.

In the Render Options panel, set the RGB output to save a 24 bit Targa image sequence. Press F10 to render the sequence

Result (Frame 91)

Result (Frame 91)

You can download the completed scene file including objects here.

Processing The Image Sequence

We're now going to process the rendered image sequence in Digital Fusion.

Add two Loaders (LD) to a new flow and load the rendered image sequence into both of them. For one of the loaders, set Clip Time Start and Clip Time End to 0, and set Extend First Frame to 180. This will ensure that that loader only ever outputs the first frame of the image sequence.

Add a Channel Booleans (Bol) and set the background to the main Loader, and the foreground to the single frame Loader. Change the settings of the Channel Booleans tool to:

Operation: - Subtract
To Red: - Red FG
To Green: - Green FG
To Blue: - Blue FG
To Alpha: - Do Nothing

Digital Fusion Flow

Digital Fusion Flow

You're probably asking what's going on here. Well, all we're doing is subtracting the first frame of the image sequence (which doesn't contain the ball), from each frame of the rest of the sequence. Take a look at the image below for a more visual explanation:

Image maths!

Image maths!

The cool thing about this, is that we're left with only the displacement due to the ball. What's more (and this a fairly subtle point), since we've subtracted the displacement of the surface from the entire image (including from where the ball is), the image represents the difference in height between the lowest point on the ball and the snow surface, i.e. we can apply this to our displaced snow surface and it will deform to perfectly accommodate the ball.

Since this displacement map will work on our height varying snow surface, we've already satisfied the fourth point of the problem that I originally stated on page 1 of this tutorial.

Snow Trails

So far we've managed to make an animated displacement map that will deform the surface to make a hole for the ball to fit in. This doesn't solve our problem however, since we need to make the ball leave a trail. As it happens, there's a tool in Digital Fusion called "Trails".

Add a Trails tool (Trls) to the output of the Channel Booleans tool. Leave all the settings for the tool at their default, apart from the Apply Mode which you should change to "Lighten.

Change the current frame to 0, and press Restart on the Trails tool. Drag the tool into one of the viewport windows and press play to view the result.

After applying Trails

After applying Trails

At this point, we need to make a few small adjustments.

Firstly, making sure that you have the final output shown (as in the image above), add a Color Corrector (CC) and press the Levels button. Pull in the upper right hand side control to fit to the top of the histogram. This maximises the use of the color space and will give us a smoother result.

Levels adjustment

Next add a Blur / Sharpen tool (Blur). Set the Blur Size to about 11 or 12 pixels in Gaussian mode. This will help smooth the displacement and prevent any jaggies appearing in the displaced mesh.
Finally, add a Saver (SV) to the output of the flow, and save your image sequence as 24 bit Targas. Set Process Mode to Full Frames and turn off the Save Alpha option under the Format tab, as we don't have any alpha information in the flow.

The Final flow

The Final flow

Press Render to save the image sequence

The final displacement map

The final displacement map

You can download the completed Digital Fusion flow here.

Displacing the Snow

This is the fun part where we apply the animated displacement map back on to the snow surface:

Make a copy of the original Lightwave scene that you rendered the depth map from and load it into Lightwave Layout. Apply some sort of basic surface to the ball and snow surface objects so that they appear shaded in the viewport (note: if you downloaded my scene, you may need to turn the lights back on). Then go to File->Save->Save Object Copy and save copies of the objects so that you don't lose the new surfaces (or overwrite the objects of the old scene).

Go to the Image Editor and load in the image sequence that you saved from Digital Fusion. Make sure you select "Sequence" from the Image Type drop down box under the Source tab

Open up the Geometry properties of the snow surface object and set the Display SubPatch Level to 10. Do the same for the Render SubPatch Level. Now go to the Deform properties and add a Textured Displacement plugin modifier. Double click on the plugin name entry to view the settings. In the Texture Editor that appears, set the layer to the following settings

Layer Type: Image Map

Projection: Planar
Texture Amplitude: -1
Image: (select your image sequence here)

Width Tile: Reset
Height Tile: Reset

Texture Axis: Y

Scale X: 10 m
Scale Y: 1 m
Scale Z: -10

Note that we need to set the Z component of Scale to a negative number so that the image is flipped. This is a result of the fact that we rendered the image from below, and are now projecting it from above.

Exit the Texture Editor and close all other active Lightwave panels. If you now press play, you should see the ball moving across the surface and correctly deforming the snow surface as it goes.

Snow Trails

Snow Trails

You can download an animation of this here.



There are all sorts of improvements that can be made to this method which I haven't gone into during this tutorial for the sake of simplicity and portability. For example, it would probably be a good idea to use a floating point image format for the image sequences, since this would result in much better accuracy compared to 8 bit RGB. It would also be a good idea to use a snow surface with randomised positions for it's vertices to prevent the artifacts that appear as a result of using a uniform grid.

Something else you may want to try is adding a slight bulge that moves in front of the ball as it makes each trail in the snow. This can be achieved with a separate displacement map generated by subtracting one frame of the original displacement map from the previous frame. I've implemented this with some success, and I might write a tutorial on how to do it if this tutorial should prove popular.

Enter content...

Fetching comments...

Post a comment