With the aim of properly getting back into keeping this thing updated, I’m trying to hit the ground running…..
So, after a little (ahem) break, I’m going to do my best to bring you weekly shake tips.
My aim with these is to try to introduce you to various tools that you may not have used much before, or to a different way of using some of the common tools…. If you’re after tips on some of the more common things that you may encounter, then I’d highly recommend Aruna’s tips of the week (which cover stuff like keying, grain matching, black points and roto)
Anyway…. Today’s tip is to do with generating water drops. It’s something that I put together at work recently (but don’t worry, work people, I recreated these examples from scratch outside of work time!) Hopefully, if you’ve not used them before, this tip will give you some idea of the power that Convolve and DisplaceX give you when used together…
The final result of this will be this: (click for quicktime (2.3Mb))

Water drops stuck to a window will be doing two things to the light that’s hitting them. They will be refracting the light coming from whatever is on the other side of the window, and they will be reflecting the light from this side of the window off their surface.
The first thing we need to generate is a matte for the water droplets. For this, I used the Fractal Noise macro from FXShare. (On the page, it says it’s for Shake 2.x, Windows only. Don’t believe it - that’s a lie - it works quite happily on 4.1, and, I’m sure, anything in between)
So…. The FractalNoise macro. Make sure it’s outputting in float, and then expand and clamp it to generate your drops image. Of course, you could always use your own painted drops map - it would work just as well… Or even an animated map with dribbling drops.
In this example, I’m going to be using this as my drops map:

These are very even drops. If you look at real drops on a window (okay, so I was bored on the bus the other day, and the window had a perfect example of what I’m recreating here), you’ll see that they are bulging at the bottom, due to gravity. To recreate that, I blurred the image, moved it down a little, and then multiplied that by the original. This is what gives the softer falloff at the top.

Next come the aforementioned Convolve nodes. Convolving is the act of using a group of pixels to decide what the new pixel is going to be. Blurs are a form of convolve, as are edge detects. The Convolve node in Shake has a number of functions that it can do, and you can even add your own. We’re going to use two of the in-built ones - SobelV and SobelH. Sobel is a type of 1D edge detect. Each pixel’s new value is the value of the old pixel one to the left minus the value of the old pixel one to the right (with SobelV, that is - with SobelH, it’s bottom and top)
What I’ve done to get the next image is a reasonable blur (to get rid of any flat section in the middle of the drops), and then a SobelV and a SobelH. I’ve then copied the green channel from the SobelH, and set the blue channel to 0.

Because we’ve been working in float, there are also negative numbers in there - the red, for example, is +ve to the left of the drops, and -ve to the right of the drops. We’re going to use this to decide how far away to displace the background image from.
Next, the DisplaceX. Firstly, I created two local parameters - xStrength and yStrength. These control how far the displacement can be. Then, with the background in the first input, and the image above in the left, and setting the parameters to be:
xExpr: min(max(x + (r * strengthX), 1), width)
yExpr: min(max(y + (g * strengthY), 1), height)
The min() and max() functions are to stop black bits from appearing in the drops near the edge - if it’s trying to get a pixel from outside the image, it just gets the edge pixels. The result of this is:

It’s not quite the effect that we’re after, but, because of the blur before the Convolves, there drops don’t touch the glass with hard edges - they fall off too softly. This is easily fixed by SwitchMatte-ing with the original drops alpha, and then putting this over the background.

Almost there with the drops. The only problem is that a lot of them disappear in the areas where the background is relatively samey. The noticable point in this example being the trees. What it’s missing is some extra highlights from the light in the sky.
For this, it really depends where the drops are on the imaginary pane of glass. If they are on our side of the glass, then we’d have a strong highlight on the top, where they’re reflecting the sky, and a softer light on the underside. If they’re on the other side of the glass (which is what I’m going for here), we’re really just adding to the refractions with a bright highlight on the bottom edge, and a softer one on the top.
For this, it’s a couple of Emboss nodes, with the elevation set to 0, and the azimuth being 180 degrees different between them. Don’t forget to clamp them, otherwise we’re going to get negative values, which we don’t want here. Blur and fade one, and blur the other a little less, add them together, and SwitchMatte them with the original drops, and we have our highlights.

For the final version, I actually added these to the refractions before their respective SwitchMattes, and then just did one SwitchMatte after the addition.

And this, blurred a little to take off the sharp edges, and over the background, gives our final movie: (click for quicktime (2.3Mb))

You can download the Shake script that I did this with from here. (don’t forget to download and install that Fractal Noise macro)
Thanks to Pete Wallington for letting me use this clip for this example. It’s from a short film called “The Long Kiss Goodbye” that I did the compositing on (so you may well be seeing this clip again…)