Basic Tutorial 2: Daemons (Water Drop)

preview video clip of compiled animations

RealFlow3 Final Project Files for this tutorial

Objectives

In this tutorial we’re going to create an animation that's a classic favourite of macro-photography : an elegant water drop that pulls downward under its own weight, sticking at it's top end initially and stretching in the middle, and then snaps gracefully apart into a series of smaller droplets that descend downward. We're all familiar with slow motion footage of this behaviour in nature documentaries, when rain water drips off leaves for example.

This scene lays the groundwork for more complex work with daemons in intermediate level Tutorial 3 (Daemons and Animation), where we'll play catch with a fluid drop. It also should give users fairly clear ideas of how to develop another iconic fluid scene, that of a droplet falling into a calm pool of water and producing a crown-like splash.

This scene is deceptively simple, involving few elements, but requiring understanding of important concepts that allow you to reach a particular goal. As usual, there are a number of ways to achieve the same result.

The tutorial is for beginners, but there are optional sections that reach to advanced levels -- check the next section for more on this.

Introduction

The most basic components of a typical RealFlow scene are emitters and daemons. Emitters generate fluid particles in your scenes, and their settings dictate the basic behaviour of the fluid. Daemons allow you to selectively add effects, like forces, that control and sculpt the behaviour of the fluid particles. In this tutorial, we’re going to focus on daemons. For more information on emitters, check Tutorial 1 on creating a geyser effect.

The work will focus on the use of daemons to make fluids do what you need to resolve a scene. This is an important issue because simulations in any production need to be art-directable, rather than simply a static result of physics that the director is stuck with -- and would, as a result, probably not use. The tutorial will also get us deeper into effective ways of running simulations, and the animation functions available in RF3 such as controlling behaviour with expressions.

Although aimed at beginners this tutorial touches on some more advanced topics such as physical concepts, force balances and scene scales, that intermediate users could find useful.

In addition, at the end there is an advanced section on how to to use expressions to effectively parameterize this scene, so with changes to just a few values you can achieve different effects with little trial and error. This approach improves the efficiency of achieving results and will allow you to do less tweaking.

This tutorial assumes you are familiar with the RF3 interface and basic concepts. If you are not, you may wish to first try Tutorial 1 on making a geyser, or accessing some of the other help resources that are freely available (see below). The tutorial will not touch on meshing, waves, rigid body dynamics, constraints, other types of fluids besides liquid and dumb, transferring data between RF3 and 3D applications, and rendering.

The structure is designed for quick navigation depending on your level of experience with RealFlow, and your level of learning interest:

-         For those wanting to quickly cover the basics and like to learn by doing and experimenting rather than get into details, just follow the bold steps giving simple instructions. Or, download the project files and examine them, running tests simulations and tweaking parameters.

-         If you like more detailed instructions and explanations, follow the main body of the tutorial text. Sections devoted to explaining how RealFlow works or relevant aspects of physics theory are broken out in blue italics and indicated with the subheading “Explanation”.

-         For more experienced users who feel they know how to do this kind of project, but want to gain a better understanding of aspects of RealFlow, scan the bold instructions and then check out the explanation sections. In addition, they should check out the supplemental (advanced) section at the end.

-         Finally, at the end of the tutorial are notes giving useful tips and alternative approaches.

If you want additional help during the tutorial or are looking for other tutorials afterward, there are a lot of resources available to you. Under Help>contents… you’ll find the online manual that is packed with information, and is a good place to start (if you’re a total beginner, check the Getting Started section). Second, check the Next Limit website for more, as well as example scenes that are great for learning. Third, there are a lot of very good user tutorials accessible from Next Limit’s RF3 forum, in the tutorial section. These tutorials have been checked over and rated by experts, and a good place to start is in the index of tutorials in that part of the forum. Finally, take advantage of the user community in the forum to ask questions and gain a variety of insights. While working in RF3, use the tooltip-style help when you need reminding or definitions of functions: hover the cursor over an interface element and hit F1 to get a popup giving you info on that element. If the element is a sub-panel tab, RMB-click over it for information. For more shortcuts, check go to Help>Key Shortcuts…

Before we start, let’s define some common abbreviations:

RF3 = RealFlow version 3.x

UI = user interface

LMB / MMB / RMB = left, middle and right mouse button, respectively

Ctrl = the control button on your keyboard

Alt = the alt button on your keyboard

Shift = the shift button on your keyboard

1,2,3,4,Q,W,E,R = those buttons on your keyboard (e.g., W = the W button on your keyboard)

And finally, time to get dripping !

1 – Initial setup

Start up RealFlow, create a new project called “waterdrop”. Also set up the workspace using File>Preferences…, to give the view setup you want, and add some Summary Info.

If you want your view to look like those below, select the 3-view window and otherwise keep everything at the default values. In the options tab, set the end frame to 170 and the FPS output to 60, since we want to end up with a slow-motion effect. At normal speed (30 fps) the physical effects in this scene move very quickly, just like in nature.

Finally, you may wish to add some file information by going to File>Summary Info...

We are going to create a volume of water, initialize the scene so the volume has a droplet shape to start the simulation and is stuck to a starting point, then release the water so that it sags beneath its own weight, stretches and snaps apart as it descends -- as though it were dripping off some object. This method allows us to fake an object's influence, which is usually faster to calculate than actually using an object in the scene.

2. Create and set-up the emitter

Create a square emitter, set the internal pressure to 0.1, the viscosity to 1, and the volume to 1.5. This will be the droplet, a simple volume of viscous liquid. We'll control it's descent and deformation with daemons.

Create a square emitter by going to the emitters panel, via the far left icon (3 dots) in the tab menus, or use hotkey F2, then use the pull-down menu to create a square emitter. We could use any of a variety of shapes (triangle, cylinder, sphere, circle) but use the square because it will nicely illustrate the influence of surface tension.

Emitters such as the square and circle can be set to shoot out particles at a specified speed, or to start off with a static shape of particles by setting the volume value. Using volume or speed prevents the use of the other value, so you have to choose one or the other mode. Remember that the particles are created in a zero-force configuration, so if you use a volume emitter to fill a container and apply a force like gravity, then on hitting Action the particles will squash against each other and not fill the container quite as you might predict. In this scene we want to start with a volume of fluid in a droplet shape, so use the emitter in volume mode and set the volume to 1.5. You should now see particles arranged in an orderly way in a rectangular form.

For our droplet, leave the resolution at 1 so we have 1500 particles. This is a good number for testing because it's enough to see details of the behaviour, but RF3 will still run the simulation quite rapidly.

Set the internal pressure to 0.1. This is the pressure within each particle "balloon" and by reducing it significantly you allow the particles to compress together more under a given force. It also lowers the amount of vigorous splashing/bouncing effects, which is good for this scene. However, for this scene it isn't completely necessary. If you choose to leave the internal pressure at 1, you may find your drop is bigger so you can reduce the number of particles or compensate other parameter values, such as the radius of the attractor daemon.

Set the viscosity to 1.0 -- There is no hard rule on this, it depends on the look you want as well as scene scale and the forces being applied. How you know what value to set depends to a large extent on experimental trials, experience, and also your knowledge of the physics and the scale of your scene.

Explanation: Scene scale and parameter values

The scale of your scene is a very important consideration. It is tempting to replicate exactly the scale of your scene in your 3D platform to try to get things to look right, but you'd end up with a big headache using this approach in all but the most simple of scenes.

The rule to remember is always to set your scene scale so that "things", meaning objects, quantitites of fluid, and your entire scene, are on the order of 1 m. "On the order" means not different by more than a factor of 10, in general. So, rather than work with a ship that is 100 m long, scale it down by 0.01 to be 1 m long in RF3, then scale the whole simulation up within your 3D application. Similarly, if you've got an insect model 1 mm long in your 3D applicaton, scale it up to 1 m.

The reason for this approach is that RF3 is setup to deal with scenes on this scale. Values of parameters such as viscosity are set for this range. For sizes much bigger or smaller, you will get into situations where you need wildly-sized resolutions, huge numbers of particles, huge surface tensions or other forces, etc. These sorts of extreme values may work but they may also produce imprecise calculations through roundoff errors. Also, extreme values can produce extreme values of derivative properties, so for example if you have extreme forces applied to particles you can get extreme velocities, and this can lead to instability in the calculations.

Viscosity is a good example of the effect of scale. The default value of 3.0 for liquid emitters is well higher than water. In fact in the real world water has a viscosity orders of magnitude less than 1, but when scaling upward in many cases you should also scale up viscosity by a similar amount (for the same sort of density and scene velocities). Here, we are simulating a droplet that is normally a few millimeters across, with a beachball around 1 m across, so you can work with a scaled-up viscosity to get the same sort of behaviour at both scales. If you don't do this, you will find that your simulation of a tiny droplet ends up looking more like a simulation of a dam bursting.

For now we'll leave the pursuit of the right sort of viscosity value as a kind of educated guess, or possibly the result of trial and error. Scaling can be done quite precisely in many cases so need not be guess-work, but it takes some effort to understand it well and our time now is better spent developing an intuition for RF3.

3. Add the daemons

Create gravity, attractor, drag and surface tension daemons. Move the attractor so it is inside the volume of fluid, but otherwise leave the parameter values at their defaults for now. Check that the daemons have been applied to the emitter by opening the Scene Tree.

Daemons are probably the most important part of RF3 to master, as they above all control what your particles do. Below, we'll apply some fine control to our fluid.

Switch to the daemons panel, the icon that is 3rd from the left that looks like 3 dots stuck to a cube (hotkey F4). This is where you add effects and controls to your fluids.

From the pull-down menu, select the following 4 daemons:  gravity, attractor, drag force and surface tension.

Normally you should add a ~volume daemon to keep control of how your particles are spread out in space, but in this scene that won't be needed as the particles will not be flying around too vigorously.

The gravity daemon will be used to apply downward pull, producing vertical stretching as it counters the force applied by the attractor, and for bits of fluid that escape the influence of the attractor the gravity will also cause accelerating downward descent.

Surface tension is a surface force equivalent to having an elastic skin coating particle groups. Just like in air-filled latex balloons, surface tension tries to pull clusters of particles into spherical shapes, removing sharp corners. The characteristic feature of surface tension is that the force changes locally over the fluid surface, and increases inversely with the local radius of curvature of the fluid surface. This means that sharp corners get very large surface tension forces applied locally, causing them to snap inward violently. It also means that really large, smooth bodies of fluid feel only small surface tension forces. This is why in nature the effects of surface tension are only strong for tiny droplets, and why the water filling a drinking glass doesn't gather itself into a spherical blob. Another important feature of surface tension is that it tends to narrow and pinch off elongated "arms" of fluid, and after pinching off it pulls the remaining elongation rapidly back into the main body of fluid. This causes behaviours (at small scales) that look more like snapping rubber bands than fluid -- and are exactly what we'll work toward in this scene.

The drag force daemon acts to add friction, sucking away the momentum / interia of particles and giving you control over behaviours like "overshoot". It will be used just at the start of the scene and will calm down the motions of the particles as they form a droplet shape. You could alternatively use a ~speed daemon to control the speed of particles, or higher viscosity to dampen down particle motions. The point is, applying some sort of motion dampening effect is needed whenever there are large rates of change in a scene.

In this case, and in many scenes, a very large change happens when the simulation starts because the particles go from being in a configuration where there is no force applied, to suddenly having big forces applied. This can make particles shoot away erratically at high speeds and might even make RF3 crash in extreme cases. Particles behaving erratically is a sign to apply some, or more, drag force or other form of dampening. Here, we use it just to get the scene going since once the particles are calm they stay calm and drag is no longer needed. We'll animate the drag to drop rapidly in the first few frames so it'll do its job, then be out of our way.

The attractor daemon is really the star of this tutorial. This is a handy daemon for controlling fluids, as you'll see in the next step and the next tutorial as well. Here, we'll use the attractor rather than an object, to "stick" the droplet's upper edge.

Explanation: Force, Velocity, Acceleration, Momentum and Friction

OK it's time for a small physics session.

Daemons can be used to apply forces, but many of them can also be switched to another mode where they apply velocity changes. So what's the difference?

When a daemon like an attractor is used on a fluid, for each particle it's like touching your finger to a helium balloon and pushing. The harder you push, the faster the balloon moves in the direction you push. Now imagine that the balloon is massively heavy, and to get it to move fast you have to apply much more force than the light helium balloon. In equation form, this boils down to:

force = mass * acceleration, or another way is force = mass * the rate of change of velocity.

So for the same force, but different masses, you get different accelerations. For fluids, this equates to less dense fluids being far more responsive to force daemons.

Now, if you switch the daemon to velocity mode, the daemon works on a different basis and the velocity gets changed with time in proportion to the strength value, without concern for the particle mass. It's important to be careful with this mode because it can lead very quickly to particles moving at high speeds. This is OK so long as the particles don't interact with anything, but when they do they then have large amounts of momentum. So why should you care about that?

First, think about what momentum is:

momentum = mass * velocity.

Changing momentum with time is the same as mass*changing velocity with time, and that boils down to mass*acceleration again, which is force. This means that a change in momentum requires you to apply some force.

So when your fast particles hit slow particles, they get forced to slow down, their momentum changes dramatically, and you get very large forces applied. The result is that your particles can transfer forces through changes in their momentum to things around them, producing knock-on effects that may threaten RF3's stability because the changes are large and fast.

In general, the safest mode to use for daemons is force, because it causes more gradual, smooth changes in particle behaviour that are modulated through the particle mass. But don't forget about the velocity mode, it can be useful under certain conditions, like when you want more rapid changes.

Friction is a reactive force in nature that is all around us, always resisting motions. If you slide an object across a desk, the resistance is caused by friction between the desk and the object. If you go to a bridge and do a bungey jump, if the bungey cord is really long your body will reach a steady fall rate (terminal velocity) when the pull of gravity is offset equally by the frictional resistance with the air around you. In RF3, there is no built-in friction for particles except that produced by viscosity, causing friction between touching particles -- this is also how adjacent particles are able to transfer momentum from one to the other and eventually across whole bodies of fluid, and is why a force applied to one part of a glob of fluid pulls the rest of the glob into motion.

An important feature of friction is that it sucks away excess momentum, preventing "overshoot". Imagine yourself on the end of the bungey cord again, with plenty of momentum as you get near the end. If you get to the end still in air, where there isn't much friction, you'll preserve your momentum and bounce up and down, overshooting the final resting point for quite a while. If plunged into water, with lots more friction than air, you'd come to a rest far more quickly as the water sucks away your momentum. In fact, what happens is that viscous friction allows a much more efficient transfer of momentum from you to the water near you, and from that water to water farther away. So as you slow down quickly, you also generate a lot more motion in the water than you did in the air.

In RF3, you get the effects of friction by applying a drag force daemon. If you don't then you basically have fluid particles moving in outer space, with no friction, and that can lead to conspicuous overshoots. You'll see these as the particles oscillating endlessly around force daemons such as attractors. You can check this out for yourself by setting up a test scene, or download this scene and run the simulation. You'll see a fluid particle group orbiting around an attractor, until a drag daemon turns on at frame 160 and allows the fluid to get pulled straight over to the attractor.

4. Setup the initial values and animation for the drag daemon

For drag, determine a useful value for initializing the scene by running experiments while locked with gravity disabled, then animate the value to decay to zero over the first ~10 frames using an exponential decay expression. You should end up with a value in the range 3-20 as the strength at frame 0.

We need to figure out the values to use for the daemons. It's worth being systematic otherwise you can get confused with conflicting effects and end up tweaking for a lot longer than you need to. We're going to do this by focusing on just a few daemons at a time.

Let's start with drag force. Remember the purpose of this daemon is to allow us to quickly initialize the scene with a natural-looking droplet shape.

Go to the daemons tab and deactivate gravity, since we don't want the fluid to fall away from view yet. Lock the scene (lock button in lower right) as we don't need to save any frames yet, and hit Action. You'll see the fluid deform into a new shape, with the originally sharp corners slamming inward into the body under the influence of surface tension, making the entire thing jiggle a bit like jelly. After a little time, the fluid achieves a spherical shape and bobs up and down past the center of the attractor. This bobbing motion and the jelly jiggling is a result of not enough drag to dampen momentum, allowing oscillations to persist.

Stop the motion by hitting Action again, hit reset, and increase the drag strength. Run again and keep trying this until you get the cube of fluid quickly assuming a spherical form without a lot of jiggling and bobbing. A value of 5 seems to work well. Be careful about setting the drag strength value too large, as extremely large values (>100) can generate extreme forces and lead to instability. Useful, large values are 10-50. At a drag strength of 50, the particles move quite slowly and take too long a time to reach their final destination of a spherical shape centered around the attractor daemon.

While running one of these experiments, enable the gravity. You can enable and disable daemons "on the fly" during simulations, as you like. When unlocked and running, you can also stop a simulation and enable, disable or change daemons and then resume the simulation. This is a nice way to check the effects of daemons, if you make a note of the frame number you made changes. Then, on replay of the results, you can observe a number of experiments built into a single run. After activating gravity, the droplet falls away, out of view. This is because the gravity force (9.8) is significantly larger than the attractor force.

Now that we have a good value of drag determined, let's animate it to decay to zero in about the first 10 frames, so it does it's job to calm things down initially and then fades away to have no role during the main action.

Select the drag force daemon, then RMB-click on the drag strength and select Open curve from the context menu. This brings up the Curve Editor. We could keyframe from 5 to 0 over 10 frames, but let's give expressions a try. This is a good, simple start point to learn about them, and we'll use them in more sophisticated ways later.

In the curve editor, LMB-click on the Expression tab. In the text window, you can enter mathematical expressions to control the value of the parameter, in this case the drag strength. You know you are working with that parameter because it is selected in the upper left window. In the text window, you can either type expressions, or use the pull-down menus to add parts of expressions and variablies, component-wise.

We want the drag strength to start off with our determined value of 5, and decay smoothly to 0 in about 10 frames. You can achieve this with an exponential function, so pick this from the Unary functions menu. Within the rounded brackets of "exp()", type "-t" (you can also get this from the "I vars" menu, you can choose either t for time or f for frames as time variables). We use a negative value to get a decaying exponential. Hit return, and you will see immediately the function plotted on the graph. This feedback is useful for quickly figuring out your expressions, as we'll see later.

The exponential goes from 1 at frame 0 and takes a long time to decay to zero. To get it to start with our desired value of 5, make the expression "5*exp(-t)", just multiplying it by 5. To incease the rate of decay, multiply the time value by a number -- this is like compressing the time scale. Using a value of 20, you get to a value close to 0 at about frame 10, so the final expression looks like:

5*exp(-20*t)

Now when you run the simulation, the drag will decay rapidly with time. When locked, the calculations will run holding the drag value constant, depending on where in time you lock. If at frame 0, then the value of the drag strength will be 5, so you can initialize the scene without worrying about the value or enable/disable state of the drag daemon

5. Setup the initial values of the surface tension and attractor daemons

Run similar experiments as in step 4 to determine good values for the surface tension strength and attractor strength, now with gravity enabled. You are aiming for the droplet to snap quickly to a spherical shape, having it's shape largely controlled by the surface tension just like small water drops in nature -- try values in the range 30-3000. The attractor needs to be able to resist gravity completely, as though the droplet was stuck to an object, so needs to be significantly greater than gravity. Values of attractor strength 50-400 work well.

Enable gravity and run locked experiments to explore for satisfactory values for the surface tension strength and attractor strength, resetting between changing parameter values.

Surface tension needs to dominate most of the time in controlling the shape of the drop, just like in nature. The surface tension works by applying a sort of tension force along the surface of the fluid, and the strength of the tension scales on the strength value. However the value also varies locally and depends on the local radius of curvature of the fluid shape. So, sharp corners have locally very strong tension applied and end up moving fastest in response to surface tension. That's why the corners of the fluid cube (after resetting the scene) snap in so quickly.

In RF3, for having strong surface tension effects, you can expect to see surface tension values in the range of hundreds to thousands. Very large values can make it difficult to deform the droplet with other forces, but sometimes this is needed to get the right sort of snapping behaviour. In those cases (and this is one) you need to increase other forces to get desired effects. The relative influence of daemons on your RF3 fluids always depends on the balance of forces. If one daemon applies a force orders of magnitude greater than others, it will dominate over all other effects.

A value of surface tension strength of 1000 seemed to give the right sort of behaviour, at least on initializiation (locking and running until the droplet is spherical and largely still).

During your surface tension experiments you will have experienced the balance of forces concept through the tug of war between gravity and the attractor. If the attractor strength is less than gravity, the fluid droplet will acclerate down. If the values are equal, then the force pulling down is the same as that pulling up and the droplet will stay largely where it starts, unless you placed the attractor not quite in the center of the fluid so that it gets some momentum. In that case, the fluid will move with a constant speed. Making the attractor strength significantly greater than the gravity, the droplet will stick to the attractor but be displaced a little downward by gravity.

A value for the attractor strength of 50 seemed to work well as a starting point.

You will see in your experiments, that you never really get a good, elongated drop-shape. This is because the forces act on all fluid particles equally. In the next step, we'll change this.

6. Setup the attractor animation

Alter the attractor settings to attenuate the force with radial distance, use an expression to make the external radius 0.1 more than the internal radius, set the external force to 0, and then animate the internal radius to decrease from 1 to 0.4 in the first 15 frames so part of the drop is released from it while the upper part is still affected. Use an "if" expression to drop off the internal force from 50 to 0 at frame 80, to release the last bit of fluid.

In this step we'll learn about the power of spatially bounding daemons, and also learn more about animating with expressions.

Daemons that apply forces, such as gravity, wind, drag and attractor, can be spatially bound so that you can apply them just locally, where you need them. This adds a tremendous amount of fine control, since you can affect just parts of fluid bodies and so make a fluid deform. That's what we need here.

In our scene, the attractor influence needs to shrink back, so that just the top part of the droplet stays stuck while the bottom part can get pulled down by gravity, making it stretch vertically. After stretching, we want to make sure the upper, stuck part eventually does fall away, so we need to finally shut off the attractor.

To do this, we first have to make the attractor bounded. You can do this in two ways: by explicitly making it bounded, or attenuating its force. Attenuating is a nice way to do this because it makes for smooth, natural-looking transitions, so let's use that method.

Select the attractor daemon, and switch to attenuated. You'll now see 3 new fields activated: internal radius, external force and external radius. In this mode, the force varies away from the attractor as a constant value (internal force) from a radius of 0 to internal radius, varies continuously from internal force to external force going from radius values of internal radius to external radius, and then is constant at external force beyond the radius value of external radius. So, you can have an attractor that attracts particles at a distance (external force > 0), and then repulses them close up (internal force < 0). In our case, make the external force = 0 so the attractor has no influence at distances more than the external radius.

We want the external radius to be just a bit bigger than the internal radius, so the force gets attenuated rapidly but continuously from an inner core value of 50. RMB-click on external radius and go to curve editor, and the expression tab. Use the "D vars" menu to find attractor01, and its internal radius parameter. After adding that to the expressions text box, type beside this entry to add 0.1 to it, so you get an expression that looks like this (you can cut and paste the below text if you want) :

0.1+attractor01.internal_radius

This makes the external radius always just a bit bigger than the internal radius, so we can animate the internal radius and the external radius always moves along with it. In 3D applications this is often referred to as a "driven variable" because its value is driven by another.

Now enter the curve editor for the internal radius and keyframe its value to go from 1 to 0.4 over the first 15 frames. This makes for a rapid fall-away of the bottom of the droplet, but you can vary the time span and also the final value to see how they affect the scene results. We don't drop to zero because that releases the whole drop too quickly to allow much deformation. Reducing the final value acts to reduce the volume of the droplet that is held back, so you get a different looking but still similar behaviour.

Next, we want the internal force to drop off sometime after the internal radius drops off, so that last bit of droplet gets released to descend. You can run some experiments to figure out a good time to drop the value, which is once the drop gets well stretched out.

Again, use the curve editor, this time for the internal force. You can use keyframes, or learn a new expressions trick: the "if" statement.

The "if" statement is a useful function as it allows you fine control on switching between values or even functions for a parameter. In our case, type the following in the text box:

if(f<80,50,30)

When you hit return, resize the graph to see the results. Navigation in the animation graph is done the same way as the viewport, using alt in combination with mouse buttons (alt-MMB-drag to translate, alt-RMB-drag to zoom). The "if" expression generates a step-function, giving us an internal force that is a constant 50 until frame 80, then drops off instantly to 30. The above "if" statement means: if the frame is less than 80, the value is 50, otherwise the value is 30.

The "if" statement is very useful for switching from conditions for initializing a scene, to those for running, immediately after the first frame. It's also great for turning on or shutting off emitters at specific times, when applied to an emitter's speed parameter.

Time to run some experiments: first, make sure in export central that you will be saving particle bin files. Now reset the scene, lock, and run until the droplet is spherical and quite still.

At this point, if you want to preserve the initial drop shape, you can stop the simulation and save the file at that stage. Now when you run a simulation, instead of resetting just rewind the timeline and start the sim from that initial state, over-writing the saved files. If you accidently hit reset, you can go to file>revert to re-load the saved version of the file. In this scene, the initialization is quite fast so you might not be concerned to preserve the initial state.

However you do the initialization, you can choose to stop the action, unlock, then start; or you can just unlock and get the simulation going.

Now you can see we get a nice elongating droplet, that is reasonably realistic. You can do some tweaking to get a nicer version, altering the values of the attractor initial strength, the surface tension strength, the timing of the attractor step, and the final value of attractor strength.

7. Final Simulation

Increase the resolution of the droplet, reset and run the simulation. Tweak the parameter values to get the final behaviour you want, then do the final run.

The only step left is to increase the resolution to what you feel gives you the sort of detail you want in your final simulation. What you are looking for is just enough particles to get well-defined fine-scale features of the fluid motion, such as tiny breakaway droplets. Using a resolution of 2 seemed to achieve this, but you can choose what you like. Remember that higher resolution means more particles and slower simulations.

You will notice, on running the higher resolution simulation, that the behaviour will be similar but not identical. One reason for this is that the higher resolution particles are less massive, and the mass is important in determining how things behave with forces applied. It's important to appreciate the fact that changing the resolution may cause changes to the details of the behaviour in any scene.

Do a little tweaking to get the behaviour you want, then run the final simulation. Download and check the project scene for the values we settled on.

Congratulations! You have just completed the tutorial and created a realistic droplet.

8. Advanced session: Parameterizing scenes for predictable behaviour

Re-do the animation of the daemons using more advanced expressions combining exponential decays and "if" statements, and develop a physical understanding of the scene in terms of just 4 essential parameters: the decay rate of the attractor radius, the final radius of the attractor, the release time of the attractor, and the decay of the attractor force.

Download the revised scene: teardrop

You have by now noticed the large numbers of parameters at your fingertips in RF3, even for quite simple scenes. Besides this, you can already tell just how difficult it is to predict the detailed behaviour of fluids. These two things together mean that a fluid simulation is hard to control.

As you gain experience, you will get better at controlling your scenes. In this section, we'll show you a little of how you can develop a physical understanding of a scene's available behaviours, so you can then proceed to get just what you want -- or more likely, what the director wants.

The basic approach is, first, to keep scenes as simple as possible, avoiding adding lots of daemons or you will have too many interacting effects. Second, attempt to understand the scene in terms of the fewest possible parameters. Third, map out the basic behaviours in terms of those few parameters, so you have a roadmap that allows you to quickly achieve whatever behaviour is finally demanded.

Our droplet scene is already quite simple, with all the behaviour controlled by the attractor daemon and surface tension. So, now we have to develop a better understanding of how the scene works.

First, let's revise the attractor daemon animations with slightly more sophisticated expressions, using exponential decays to make for nice, smooth transitions. These kinds of transitions usually look more natural than step-functions.

Select the attractor daemon and open the curve editor to show both the internal force and internal radius curves. For the internal radius, we want a rapid decay from a value of around 1 (a little bigger than the droplet) to some final value a little bigger than 0. Intuitively, we know that the bigger this final value and the slower the decay to it, the more particles of the droplet will be held up and prevented from descending. This means these values control the volume of the droplet that is held back as the droplet stretches vertically. To get this kind of curve, just use an exponential decay with an added constant:

0.25+exp(-5*t)

The value 0.25 is the final value of the internal radius, and the value 5 is proportional to the rate of decay to that value. Try some other values to see how they affect the curve shape, before re-setting the expression to that above as a starting point.

For the internal force, we want a constant value for the first part of the scene while the top part of the droplet gets suspended, until a "release time" when that part gets released, and then a smooth transition to zero. This period will define how much the droplet stretches out -- a greater release time will allow for more stretching. In addition, the rate of decay of the force after the release will add to the effect, with a very slow decay allowing more stretching while the top part of fluid starts to move. A very fast decay will allow the top part of fluid to rapidly descend, possibly reversing stretching or at least inhibiting breakup of the droplet.

To get the curve shape, use an "if" statement combined with a time-shifted exponential decay.

You can use any function within an "if" statement, not just constants. But to get the curve to go continuously from one part (constant value in this case) to the exponential part, we have to scale the exponential correctly and also time-shift it to start off where the constant part ends.

If you have a function like exp(-5*t) and you want to shift it in time so that it starts 2 seconds later, all you have to do is change the time t to (t-2). In the equation, this means that when the time is 2 seconds, the value in the equation is 0. When the time is 3 seconds, the equation sees a value of 3-2=1. And so on. This makes our time-shifted equation exp(-5*(t-2)).

In our scene, we made the expression for the internal force this:

if(t<0.52,300,300*exp(-3.5*(t-0.52)))

Which says that the internal force is 300 up to a time of 0.52 seconds, and after that the internal force follows the exponential function. That function is time-shifted by 0.52 seconds, starting with a value of 300 at 0.52 seconds, and then decays in proportion to the value 3.5. You'll notice we increased the initial force from 100 to 300 for this revised scene. The reason for this is that the surface tension got increased to 2500, to get better droplet breakup effects. We found the droplet in the earlier scene a little too syrup-like.

In this case, then, the parameter controlling the release time is the time 0.52, and the decay rate 3.5.

Overall, we now have just 4 parameters that control the scene (assuming we are happy with the surface tension, gravity, density and viscosity).

By running some experiments where we vary just these values in a systematic way, in just a short time we can develop a roadmap of the variety of behaviours. The only reason this is possible is because we have boiled down the controls to just a few parameters, if we had even a few more then the task of running experiments varying each parameter one by one would be too big to be approachable in a short time. For our scene, the table below can be built up in an hour or so of trials, where the values are the final radius/radius decay/release time/release decay :

tiny volume held up, short stretch, no breakup (0.1/5/anything/anything)

small volume held, short stretch, no breakup (0.25/10/0.46/5)

small volume held, long stretch, breakup just happens (0.25/5/0.52/3.5)

large volume held, short stretch, no breakup (0.4/15/0.4/12)

large volume held, long stretch, breakup into a series of drops (0.4/5/0.45/2)

large volume held, short stretch, sharp break into two drops (0.4/15/0.65/20)

After this mapping, when the director asked for a droplet that behaved a certain way, you could deliver the animation quickly and precisely.

Tips:

-         There are many other ways of getting this kind of stretching behaviour, such as using bounded and animated gravity; using an object to hold the droplet top end; animated and attenuated limbo daemon; etc.

- getting good previews: The example animation at the top of this tutorial was created by saving the particle files from the mapping exercise of the last (advanced) session, and then creating a new project just for the preview. Each set of particle files was imported into the new scene using a binloader (for each), then the binloader emitters were re-positioned and their display colors changed, and finally the scene played with preview images enabled for exporting via Export Central. This technique allows you to leave out other objects and daemons that clutter the view.