Letting Blender Do the Work for You - Get Animated - Blender For Dummies (2015)

Blender For Dummies (2015)

Part III

Get Animated

Chapter 13

Letting Blender Do the Work for You

In This Chapter

arrow Playing with particles

arrow Simulating physics with soft body and rigid body dynamics

arrow Working with cloth simulation

arrow Creating fluid animations with Blender’s fluid simulator

When animating, some actions are difficult or very time consuming to get right, such as explosions, fire, hair, cloth, and physics-related actions like moving fluids and bouncing objects. In order to get these actions to look right, one solution is to let the computer do the work and create a simulation of that action. You use variables like gravity and mass to define the environment, and the computer calculates how the objects in the scene behave based on the values you set. Using the computer is a great way to get nearly accurate motion without the need to key everything by hand.

That said, don’t make the mistake of thinking simulations always give you a huge time savings in animation. This assumption isn’t necessarily true, as some highly detailed simulations can take hours, or even days, to complete. Instead, think of simulations as a way to more reliably animate detailed, physically accurate motion better than you might be able to do by hand alone. If you look at the process while wearing your “business hat,” paying for a computer to crunch through a simulation is cheaper than paying for an artist to create it manually.

remember This chapter only scratches the surface of what you can do with the simulation tools in Blender, so you should certainly look at additional resources, such as Blender’s official online documentation and the wide variety of online tutorials from the community, particularly those on www.blendercookie.com and www.blenderdiplom.com to get a full understanding of how each feature works. But hopefully, this chapter gives you an idea of the possibilities you have at hand.

Using Particles in Blender

Blender has had an integrated particle system from its early beginnings. Over the years, though, it has grown and matured into a much more powerful system for creating particle-based effects like hair, flock/swarm behavior, and explosions. And the particle system gets more and more powerful with every release.

The controls for Blender’s particle systems live in Particle Properties, as shown in Figure 13-1. Initially, this section looks pretty barren, with just a single list box. However, if you have a Mesh object selected and click the Plus (+) button to the right of the list box, a whole explosion of additional panels for controlling particle behavior appear. Adding a particle system in Particle Properties also adds a Particle System modifier to your object. Technically, you can create your new particle system from Modifiers Properties as well, but it's better to do it from Particle Properties, because that's where all of the particle controls live.

image

Figure 13-1: Left-click the Particle Properties icon to bring up the particle control panels.

Knowing what particle systems are good for

Particle systems have a handful of good uses. Each use involves large numbers of individual objects that share some general behavior. Consequently, particle systems are ideal for groups of objects that move according to physics, such as fireworks or tennis balls being continuously shot at a wall. Particle systems are also good for simulating hair and fur. If the path along which an individual particle travels was to be considered a strand, you could use groups of these particle strands to make hair. This technique is exactly what Blender does.

There’s also one other use for particle systems: simple flocking or crowd simulation. Say that you want to have a swarm of gnats constantly buzzing around your character’s head. A particle system is a great way to pull off that effect. In Figure 13-1, a whole mess of configuration panels appear in the Particle Properties. Figure 13-2 boils these panels down and shows the most used and useful panels in this section of the Properties editor.

image

Figure 13-2: The most useful panels in the Particle Properties.

After you create your first particle system, the context panel at the top of Particle Properties gives you the broadest controls, allowing you to name your particle system or choose a different set of settings from the Particle Settings datablock. Objects in Blender can have more than one particle system and can even share the same particle system settings between objects. Beneath the Settings datablock is a Type drop-down menu that offers you two types of particle system behaviors to work with: Emitter and Hair. In most instances, you’ll probably use the Emitter type. Hair particle systems are the way to create manageable hair and fur in Blender (there's more on hair and fur later in this chapter).

If you choose Emitter, the Emission panel has some of the most important settings for controlling how many particles you have and how long they exist in your scene. Here’s a brief explanation for each value:

· Number: As the name implies, this value is the total number of particles created by the system. After the particle system generates this number of particles, it stops. You can get additional particles in more than one way, but the most straightforward (though potentially CPU-intensive) way is to increase this value.

· Start: This frame is where particles start being emitted from the source object. By default, this value is set to frame 1, but if you don’t want to have your particles start until later in your animation, you can increase the value in this field. You can also set this value to be negative, so your animation starts with the particles already in motion.

· End: This frame is where Blender stops emitting particles from the source object. By default, it’s set to frame 200. With the default values for Amount and Start (1000 and 1.0, respectively), Blender creates five particles in each new frame in the animation up to frame 200 and then stops generating particles.

· Lifetime: The Lifetime value controls how long an individual particle exists in your scene. With the default value of 50.0, a particle born on frame 7 disappears from the scene when you reach frame 57. If you find that you need your particles in the scene longer, increase this value.

· Random: This value pertains specifically to the Lifetime of the particle. At its default of 0.0, it doesn’t change anything; particles live for the exact length of time stipulated by the Lifetime value and disappear, or die, at the end of that time. However, if you increase the Random value, it introduces a variation to the Lifetime option, so all the particles born on one frame disappear at different times, giving a more natural effect.

tip One additional option to pay attention to in the Emission panel is the Use Modifier Stack check box at the bottom. If you're emitting particles from a mesh on which you've used Generate modifiers (such as the Mirror modifier or the Remesh modifier), you may want to enable this check box. Otherwise, only the geometry of your base mesh will emit particles; in some cases, such as hair, that's not likely to be what you want.

You can associate any particle type (Emitter or Hair) with one of five varieties of physics simulation models stipulated in the Physics panel: No physics, Newtonian, Keyed, Boids, and Fluid. Very rarely do you have a need to use the No option, but it’s good to have. Typically, the default Newtonian setting is the most useful option because it tends to accurately simulate real-world physical attributes, such as gravity, mass, and velocity. Occasionally, though, you may want to have more explicit control over your particles, such as when you’re shaping the hair on a character. This is where Keyed physics come into play. You can use the emitter object of one particle system to control the angle and direction of another one. The Boids option tells your particles to have flocking or swarming behavior, and you get a set of settings and panels to control that behavior. The last option, Fluid, is a physics-based choice similar to the Newtonian option, but particles have greater cohesive and adhesive properties that make them behave like part of a fluid system.

To create a basic particle system, use the following steps:

1. Add a mesh to work as your particle emitter (Shift+A⇒Mesh⇒Grid).

In this example, I use a simple grid, but really any mesh works. The key thing to remember is that, by default, particles are emitted from the faces of your mesh and move away from the face in the direction of that face’s normal.

2. Navigate to Particle Properties and add a new particle system.

After you click the Plus (+) button next to the particles list box, all the options available to particles become visible. If you try to play back the animation now (Alt+A), you see particles dropping from your grid.

remember While your particles play, look at your Timeline. Along the bottom edge of the timeline is a red bar. Some of that bar may be solid, while the rest is semi-transparent. This is your particle cache, or the movement in your particle system that Blender has stored in memory. Working with particle caches is a bit of an advanced topic, but the main thing to know is that when your timeline cursor is not in the solid red area, that moment in time for your particle system has not yet been cached. The result is that it may not be accurate to your final results and it may play back slower than the cached part. The cache will be updated with any major changes that you make in Particle Properties.

3. Decide what type of physics you would like to have controlling your particles.

Newtonian physics are usually the most common type of particle system used, but I’m also pretty fond of the Boids behavior for emitter particle systems. It just looks cool, and they’re a lot of fun!

4. Adjust the velocity settings to control particle behavior.

You change this setting from the Velocity panel in Particle Properties. For Newtonian physics, you can give your particles an initial velocity. I tend to adjust the Normal velocity first because it gives the most immediate results. Values above 0 go in the direction of each face’s normals, whereas values below zero go in the opposite direction. Boid particles don’t require an initial velocity, but the settings do adjust how each Boid particle interacts with its neighboring particles.

5. Play back the animation to watch the particles move (Alt+A).

If you followed the tip in Step 2, you could be playing your particle animation already. If not, press Alt+A and see what your settings make the particles do. If your particles start behaving in erratic or unexpected ways, it’s a good idea to make sure that your time cursor in the Timeline is at or before the frame you entered for the Start value in the Emission panel when you start the animation playback.

Watch how your particles move and behave. You can now either tweak the particle movement during playback, or if it’s more comfortable for you, press Esc to stop the playback and adjust your settings before playing the animation again. I usually use a combination of live adjustments and this back-and-forth tweaking to refine my particle system’s behavior.

Figure 13-3 shows the preceding process. Bear in mind that these steps show a very basic particle system setup, and you’re just barely scratching the surface of what’s possible. I definitely recommend that you take some time to play with each of the settings and figure out what they do, as well as read some of the more in-depth documentation on particles in Blender’s online documentation.

image

Figure 13-3: Creating a basic particle system.

tip If you change a lot of settings, it's a good practice to go back to frame 1 and replay your animation with Alt+A to cache your particle system from the beginning instead of from just the previous frame.

Using force fields and collisions

After you create a basic particle system, you can have a little bit of fun with it, controlling the behavior of your particles. You control this behavior by using forces and deflectors. A force field is a controlling influence on the overall behavior of the particles, such as wind, vortices, and magnetism. In contrast, you can define collision objects, or deflectors, for your particles to collide with and impede their progress. Generally speaking, forces are defined using specialized empties, whereas deflectors are created with meshes.

All the controls for forces and deflectors live in Physics Properties, accessed by left-clicking the last button in the Properties editor’s header. Its icon looks a bit like a blue check mark with a white circle at the end of it; it’s really a visualization of a bouncing white ball. For particle force fields, left-click the Force Fields button, and a Force Fields panel appears. If you need collision settings, left-click the Collision button, and the Collision panel appears.

remember You typically use these panels to add force and collision behaviors to objects that are already in your scene. You select an object and then, from Physics Properties, add force field and collision properties to that object. For force fields, however, you can add them in a slightly faster way: from Blender’s Add menu in the 3D View. If you press Shift+A⇒Force Field, you get a whole list of forces that you can add to your scene. Then you can just adjust the settings for your chosen force from the Force Fields panel in Physics Properties.

Now, I could go through each and every option available for force fields exhaustively, but things usually make more sense if you have an example to work with. That being the case, use the following steps to create a particle system that creates particles influenced by a wind force that causes them to collide with a wall and then bounce off of it:

1. Create a simple particle system.

If you need a refresher, use the steps in the preceding section to create a basic emitter particle system with Newtonian physics.

2. Add a Wind force field (Shift+A⇒Force Field⇒Wind).

Notice that the Wind force field object looks like an Empty with circles arranged along its local Z-axis. This visual cue lets you know the strength and direction of your wind force. Increasing the Strength value in the Force Fields panel spaces out the four circles to help show how much wind you’re creating. Play back the animation (Alt+A) to see how your wind is affecting the movements of the particles. While playing your animation, if you rotate your Wind object or adjust its force field settings, the particles are affected in real time. Neat, huh?

tip For the remaining steps, you don't have to stop the animation of your particle system. Let it keep playing. This is one of the benefits of Blender's non-blocking philosophy. As you add and change things in your scene, the particle system updates and reacts in real time.

3. Add a plane (Shift+A⇒Mesh⇒Plane).

This plane is your deflector. Grab the plane (G) and move it so that it’s in the path of the particles pushed by your wind force. Rotate (R) the plane to make sure that the particles actually run into it head-on.

4. Make the plane a Collision object.

With your plane still selected, add a Collision panel in Physics Properties. Whammo! You made a deflector! If you play back the animation (Alt+A) — or if you've been playing the animation the whole time — your particles should be blown by your wind force into your plane, which they should bounce off of rather than shoot straight through.

Figure 13-4 shows the results of this step-by-step process. And like the section preceding this one, you’re just seeing the tip of the iceberg in terms of what’s possible with forces and deflectors. You can use all sorts of cool forces and settings to get some very unique behavior out of your particle systems.

image

Figure 13-4: Creating a wind force that blows your particles into a plane, which they bounce off of.

Using particles for hair and fur

It would be remiss of me to cover particles and not say anything about Blender’s hair and fur system. Blender uses particles to create hair and fur for your characters. As you may have guessed, you choose Hair as the type of particle system you want from the context panel at the top of Particle Properties. From there, the setup is roughly the same as using a regular emitter system with Newtonian physics, but with two notable differences.

The first difference is that Hair particles are, in some ways, easier to edit than emitter particles because you can use Blender’s Particle mode to customize and comb your particle hair. When you start combing in Particle mode, Blender freezes the particle settings that you already set, and you can tweak and customize the hair from there. Figure 13-5 shows a screenshot of an object with particle hair being combed in Particle mode.

image

Figure 13-5: Combing hair in Particle mode. Suzanne looks so wise with a moustache and beard!

tip If you decide that you don’t like the results you created in Particle mode, you can always reset your hair particles to their positions defined by the settings in Particle Properties. To reset your hair particles, left-click the Free Edit button in the context panel of Particle Properties. If you haven’t edited your hair in Particle mode, this button isn’t visible. But after you start combing, the button appears so that you can easily reset everything.

You switch to Particle mode by using the Mode menu in the 3D View’s header or (if you have the Pie Menus add-on enabled) by selecting a menu option when you press Tab. With your emitter object selected, switch into Particle Mode. When you’re in Particle mode, you have the ability to directly edit particle hair, including combing, cutting, growing, and smoothing it out. To see these controls, look to the Tools tab of the Tool Shelf (T). Particle Mode gives you a circular brush like the one used in Sculpting and Vertex Paint modes. You can adjust the brush’s size and strength using the sliders from the Tool Shelf or by pressing F and Shift+F, respectively.

The other thing that differs in the setup of hair particles is the use of child particles. Creating and displaying hair particles can take up a lot of computing power. When animating, you don’t necessarily want to be waiting on Blender to draw all your character’s fur in the 3D View. To deal with this problem, you have two solutions, and the results are best when they’re used together. The first thing is to reduce the number of viewable particles in the 3D View using the Display slider in the Display panel of Particle Properties. The Display slider changes the percentage of particles being displayed in the 3D View. When you make this change, fewer particles show up in the 3D View, but all of them appear when you render. You get the best of both worlds.

Of course, for characters with a lot of hair, just reducing the displayable particles may not be enough. In this case, child particles are useful. In the Children panel of Particle Properties, left-click the Interpolated button. Additional particle strands grow from the faces of your emitter, with their locations determined by the particles around them. The Children panel has two amount values on the left column: Display and Render. The Display value dictates how many particles are seen in the 3D View. For speed while animating, I often set this value to 0. The Render value controls the number of child particles that each parent particle has at render time.

remember In both Blender Internal and Cycles, Rendered viewport shading (Shift+Z) uses the preview display values for particles. They don't use the render values. This means that, if you're using a display percentage in the Display panel that's less than 100%, Rendered viewport shading isn't showing you an exact depiction of your final render. The same goes for the Display and Render values in the Children panel: Rendered viewport shading uses the Display value, not the Render value.

Rendering hair in Blender Internal

With the particle system properly generating your hairs, the only thing you have to worry about now is controlling how Blender renders this hair. Of course, because Blender ships with two render engines, the process depends on the renderer you're using. Here’s a quick-and-dirty rundown of the steps I go through to get the hair to render nicely using the Blender Internal (BI) renderer:

1. Enable the Strand render check box in the Render panel of Particle Properties.

This step tells Blender’s rendering engine to render the particles as strands.

tip Another helpful option in this panel is the Emitter check box near the top. Enabling this option makes the emitter visible, a helpful feature if you’re using your actual character mesh to generate the hair.

2. In Material Properties, enable Transparency and verify that Z Transparency is being used; set your Alpha value in the Transparency panel to 0.

If you’re using the Hair strands preview type in the Preview panel (I recommend doing so), you may notice that your hair is virtually non-existent because of the 0 Alpha value. Don’t worry: This setting makes sense in the next couple of steps.

3. In Texture Properties, add a new Blend texture and use the Ramp editor in the Colors panel to control the color and transparency along the length of the hair.

The most important thing here is that the right-hand side of the ramp represents the tip of your hair strand and should therefore be completely transparent. All other color positions in it should be opaque.

4. In the Mapping panel, choose Strand/Particle from the Coordinates drop-down menu.

5. In the Influence panel, enable Color and Alpha.

The Preview panel should show hair strands that use your ramp gradient along the length of each strand, feathered out to semitransparent tips.

6. Back in Material Properties, go to the Strand panel and check the settings.

A couple fields are worth mentioning:

· Make sure that the Tangent Shading check box is enabled. This gives the hair a nice shiny effect.

· Enable the Blender Units check box. By default, Blender’s hair strands are measured in pixels. Using pixels works fine except in situations where you have a hairy object move toward or away from the camera. Enabling this check box makes the hair size relative to your scene’s units (set in Scene Properties) rather than the size of your final render.

· Because you’re using the Blender Units option for hair size, you need to reduce the sizes for the Root and Tip of the hair strands. I usually use something like 0.02 and 0.01, respectively. You may need a few test renders to get it just right for your object.

· The other sliders control the shape and shading of the strands; you can adjust these to taste with a few test renders.

remember If you're going to make your emitter visible, you may also want to use a separate material for your hair particles. Otherwise, you may have to do a bunch of extra work to make sure your hair particles are the right color. If you set up a special material for your hair (perhaps using the settings I cover in the preceding steps) and name it something memorable, like Hair, you can choose that material for your particle system from the top of the Render panel in Particle Properties. There's a drop-down menu there with a list of all of your object's material slots; you can choose to use any one of those.

tip If your scene isn't too complex, you can make a lot of these material and texture changes using Rendered viewport shading (Shift+Z). It isn't quite as snappy as in Cycles, but it can be quite fast with a few optimizations (like temporarily disabling ray tracing and hiding any extraneous high-poly meshes). Faster, at least, than doing the tedious back-and-forth of test renders and settings tweaks.

Rendering hair using Cycles

If you're rendering with Cycles, the process is a bit different than with Blender Internal. In many ways, it's actually simpler. For the most part, you don't even need to leave Particles Properties. To render hair particles using Cycles, follow these basic steps:

1. At the bottom of Particle Properties, make sure that the check box for the Cycles Hair Rendering panel is enabled.

tip That's pretty much all there is to it. Seriously. The rest of the steps here are tweaking to taste.

2. Change the Primitive Style drop-down to Curve Segments.

Curves are a bit more processor intensive, but the results are worth it for smoothly flowing hair.

3. In the Cycles Hair Settings panel, adjust the Root and Tip values to suit your character.

Cycles gives nice scaling to the tips of the hair, so it isn't necessary to use the Ramped transparency trick described in the previous section.

tip For the last two steps and any adjustments that you make to your hair material (you can specify a separate hair material in Cycles, just like I described for Blender Internal in the previous section), I recommend that you use Rendered viewport shading (Shift+Z). It gives you a very accurate understanding of what your final render will look like.

Figure 13-6 shows the same particle system as Figure 13-5, but rendered in both Blender Internal and in Cycles.

image

Figure 13-6: On the left, bearded Suzanne rendered in Blender Internal. On the right, she's rendered with Cycles.

Giving Objects Some Jiggle and Bounce

Have you ever sat and watched what happens when a beach ball gets hit or bounces off of the ground? Or seen what happens when someone places a plate of gelatin on a table? Or observed how a person’s hair moves when they shake their head? When these things move and collide with other objects, they have a bit of internal jiggle that can be difficult to reproduce correctly with regular animation tools. This jiggling is the basis for what is referred to as soft body dynamics.

You can simulate soft body dynamics in Blender from Physics Properties. Left-click the Soft Body button, and a Soft Body panel appears. In that panel, you can make adjustments and tweak the behavior of your soft body simulation.

tip Like with particle systems, adding soft body dynamics to an object from Physics Properties also adds a Soft Body modifier to your object. You can verify this addition by looking in Modifier Properties.

What follows is a simple step-by-step process for creating a simple soft body simulation with the default cube object:

1. Select the default cube with a right-click and grab it up in the Z-axis so that it floats above the 3D grid (G⇒Z).

You want to give the cube some height to fall from. It doesn’t have to be very high; 3 to 5 units should be enough.

2. Create a Plane mesh as a ground plane (Shift+A⇒Mesh⇒Plane) and scale it larger so that you have something for the cube to hit (S).

This plane is the surface for your jiggly cube to bounce off of. It may be helpful to put your 3D cursor at the origin (Shift+S⇒Cursor to Center) before adding the plane.

3. With your plane still selected, add a Collision panel in Physics Properties to give your plane collision properties.

Doing so makes Blender understand that the plane is an obstacle for your falling cube.

4. Right-click the cube to select it.

5. Make a Soft Body panel in Physics Properties.

That’s all you really have to do to enable soft body physics on your 3D objects. However, in order to get the cube to properly act according to gravity, there’s one more step. Notice that adding soft body properties to your cube reveals a bunch of new panels to Physics Properties.

6. Disable the Soft Body Goal check box next to its panel.

This step disables the default goal behavior of soft bodies. When Soft Body Goal is enabled, you can define a group of vertices in the object to be unaffected by the soft body simulation. A scenario where you may want to have Soft Body Goal enabled would be a character with loose skin, like the jowls of a large dog. You may want the dog’s snout to be completely controlled by your armature animation, but have the jowls that hang off to be influenced by soft body simulation. Because in this case with the cube you want the entire object to be affected by the simulation, it’s best just to turn it off.

7. Play back the animation (Alt+A) to watch the cube fall, hit the ground plane, and jiggle as it lands again.

Pretty cool, huh? Figure 13-7 shows this process being completed. As with particles, it’s a good practice to make sure that you’re at the start frame of your animation before playing back your simulation.

image

Figure 13-7: Dropping a jiggly cube into the scene.

Now, I have to admit that I cheated a bit in the preceding example by using a cube. If you were to try those steps with another type of mesh, like a UV Sphere or Suzanne, the mesh would collapse and look like it instantly deflated when it hit the ground plane. In order to get around this issue, you need to adjust one more setting. In the Soft Body Edges panel on the left column of values is a setting labeled Bending with a default value of 0.00. This value sets the bending stiffness of your object. With a setting of zero, you have no stiffness, so the mesh collapses. However, if you change this setting to a higher value, such as 3.0 or 5.0, the falling mesh retains its shape a little bit better when it collides with the ground plane. You can also enable the Stiff Quads check box in this panel to get your mesh to retain its shape even better, but be careful: This setting slows down the soft body calculation substantially.

remember Similar to particles, if you look in the Timeline when you play your soft body simulation, you should see an orange bar along the bottom. If the orange bar is opaque, Blender has cached that part of the simulation. If it's semi-transparent, that moment in time has not yet been cached. Cached simulation data will play at a rate that's closer to real time. To get a good idea of the timing of your simulation, let it play through all the way once, ensuring that the simulation gets cached. When you play it again, you should get a much more reasonable sense of the simulation's timing.

tip For any physics-related simulations in Blender, keep interacting objects (such as particle colliders, or obstacles for rigid bodies and fluids) on the same scene layers. That's a hint to Blender that these objects are meant to interact with one another. For example, if you have a soft body object and a plane as its floor on two different scene layers, the soft body will just run right through the floor without stopping.

Dropping Objects in a Scene with Rigid Body Dynamics

Not everything that reacts to physics has the internal jiggle and bounce that soft bodies have. Say, for example, that you have to animate a stack of heavy steel girders falling down at a construction site. For that animation, you don’t want to have a soft body simulation. I mean, you could technically get the correct behavior with really stiff settings in the Soft Body Edges panel, but that’s a bit of a kludge and potentially very CPU-intensive. You’d be better off with rigid body dynamics. As their name implies, rigid bodies don’t get warped by collisions the way that soft bodies do. They either hold their form when they collide, or they break.

newversion Like the other physical simulation types, the controls for rigid bodies are in Physics Properties. Previously, this wasn't the case. It used to be that you needed to bake rigid body simulations from Blender's internal game engine. That's no longer necessary. You need only left-click the Rigid Body button.

Use the following steps to get a simple rigid body simulation with the default cube:

1. Select the cube by right-clicking and grab it up in the Z-axis by a few units (G⇒Z).

Like the soft body simulation, 3 to 5 units should be fine.

2. Create a mesh plane to act as the ground (Shift+A⇒Mesh⇒Plane) and scale it larger so that you have something for the cube to hit (S).

3. With your plane still selected, add a Rigid Body panel in Physics Properties.

Unlike the soft bodies example, your ground plane should not get a collision panel. This is unique to how rigid bodies work in Blender.

4. In your newly-created Rigid Body panel, change the Type drop-down menu from Active to Passive.

This tells Blender that the ground plane should be part of the rigid body calculations, but that it isn't going to be a moving object. Setting the type to Passive is basically how you set up a rigid body collier.

5. Right-click the cube to select it.

6. Make a Rigid Body panel in Physics Properties.

That's the last step that's really required to have your cube drop into the scene. You may want to give the cube a bit of an arbitrary rotation (R⇒R) so it lands and bounces around on the plane in a more interesting way.

7. Play back the animation (Alt+A) to watch the cube fall, hit the ground plane, and bounce around a bit.

Congratulations! You have a rigid body simulation.

Figure 13-8 shows a breakdown of the preceding steps.

image

Figure 13-8: Creating a simple rigid body simulation.

Simulating Cloth

Cloth simulation and soft body simulation are very similar in Blender, despite a few key differences. Both soft bodies and cloth work on open as well as closed meshes — that is, the mesh could be flat like a plane or more of a shell like a cube or sphere. However, soft bodies tend to work better on closed meshes, whereas cloth is better suited for open ones.

Also, the cloth simulator tends to work better with self collisions. Think about the fabric of a flowing dress. In the real world, if you bunch up part of a dress, it’s technically colliding with itself. In computer simulations, you want to re-create that effect; otherwise, the fold of one part of the dress breaks through the fold of another part, giving you a completely unrealistic result. The cloth simulator handles these situations much better than the soft body simulator.

Revisiting the simple default cube, here’s a quick walk-through on getting some cloth to drape across it:

1. Create a mesh Grid (Shift+A⇒Mesh⇒Grid) and grab it along the Z-axis (G⇒Z) so that it’s above the default cube.

2. Scale the Grid so it’s larger than the Cube (S).

It doesn’t have to be too high; just a couple of units should be plenty.

3. Apply smooth shading to the grid (Tool Shelf⇒Shading⇒Smooth).

This step is really just to make it look prettier. It has no effect on the actual simulation.

4. Apply a Subdivision Surfaces modifier to the plane (Ctrl+1).

The simulator now has even more vertices to work with. Of course, adding subdivisions causes the simulation to take longer, but this amount should be fine. It's important that you do this before adding cloth properties to your mesh. Like many other simulators, cloth is added in Blender as a modifier, and the order in the modifier stack is important.

5. In Physics Properties, left-click the Cloth button to enable the cloth simulator.

The default preset for the cloth simulator is Cotton. That preset should work fine here, but feel free to play and change to something else.

6. In the Cloth Collision panel, enable the Self Collision check box.

This step ensures that the simulator does everything it can to prevent the cloth from intersecting with itself.

At this point, your cloth simulation is all set up for the plane. However, if you were to play the animation with Alt+A right now, the plane would drop right through the cube. You want the cube to behave as an obstacle, so follow the next steps.

7. Select the cube object (right-click) and left-click the Collision button in Physics Properties.

Collision properties appear for your cube. Your simulation is set up.

8. Press Alt+A to watch the cloth simulate.

Figure 13-9 shows what the results of this process should look like. It’s a good idea to set your time cursor at the start of your animation in the Timeline before playing back the simulation.

image

Figure 13-9: Creating a simple cloth simulation.

remember As with the other simulation types in Blender, if you look in the Timeline when you play your soft body simulation, you should notice a bar along the bottom. In the case of cloth simulation, that bar is blue. If it's opaque, Blender has cached that part of the simulation. If it's semi-transparent, that moment in time has not yet been cached. To get a good idea of the timing of your simulation, let it play through all the way once, ensuring that the simulation gets cached. On the second time playing, you should get a much more reasonable sense of the simulation's timing.

Splashing Fluids in Your Scene

In my opinion, an especially fun feature in Blender is its integrated fluid simulator. This thing is just really cool and a ton of fun to play with, to boot.

Before running head-long into fluid simulation-land, however, you should know a few things that are different about the fluid simulator. Like most of the other physics simulation controls, the main controls for the fluid simulator are in Physics Properties. However, unlike particle, cloth, and soft body simulations, which can technically work in an infinite amount of space, the fluid simulator requires a domain, or world, for the simulation to take place.

tip Another difference is that the fluid simulator actually creates a separate mesh for each and every frame of animation that it simulates. Because of the detail involved in a fluid, these meshes can get to be quite large and take up a lot of memory. To account for that size, the fluid simulator actually saves these meshes to your hard drive in .bobj.gz files. The other simulation systems can also save data to your hard drive, but because fluid simulation data can take up an enormous amount of hard drive space, you need to explicitly tell Blender where to save these files. The whole fluid simulation can't be cached in RAM. Because these files can get pretty large, it’s a good idea to confirm that you have plenty of hard drive space available for storing your simulation.

The fluid simulator has all the other features of the other physics simulators. It recognizes gravity, understands static and animated collisions, and has a wide array of available controls.

Use these steps to create a simple fluid simulation:

1. Right-click the default cube and scale (S) it larger.

This cube serves as your simulation’s domain. The domain can actually be any shape or size, but I definitely recommend that you use a cube or box shape as the domain. Other meshes just use their width and height, or bounding box, so it's essentially a cube anyway. In this example, I scaled the default cube by 5 units.

2. In Physics Properties, left-click the Fluid button and choose Domain from the Type drop-down menu.

Now the fluid simulator recognizes your cube as the domain for the simulation. Figure 13-10 shows the Fluid panel with the Domain option from the Type drop-down menu.

3. Set the location where simulation meshes are saved.

Use the text field at the bottom of the Fluid panel. By default, Blender sends the .bobj.gz files to their own folder the /tmp directory. However, I recommend you create your own folder somewhere else on your hard drive, especially if you’re using Windows and don’t have a /tmp directory. Left-click the folder icon to navigate to that location with the File Browser.

4. Decide at which resolution you would like to bake the simulation.

These values are set with the Final and Preview values under the Resolution label. The Final resolution setting is the value that is used when you render. Typically, it’s a higher number than the Preview resolution, which is usually used in the 3D View. For the Preview value, you want a smaller number so that you can get your timing correct. The defaults should work fine for this example, although higher values would look better. Be careful, though, depending on the type of machine you’re using: very large values may try to use more RAM than your computer has, bringing the simulation time to a crawl.

tip Conveniently, the Bake button at the top of the Fluid panel gives you an estimation of how much memory it expects to need. As long as that is less than the amount of RAM your computer has available, you should be good to go (though you may still wait quite a while for a simulation to finish. Blender still has to calculate the simulation for all those subdivisions).

warning Blender's fluid simulator gives you the ability to use multiple threads, or processing streams on your computer. If you have a modern computer with multiple cores, you can take advantage of this feature. However — and this is a pretty big however — each thread requires a separate copy of your simulation data. This means that whatever number the fluid simulator is estimating for the amount of RAM it needs, you must multiply it by the number of threads. So if you've set up a simulation with a resolution that uses 1 GB of memory and you set the Simulation Threads value to 4, then you'll actually need 4 GB of memory to do that simulation.

5. Determine the time that you want to simulate the fluid’s behavior.

The Start and End values under the Time label in the Fluid panel are the time of the simulation, measured in seconds. By default, the simulator starts at 0.000 and runs until 4.000 seconds. An important thing to realize here is that this time is scaled across the full number of frames in your animation, as noted in the Timeline or the Dimensions panel of Render Properties. If you’re using Blender’s default frame rate of 24 fps and length of 250 frames, your simulation will be in slow motion, showing 4 seconds of fluid simulation over a span of roughly 10.4 seconds. For this test, I set the End time in the Fluid simulator to 3.000 seconds and the duration of the animation to be 72 frames long.

6. Create a mesh to act as the fluid in your simulation (Shift+A⇒Mesh⇒Icosphere).

I typically like to use an icosphere, but any mesh will work. To give yourself some more room, you may also want to move this mesh up the Z-axis (G⇒Z) to somewhere near the top of the domain cube so that you have some room for the fluid to fall.

7. In Physics Properties, left-click the Fluid button and choose Inflow Type from the drop-down menu.

Your icosphere is set as the source for the fluids entering the domain. Choosing Inflow means that the mesh constantly produces more and more fluid as the simulation goes on. If you prefer to have a single fluid object with a fixed volume, choose Fluid rather than Inflow. Figure 13-11 shows the Fluid panel with the Inflow fluid type chosen.

8. (Optional) Give the Inflow object an initial velocity in the negative Z direction.

This step is optional because the fluid simulator does recognize the Gravity setting in Scene Properties. Adding an initial force in the negative Z direction here just gives it a little extra push. The value doesn’t have to be large: -0.10 should work just fine. You want to make this value negative so that it pushes the fluid down. This initial velocity is added to the force already set by gravity. At this point, your simulation is configured.

9. Select the domain cube (right-click) and bake the simulation.

Left-click the large Bake button in the Fluid panel. I know that this sounds odd — “Baking fluids? Really? Won’t it boil?” — but that’s the terminology used. You’re running the simulation for each frame and “baking” that frame’s simulation result to a mesh that’s saved on your hard drive. If you look at it in that way, it kind of makes sense.

10. Watch the progress of the fluid simulation.

Depending on how powerful your computer is, this baking process can be pretty time consuming. I once had a 4-second fluid simulation that took 36 hours to bake. (Granted, it was at a high resolution, and I had a lot of crazy Inflow objects and complex moving obstacles, so it was entirely my own fault.) Just know that the more complexity you add to your simulation and the higher the resolution, the more time it’s going to take. As the progress bar at the top of the screen shows your simulation processing, you can interactively follow progress in the 3D View. Remember that Blender has a non-blocking interface, so you can actually scrub the Timeline, use the ←/→ hotkeys, and even play back the animation (Alt+A) while Blender is still baking. How’s that for cool?

11. Play back the finished simulation with Alt+A.

One thing to note here is that your mesh looks faceted. You can easily fix this issue by left-clicking the Smooth button beneath the Shading label in the Tools tab of the Tool Shelf.

image

Figure 13-10: The Fluid panel with options for a domain object.

image

Figure 13-11: The Fluid panel with options for an inflow object.

And, POW: You have water pouring into your scene! Using these same basic steps, you can add obstacles to the scene that can move the water around as you see fit.

Knowing when to use the right type of fluids

Blender’s particle system also offers a way to do fluid simulation by choosing the Fluid physics type from the Physics panel in Particle Properties. And because that choice is available, you may find yourself wondering why you’d use this mesh-based method when that one is available. The short answer is that it all depends on what you’re trying to do. For example, the particle-based fluid technique is useful if you need your fluids to interact with Blender’s other simulators (force fields, cloth, and so on) or if you’re simulating large-scale fluids that don’t quite fit in the constraints of a 10-meter cube. The particle-based method is not so great, however, for detailed small-scale fluid simulations or if you need to use materials with ray traced transparency or shadows. The particle-based technique doesn’t currently generate meshes where you can apply those materials (though that's likely to change in future releases of Blender). For those situations, the fluid simulation technique covered in this section is more useful.

Smoking without Hurting Your Lungs: Smoke Simulation in Blender

In addition to all the other cool physics simulation goodies that come bundled with Blender, you can also do smoke and fire simulations. The process for setting up the smoke simulator is in some ways very similar to the fluid simulator in that it requires that you set up a domain object (under the hood, the algorithms for the two are pretty similar). However, that's where the similarities end. For one, the smoke simulator doesn't generate mesh objects, so you're not compelled to find a clean chunk of hard drive space to store your simulation data. And a much bigger difference becomes apparent when you get down to trying to render the smoke.

First, however, you need to set up your initial smoke simulation. Use the following steps:

1. From the default scene, scale the cube up.

For this example, scaling by a factor of 5 should be fine (S⇒5⇒Enter).

2. From Physics Properties, left-click the Smoke button to create a Smoke panel.

3. In your new Smoke panel, left-click the Domain button.

When you click this button, Blender knows to treat your cube as a smoke domain. The cube automatically changes to wireframe display in the 3D View and you get a whole bunch of additional panels in Physics Properties. For now, you can leave all of these settings at their defaults. Figure 13-12 shows the panels for a smoke domain.

4. Back in the 3D View, add a simple mesh and lower it a bit (Shift+A⇒Icosphere, G⇒Z⇒-3⇒Enter).

This object will be your smoke source. And your smoke naturally will float up, so it makes sense to lower your object a bit to give the smoke some room to show up.

5. In Physics Properties, add a Smoke panel.

6. In your new Smoke panel, left-click the Flow button.

This establishes your smaller object as your smoke source. As Figure 13-13 shows, there are fewer panels and options for a smoke flow object than a smoke domain, but there's still quite a few. Fortunately, you can leave these settings at their defaults for now.

7. Play back your simulation with Alt+A.

Smoke should start billowing up from your flow object and stop when it reaches the faces of your smoke domain.

8. Tweak your smoke settings to taste.

There's a lot of playing that you can do here. Not only does the smoke simulator make smoke, it can simulate fire, and you can add objects to collide with the smoke in all kinds of interesting ways. You really can lose hours — perhaps days — of your life messing around with all the settings in the smoke simulator.

image

Figure 13-12: A smoke domain object has a lot of options for you to play with.

image

Figure 13-13: The panels showing the options for a smoke flow object.

Those are the basics of setting up a simple smoke simulation in Blender. As Figure 13-14 shows, the 3D View gives you a nice preview of your smoke simulation.

image

Figure 13-14: A simple smoke simulation displayed in the 3D View.

Unfortunately, if you try to render your smoke simulation as-is, you'll be disappointed. Regardless of whether you're using Blender Internal or Cycles, all you'll see is the blocky cube shape of your smoke domain. To get your smoke simulation to render, you need to make a few more improvements, as covered in the next two sections.

Rendering smoke using Blender Internal

In 3D computer graphics, smoke and fire fit into a category of materials referred to as volumetric effects. In meatspace, there's no such thing as a smoke object (a smoking object, yes, but not a smoke object). It isn't a single object. You see smoke because it's a build up (a volume) of millions of small particles floating in the air. They reflect and obstruct light. Unlike solid objects, it just isn't sufficient to render the surface of smoke and fire. The result doesn't look believable. Your renderer must support volumes.

Fortunately, both the Blender Internal and Cycles renderers have support for volumetric materials. They're just a little bit trickier to set up than regular materials. Assuming you already have a smoke simulation created to your satisfaction, follow these steps to get it to render in Blender Internal:

1. Select your smoke domain object (right-click).

2. If your smoke domain doesn't already have a material slot, add one by clicking the Plus (+) icon next to the list box at the top of Material Properties.

Your smoke domain should only have one material. If you already have a material slot in use, just use that one.

3. In the Material datablock, left-click the New button to add a new material.

Rename the material to something descriptive, like Smoke.

4. From the row of buttons under the material datablock in Material Properties, left-click the Volume button.

Clicking this button tells the Blender Internal renderer that this is a volumetric material.

5. In the Density panel of Material Properties, set the Density value to 0.

If you're watching the material preview at the top of Material Properties, the preview object should disappear, leaving only its shadow. Don't worry. This is supposed to happen.

6. Switch over to Texture Properties and add a new texture. Change its type to Voxel Data.

A voxel is a volumetric pixel. This is how Blender stores your smoke simulation. You're telling Blender to use the voxel data from your simulation as a three-dimensional texture. All you need to do is tell Blender where the simulation data is and how it influences the material's appearance. Those are the next steps.

7. In the Voxel Data panel of Texture Properties, make sure the File Format drop-down menu is set to Smoke and fill in the Domain Object field with the name of your smoke domain.

If you gave your smoke domain a descriptive name, it should be easy to find in the Domain Object field. If not, press E with your mouse cursor hovered over the field to enable the eyedropper, then left-click on your smoke domain in the 3D View to pick it.

8. In the Mapping panel of Texture Properties, change the Coordinates drop-down menu to use Generated coordinates.

9. In the Influence panel of Texture Properties, enable the check box next to the Density slider.

This maps the voxel data from your smoke simulation to the Density property of your volumetric material.

10. Render your smoke material (F12) or enable Rendered viewport shading in your 3D View (Shift+Z).

There you have it! Your rendered smoke has the same basic smoke effect you see in the 3D View. From here, you can do all kinds of tweaks to your material settings to further customize your smoke material.

Figure 13-15 shows a simple smoke simulation rendered using Blender Internal.

image

Figure 13-15: Blender Internal renders smoke!

Rendering smoke using Cycles

Blender's other renderer, Cycles, can also render your smoke simulation. The basic principle is still the same. Your goal is to map the data from your simulation to a volumetric shader. Use the following steps:

1. Select your smoke domain object (right-click).

2. If your smoke domain doesn't already have a material slot, add one by clicking the Plus (+) icon next to the list box at the top of Material Properties.

Your smoke domain should only have one material. If you already have a material slot in use, just use that one.

3. In the Material datablock, left-click the New button to add a new material.

Rename the material to something descriptive, like Smoke. From this point, you could continue to work in Material Properties, but it's much easier to see what's going on from the Node Editor.

4. Split the 3D View and change one of the new areas into a Node Editor.

Make sure you're using the Shader node tree type. It's the leftmost button of the node tree type button blocks; the one with the same icon as Material Properties in the Properties editor. For more on using the Node Editor for materials, see Chapter 7.

5. In the Node Editor, select the Diffuse BSDF shader node and delete it (right-click the node, X).

6. Add a Volume Absorption shader (Shift+A⇒Shader⇒Volume Absorption) and wire it to the Volume socket of the Material Output node.

If you're looking at your 3D View in Rendered viewport shading (Shift+Z), your smoke domain should appear as a kind of smokey cube.

7. Add an Attribute node (Shift+A⇒Input⇒Attribute) and wire its Fac socket to the Density input socket of the Volume Absorption node.

If you're still looking at your 3D View in Rendered viewport shading, your smoke domain should disappear. Not to worry, I told you that there was a tricky part. It's the next step.

8. In the Name field of the Attribute node, type density.

And poof! (Pun intended.) You have smoke in your render. From here, you can tweak colors and other attributes of your material to land on the visual effect that you want. For instance, you may want to try the following steps to incorporate the Volume Scatter node to your material network.

9. Add a Volume Scatter shader (Shift+A⇒Shader⇒Volume Scatter).

10. Wire the Fac socket of your density Attribute node to the Density socket on your new Volume Scatter node.

11. Add an Add Shader (Shift+A⇒Shader⇒Add Shader).

The plan here is to mix the two volume shaders together.

12. Wire your Volume Absorption node to one socket of your Add Shader node and wire your Volume Scatter node to the other socket on the Add Shader node.

13. Wire the output of your Add Shader node to the Volume socket of the Material Output node.

Steps 9-13 make your smoke material disperse light and cast shadows in a more realistic way.

Figure 13-16 shows a screenshot of Blender with a simple smoke material in the Node Editor and shows the results of that material in the 3D View with Rendered viewport shading.

image

Figure 13-16: Setting up a basic smoke material in Cycles is pretty easy.