Fluid Simulation


Blender provides a couple of tools that can be used to apply certain physical properties to objects. And such objects can even be affected by different physical forces, like gravitation or wind. One of these tools allows you to generate fluid simulations. Not only the simulation of the yielding is part of this tool but also the interaction between the fluid and other objects within the scene.



The basic functions of the fluid simulation tool will be presented in the following exercise: We will build a wine bottle that will transfuse its wine into a glass. Hence, we will have at least three objects in our scene: The fluid, the wine bottle, and the glass. In order to pad the scene with another element, also a marble table will be added to that scene.

First, we want to place our two container objects in the scene. Since both of them have an axially symmetric shape, we can use the procedure I already mentioned in another chapter (Fig. 1 - 1, 2) in order to build these objects. For the shape of the table board I simply used a cylinder object (which has been scaled along its axes) and applied some modifications to the shape of that mesh (smoothening of the edges by use of MODIFIER BEVEL, additional smoothening with MODIFIER SUBDIVISION SURFACE, both with the default settings) as well as to its material and texture properties (TEXTURE MARBLE, with some adjustments of the parameters; in the MATERIAL section I activated SUBSURFACE SCATTERING with the preset settings for marble and used some mirror reflections).


Note: I will not report the exact material settings I used for my objects here, since those settings are not important for this exercise and will rather be subject to personal preferences.


The next step to do is to embed the fluid into the scene: Actually, you can use any geometric primitive as the fluid object, since its function will merely be to determine the volume as well as the initial position of the fluid. That means that you don't even have to assign certain material properties to that fluid object. For our example I used a simple cylinder as the fluid object and placed it into the interior of our bottle (Fig. 1 – 3).


Figure 1.


At first glance, it looks as if we have all necessary objects we need for our fluid simulation. However, the main object is still missing: We need another object that serves as a kind of spatial frame for our simulation, i.e., this object determines the spatial boundaries of the simulation that includes all objects that will be affected by the fluid. For our example I used a simple cube that has to be scaled along its axes until it includes all other objects we added before (Fig. 1 - 4). As we will learn later on, this object will take the role of our fluid itself and this object will be the one we have to link to the material properties of our wine (I gave it a dark red diffuse color and some transparency properties with an index of reflection of 1.33).

So far, we have done the groundwork for building up our scene. So let's come to the interesting part of our exercise: The implementation of a fluid simulation. All the objects we added to our scene will play different roles within this simulation. The glass and the bottle will serve as containers for our wine. The table board, on the other hand, will predominantly play the role of a boundary for the fluid. You can apply these roles to the objects in a simple way: This will be done in the PHYSICS menu of blender (last button in the menu bar at the far right, see Fig. 1 - 5).

First, you have to click the button FLUID in the PHYSICS menu, then you can select the desired property or role for each object in the selection field. For the objects “bottle”, “glass”, and “table” we will choose the role OBSTACLE, since all of these objects will serve as surfaces that prevent the fluid from further drainage. Since our glass as well as our bottle will play the role of container objects, we will have to select the property SHELL for both in the next selection field. For our table I used the option BOTH in this selection. For the cylinder that we placed into the interior of the bottle and that represents the volume and the initial position of our wine we have to select the role FLUID in the selection field.

The most important part for our fluid simulation, however, will be the cube we added before as a kind of boundary box: This object will be our DOMAIN. As you can see, blender offers many more functions and properties for this DOMAIN object, compared to the other contributers to the simulation (Fig. 1 - 6-9).

In the FLUID section, you can determine the spatial resolution of the mesh that represents the fluid. For the final result (FLUID RESOLUTION FINAL, Fig. 1 - 6) as well as for the preview you can adjust the value of the resolution. The higher the corresponding value, the better and smoother the result will be. However, also the processing time and the required memory will increase with an increasing resolution value. You can see the hard disk memory that will be needed for the simulation files on the BAKE button of the FLUID section (Fig. 1 - 7). Just play around with the resolution value and see how it affects the required memory.

In another section you can apply further properties to the fluid, for instance, you can determine the viscosity of the fluid (DOMAIN WORLD VISCOSITY PRESETS, see Fig. 1 – 8). In this selection field, you can choose between some presets, namely, between OIL, HONEY, and WATER. For our wine, we will select the option WATER (which is not meant to be a quality feature of our wine—let us imagine that we have a good vintage of a Burgundy).

I also adjusted further settings of the DOMAIN object that will also affect the processing time and the required memory: In the section DOMAIN BOUNDARY I increased the values SMOOTHING and SUBDIVISIONS under the SURFACE options (Fig. 1 - 9). Both will increase the resolution and the smoothing of our wine. I recommend to try out several values here, just to get familiar with these parameters. Actually, I used rather rough values for our example, for a more realistic fluid simulation higher values would be more appropriate. But as long as it is just for demonstration purposes, those values will be sufficient, I think.

If you press the above-mentioned BAKE button (Fig. 1 - 7), you will start the calculation of the fluid simulation. For each frame blender will generate a couple of files that will contain the respective information. In the field at the bottom of the FLUID section you can determine the folder for these files. blender will always use these files when you start or render the animation. That means that the fluid simulation will not be calculated anew each time you start the animation—which is a good thing if you want to do some modifications in the rest of the scene.

But let's wait a minute before we will start the simulation. First I want to apply a tilting motion to the bottle object, using the so-called IPO-buttons of blender: The initial position and orientation of the bottle is already fine. In order to build a smooth motion where the bottle will travel from its initial position to a draining position, I set the marker of the time line at the bottom of the screen to frame 60 (Fig. 2 - 1). At this frame I place the bottle at the draining position (using the translation and rotation tools). We don't have to care about the cylinder—it will remain at its original position. After I placed the bottle at the draining position, I click the button I (IPO) and select the option LocRot (Fig. 2 - 2). This way, we built a smooth motion between the two different positions of the bottle between frame 1 and frame 60. The next IPO point will be at frame 150: I just select this frame in the time line and press button I again and select the option LocRot, without changing the position of the bottle. That means that our bottle will keep the same constant position between frame 60 and frame 150. At frame 165 I will set another IPO point, in order to indicate a removal of the bottle from the glass. We will place the bottle at a new position in this frame and repeat our IPO-procedure. You can have a look at the motion simulation now: Just move the marker of the time line by hand or start the simulation with ALT + A.

However, the fluid simulation will not be part of that animation at the current stage. We haven't started the calculation of the fluid simulation yet—so let's do it now and finally press the BAKE button (Fig. 1 - 7). Meanwhile, you can do some homework, since the calculation will last for a while. You can see the status of the calculation at the processing bar at the top of the window.

After the calculation is done, we should first disable the visibility of the cylinder that served as our FLUID object, because otherwise it would appear in the rendered images. In the window at the top right we have to select the respective object (which I named “wine” before) and click the camera symbol (Fig. 2 - 3). This way we told blender not to render this object anymore. As a last object, I added another cube with a wallpaper texture that includes all other objects in the scene (including the camera and the light source) and serves as the room in which the scene takes place.


Figure 2.


After this is done, we can start the rendering of the animation, in order to produce a little movie clip with our fluid simulation: In the RENDER window (click the camera symbol in the menu bar, Fig. 2 - 4) one has to select an appropriate video format in the OUTPUT section (I used the AVI RAW format, Fig. 2 - 5) and then start the rendering by pressing the button ANIMATION at the top of the RENDER window (Fig. 2 - 6). For my video I truncated the time line a bit, setting the start position of the video at frame 36 (DIMENSIONS FRAME RANGE START, Fig. 2 - 7). Again, we will have some time until the video is rendered—I hope you can keep your anticipation during that processing time.



© 2011 G. Wendt

Write a comment
Name: Note: Your email address will not be displayed on this site nor otherwise published!
Color & Font
Color tool

You have difficulties finding a balanced color combination and appropriate font formats for your website?

Use the tool Color & Font on this website in order to interactively create the color and font properties of your own site. The results of your settings can be easily included as CSS listing in your web project.