Some things are much more complicated to create they then they should be. Gravel, for instance. It’s just a bunch of small rocks. How hard could that be? You start out by making a number of different rocks. Once that is done, you stare at the screen blankly trying to figure out how to fit hundreds of them together without overlap. That is where scripting and physics come into play. At the same time, there are some things that end up being way easier to create then they should be. I’m talking about rain. Thousands of raindrops falling to the ground. Using individual objects for each drop would be impossible. This is another job for……the procedural editor!
In the procedural material editor, there is a pattern module called “Cells”. This is one of my favourite modules because you can create lots of perfect circles. I used it make the stars in the space scene. The cells module has three different outputs.
The first output is the basic cell pattern. The other two use the same pattern, but they add different shadings to it. For this purpose, we are going to use the Distance 1 output. It’s basically a radial gradient at the center of each cell. The gradient comes to an abrupt stop when it touches the edge of another cell. If we open this picture in the GIMP and increase contrast, the image gets reduced to a bunch of circles.
Obviously the colours are inverted, but you can see how this would become stars. Once the contrast is maxed, altering the brightness of the image will change the size of the circles. This is great. Now we just need to replicate this effect in the procedural editor. For that, we will add a “Greater Than” module and a number. The procedural editor considers black to be zero and white to be one. The Greater Than module will allow us to limit the colour output of the cells by designating a minimum value.
The Greater Than module is causing all colours with a value greater than 0.2 to become white, while leaving everything else black. Essentially we have increased the contrast.
I’m going to use 0.1. Lets see what happens when we transplant this texture into a procedural material.
I switched the pattern output to control the transparency and gave the material a blue colour. This gives us many spheres suspended in the air.
So far so good. There are only two things we need to do: animate the rain and vertically stretch it. The cells module has an x, y, and z input, which makes it very easy to add time to the Y direction. As time increases, so does the vertical position of the drops.
I have added time to the y-coordinate of the cell pattern. This will cause all the drops to move down as time passes. If we want more speed we can multiply time by anything we want. When 1 second passes, the drops will move down by a distance of TX, where T is time and X is the multiplier.
The material is done. Vertically stretching it can be done by altering the mapping of the material to the object.
As you can see, the vertical scale is 20x greater than the other two dimensions. This will give the rain a streaking look. I have also rotated the material to simulate the effect of wind. The final result is quite remarkable. However, this being a material, it takes a long time to render. A 1000 x 750 pixel image takes about 2 minutes to render. A 5 second clip takes about 8 – 10 hours. Although, considering a single frame of a Pixar film averages a 7 hour render time, 2 minutes isn’t bad!
So that’s it. My only complaint is the long render time. For a hobbyist with a single computer I can’t really use this in an animation. If I did, my computer would be out of commission for days. I have a feeling that I will be visiting this topic again in the future. I’ve seen video game produce decent looking rain in real-time. They mostly use animated image textures on large rectangular meshes that always face the player. It’s not truly 3D, but it looks like it is.
AOI File: Rain.zip