Monday, June 4, 2012

Horrible Tutorial #1 - Fluid Simulator Explained

So here is Horrible Tutorial #1, Blender Fluid Simulator, explained... as best as I can.

So this tutorial goes into the basic setup, and design of the scene. The main event is the Fluid Simulator, how to set it up the simulator, configure settings, and explains what most of it does. I show and explain the domain, the fluids, and obstacles. And finally how to set up the domain, and get you to understand what it all means.

After the break, you'll see the video, and I'll give an outline of everything I went over in the video.

So first, one of my favorite little things is setting up the world sky, and a sun lamp to get a quick setup of environmental lighting.
In the World Properties pane, choose to add a node, and change the color to "Sky Texture", by clicking on the little dot in the color bar.
I leave Turbidity at 2.20 because it's a nice clear day with light haze by the horizon, and I like to put the sun somewhere near the horizon, where it might shine from the side, or stay within frame.
Set up your sun lamp to point in the same direction the Sky Texture is, and you're on your way to setting up a great looking outdoor scene.

I didn't want to bore you with the basics of setting up some cubes and moving them around to position my scene, so make your scene how ever you like. I suggest you texture them, and make them a bit more realistic than I did.

Into the setup of the fluid simulator:

There are three basic objects; Domain, Fluid, and Obstacles.

  • The domain is the world where your fluid will exist, and the fluid results itself. 
  • The fluid object is merely starting dimensions for where your fluid will be calculated. 
  • Obstacles are dimensions where fluid is not supposed to go.

The three basic fluid types for the simulator, found on the fluid object itself in the physics properties pane.

  • Fluid - Based on the dimensions a one time object that just falls into the scene, with the exception of gravity and other forces, this fluid type is very simple.
  • Inflow - A pipe from the 5th dimension that pumps fluid into the scene, using the dimensions as a continuous hole, where fluid will be generated.
  • Outflow - A drain, to the 5th dimension, where fluid gets drained out from the scene.
Notice, I don't get into particle system fluid type, because that's a complete tutorial in itself, and should be an interesting one.

After you've baked the fluid simulation, if your origin object for the fluid is in your render or animation, you can remove the object without affecting the rest of the scene, or if you prefer, move it to another layer. Select the object, and hit the [M] key.

Back to the domain, as I said above, the domain becomes the actual fluid result, so this is the object you're going to texture as your fluid. Be it water, oil, jelly, or icing. I wanted a dam breaking scene, so water would flow into my scene. 

With cycles I gave the fluid a "Glass BSDF" texture, with a white and slightly blue tint color, and an Index of Refraction of "1.333" (Hint: That's water.) In one of my samples I did a slight roughness to the texture to give it some turbidity, or cloudiness.

Finally, the domain settings:
  • Resolution - This is the basic quality setting of the simulation, the higher the final resolution the better the final render will look. The higher this number, although the longer the simulation time, and the more memory simulator will take. (I have noticed over 400mb of required memory may crash blender.) This will increase memory requirements exponentially. My preference was 256 for the final, the preview did not matter max for the preview is 100.
  • Time - This value is in seconds, start time and end time. If you want to just generate the scene for an aftermath of what happened, you can change the start time and end time to be what you want. 

Important: Make sure your total time (End - Start = Total) is Equal to the Total Frames, divided by your scene Frame Rate
Say your Animation is 250 frames, and you've got 24 frames per second, 250 / 24 is equal to 10.41 seconds. If your start time is 0 in your fluid simulation, then the end time should be 10.41.
With the exception that if you are intentionally trying to create a high speed film simulation, or "slow motion." 
Accidentally setting the wrong time frame, just makes fluid look bad.

  • Cache Fluid Directory - This is one of the most important settings!
    Make sure you set this directory, if you have a directory where you're building this scene, and storing your textures, make sure you keep this directory with the blend file. If you lose this directory, you will have to bake the simulation all over again. 
  • Viscosity - There are some very simple default settings here, but some techniques that you can learn. Viscosity is the thickness of a fluid; Air is just a low viscosity fluid. Water is low, honey is highly viscous.
    My tip when playing with the simulator, Viscosity can change the relative appearance of size of your fluid. I put the water in my scene to a base of 0.7, this makes the liquid appear like water but at a greater distance. If you wanted to make the scene look like a simple 2 foot model you may turn up the viscosity maybe to a base of 1.2. 
  • Smoothing and Subdivisions - Smoothing effects the edge sharpness, subdivisions adjusts the number of edges to adjust the roundness. This will increase the required memory, and too high of a setting can cause blender to crash. (Too many vertices.)
  • Particles - The particles settings adjust the crash effect of the water simulation. This is just something you need to play with, to get to the right setting you like. I had set "2", with a generate of "0.4"

That's really it!

When you're happy with the settings, click that magical [Bake] button on the domain, and listen to your hard drive chunk away. The fluid simulator generates it's results from the bake and stores it in the Fluid Cache directory I mentioned before. This directory can become quite large (I've had larger than 21GB), so make sure you have space for it.

As it bakes you can watch the progress by stepping through the animation frames, if you're looking for a still shot, you can catch one early and stop the bake. But if you're looking for a full animation, you need to wait for it to finish, but keep an eye on the results, just in case it looks horrible or unusable.

After it's done, and you're happy with your scene setup, go ahead and hit [Ctrl]+[F12], and start rendering!

Let me see what you've created, post a reply with a link to your creation!

No comments:

Post a Comment