Tutorial: RealFlow Water Sphere

RealFlow Water Sphere

 

Introduction

This tutorial will guide you through creating a fluid dynamic simulation of swirling water inside a glass sphere. Next Limit RealFlow 4 and AutoDesk 3DS Max are used in the tutorial.

 

 

The Goal:

The goal of this tutorial is to animate a small body of water inside a spherical container using Next Limit’s fluids engine, RealFlow. The water inside the container will be generated by the RealFlow’s particle system and fluid motion acheived using a combination of fluid dynamic settings and force fields native to the RealFlow simulation tool. The completed animation will be rendered within a 3D graphics application such as 3D Studio Max.

Overview:

RealFlow is unique in that it is the first commercially available product to marry two previously functionally distinct approaches to real-world graphics simulation: particle systems and physics engines.

The RealFlow fluid simulation engine permits the realistic simulation of complex interactions between fluids and solids by merging a particle and physics engine to more accurately integrate and control the behavior of fluidic mass and surfaces with that of rigid and soft bodies.

As a physical simulator, RealFlow’s true value lies in returning ultimate control of the physics simulation process back to the user via a wide selection of simple modifiers that control fluid behavior and interaction, thus allowing fine-tuning of the physical characteristics of the elements within a simulation according to a set of user-defined parameters.

The integration of RealFlow with other 3D platforms depends on a two-way transfer of scene data between it and third party 3D applications like 3DStudio MAX, Maya, LightWave, XSI or Cinema 4D. These various applications employ different methods for transferring data in and out of RealFlow.

In this tutorial, scene data representing the objects we want in our animation will be exported from 3D Studio Max into RealFlow where it will used in the fluid simulation. The resulting animation will be imported back into 3D Studio Max as part of our scene and rendered. The tutorial is divided into three sections.

  1. Setting up the scene data within our third party 3D application and exporting it to RealFlow.
  2. Using the imported scene data, performance of the fluid simulation within RealFlow.
  3. Importing the completed simulation data back into 3rd Party 3D application for rendering.

Resources:

Requirements:

  • RealFlow 4
  • 3DS Max v.7.0 to 2009.
  • VRay v1.5 *

* Recommended, not required.

The source files required to complete the tutorial using 3D Studio Max are included with this tutorial. If you are using another 3D application, I would suggest reading the RealFlow documentation for import/export process for scene data before continuing with the tutorial.

My preferred renderer for scenes involving fluids and glass is VRay, however similar material effects can be achieved with your native render plugin. If your graphics package does not come with preconfigured material settings for these materials, I suggest looking at the many free tutorials on how to create water and glass materials for your particular package. It is not too difficult to create your own materials once you master the basics, you may even prefer this over using the supplied materials.

Hope you enjoy it!

PROJECT SOURCE FILES

If you have any questions, please feel free to contact me via my web form at http://www.arstropica.com.

The Process

A: Scene Data Setup & Export.

  1. Open 3DS Max and open the start_tutorial.max scene.
  2. Click the Time Configuration button.time_config
  3. Change the Frame Rate to ‘Custom’ and enter 12 FPS. Ensure that frame count is at least 40 frames.
    time_config
  4. Now to create the scene object(s) that we will export to RealFlow. Create two spheres of radius 7.5 and 8.0 units respectively.

    RealFlow integrates mesh objects into its particle/fluid simulation on the sub-object level. RealFlow will use mesh sub-object data to ‘recognize’ the physical surface dimensions of a mesh in relation to the thousands of fluid particles involved in a simulation. The mesh recognition occurs at the polygon sub-object level with an additional requirement known as triangulation: all polygons must be three-sided. Different applications use different methods to create triangulated meshes. In 3DS Max, the tessellate modifier will convert a four-sided polygon sub-object in a mesh to triangular polygons. In this tutorial, particles will not interact directly with an external mesh, so we do not need to be too concerned with the triangulation requirement. However, it is recommended that all exported meshes should be triangulated as a rule of thumb.

    Step_4aStep_4b

  5. The spheres should be centered within the camera’s field of view and aligned with each other.
    Step_5
  6. Select the innermost sphere with the 7.5 unit radius. Under the Utilities panel, click the ‘More’ button and select the Scene Data Saver utility.
    Step_6aStep_6b
  7. Open SD Saver Settings and ensure that the selected sphere object is selected. Click the SET button to open the Sequence Interval Dialog and save the sequence as ‘water_sphere_tutorial.sd’. Remember where the scene data file is saved as you will need it in the next section.
    Step_7astep_7b
  8. At this point, you can close Max if you want. Resave your file before closing Max. You may view the 3DS Max scene at this point by opening the ‘Section_A.max’ file.
     

B: RealFlow Fluid Simulation.

  1. Extract RF4_start_tutorial.zip file to a local directory and open the directory. Copy the scene data file that you created previously: ‘water_sphere_tutorial.sd’ into the ‘objects’ sub directory.

    Alternatively, you may create a new RealFlow scene and copy the scene data file: ‘water_sphere_tutorial.sd’ into the ‘objects’ directory. In this event, you will need to change the following settings in RealFlow: scale: 0.10 Step_1a, animation length: 40 Step_1b.
  2. If you haven’t done so already, start RealFlow. Under the File menu, select import > import object and import the copied scene data file into RealFlow. As you can see, the sphere object we created in 3DS Max now appears in RealFlow.
    Step_2a
  3. One more step you should perform before making further changes is to ensure that the axis setup setting is configured for your 3D application. In the General tab under File > Preferences, select the axis setting that corresponds your 3D application. If you do not see your 3D application displayed in the drop down menu, leave the setting as it is.
    Step_3a
  4. Select the sphere object in the Nodes panel to bring up the Node Params panel. Under Nodes, the position information should tell you the sphere location within the RealFlow environment. If the position is not at origin, i.e., 0,0,0, we need to change it so it can align with everything else we will add to the RealFlow scene. Click the SD < – > Curve button once to allow editing by RealFlow and change the position settings to 0.0 for all three axes.
    Step_4a
  5. The sphere represents the volume that the fluid will occupy. However, as the fluid will be in motion, it should not occupy the entire volume of the sphere. We, therefore, have to create fluid that, initially, only partially fills the spherical volume. The ‘Fill Object’ emitter can fill the volume of a mesh object with fluid particles. Add a ‘Fill Object’ emitter to the scene by clicking the ‘Add Emitter’ icon Step_5aand selecting the ‘Fill Object’ emitter.
    Step_5b
  6. Make the following changes to Fill Object emitter parameters:
    1. Under Particles:
      1. Resolution: 30
      2. Density: 500
      3. Viscosity: 1
    2. Under Fill Object:
      1. Object: Sphere1
      2. Fill Volume: Yes
      3. Fill Z ratio: 0.3

    Step_6a

    By setting the Fill Z Ratio to 0.3, we are filling 30% of the spherical volume with fluid as shown in the figure below.
    Step_6b

  7. If we were to leave the settings as entered so far and run our fluid simulation, we will have created a fluid simulation that is not too exciting. If you want, you can try this by hitting the SIMULATE button just to see what happens. The particles representing the fluid will rise slowly and that’s about it. It is evident that this is not a very realistic simulation of typical fluid behavior. There are no forces acting on the fluid so it simply floats there in a manner somewhat similar to fluid behavior in a zero gravity environment. So let’s add some of the forces that we expect would typically affect fluids.
     
  8. The first force we’ll add is Gravity. Click the “Daemons” icon Step_8a, and choose ‘Gravity’ to add a realistic gravity force normal for a real world environment.
    Step_8bStep_8c
    The position of the daemon isn’t too important as long as the arrow is facing down. If you were to run the simulation again (by rewinding the timeline and clicking SIMULATE), you would see that the fluid particles no longer rise as before although they still move around. This is a little closer to what we would expect from a contained body of standing water. Again, not too exciting. So, what other forces could we add to stimulate fluid motion?
     
  9. RealFlow contains several daemons that simulate the effects different types of forces on fluid behavior. In this tutorial, we will introduce a daemon with a random force vector acting upon our fluid to make its behavior more interesting. Go ahead and click the “Daemons” icon again and, this time, select a ‘Noise Field’ daemon. Change the “Strength” parameter to 25.0.
    Step_9cStep_9b
  10. Adding a Noise Field daemon introduces an element of random variance to the motion of our fluid particles that is similar to the random turbulence created by wind or shear effects in our simulation. With unpredictable behavior comes the possibility that the movement of some particles may carry them outside the predefined space of our sphere. In order to maintain some element of control over the spherical boundary of our fluid motion, we can also add a daemon to our simulation that will remove those particles that move outside the volume of the sphere. In this tutorial, this step is superfluous because of the relatively simplicity of our simulation. RealFlow can make all the required calculations for particle motion and volume containment without sacrificing accuracy or speed, due to relatively low particle count, particle velocity and primitive mesh object. However, in a more complex simulation, it is a good idea to add a Killer daemon to destroy particles that fall outside a predefined space. This step eliminates unnecessary calculations for unwanted particles.

    Click on the Daemons icon and add a kSphere daemon to the simulation. Use the “Fit to Object” setting to position and size the daemon to our sphere and set the radius to 0.77.

    Step_10aStep_10b
    Step_10c

  11. Re-run the simulation again, and you should get something similar to the figure below. At this point, you may disable the display of the sphere object by changing the sphere’s Visible setting to No, in order to view the fluid particles more clearly.
    Step_11aStep_11c
    Step_11b
  12. Hopefully, our fluid particles look more interesting now than before. Now that we have our particle simulation, we need to create a kind of ‘skin’ for it so our fluid can have a visible surface. In RealFlow, this is done with a 3D fluid mesh that is built from the particles in our simulation. To create the fluid mesh, click the “Add mesh” button Step_12a. In the Mesh section under Node Params, change the Polygon size to 0.03.
    Step_12b
  13. Right click the ‘Mesh01’ node and select ‘Build’ to generate the mesh. You can view a solid rendition of the mesh by right clicking any view and selecting Shading > Smooth.
    Step_13a
  14. Reset the simulation by clicking the RESET button and run the simulation. The mesh should now be displayed in each frame of the simulation.
    Step_14a
  15. By default, RealFlow saves a 3D model of each mesh generated simulation under the ‘meshes’ directory of the scene folder. To ensure that this happens, you can check the export setting in ‘Export Central’ under the Export menu. With the fluid mesh exported to the meshes sub directory, we are ready to return to our 3D application.
    Step_15a

    You may view the completed RealFlow scene by opening the ‘end_tutorial.flw’ file in RealFlow.

C: Import & Render Scene.

  1. Start 3DS Max, if you had closed it earlier, and reopen the file you previously saved.
  2. Of the two spheres that you created earlier, select the innermost sphere and hide it.
  3. Under the create panel, use the drop down menu to choose Next Limit and then click the RF Loader button. Under File Options, click ‘Select File Sequence’, navigate to the ‘meshes’ folder of your RealFlow project folder and select the first .bin file. Click the ‘Create Mesh’ button to generate the mesh object. You should see that the Number of Fluids amount changes to 1 and that our fluid mesh is now displayed in the viewport(s).
    Step_3aStep_3b
  4. Select the sphere and open the Material Editor. Apply the GlassForest material to the sphere. If you change the viewport view to Smooth + Highlights, you will see that the sphere is now semi-transparent and the fluid mesh is visible.
    Step_4aStep_4b
  5. Select the fluid mesh (MeshLoader1) and apply the ‘Transparent watery blue’ material in the Material Editor. The fluid mesh material should change as shown below.
    Step_5aStep_5b
  6. If you perform a single frame test render, you should have something similar to the image below. You may view the completed 3DS Max scene by opening the ‘Section_C.max’ file.
    Step_6a
  7. Render out the full 40 frame animation to see the fluid motion within the glass sphere.

Conclusion

Thank you for reading this tutorial. If you have any questions, please feel free to contact me via my web form at http://www.arstropica.com.