PainfulUrination.com

 

Maya Tutorial

Particles and Dynamics

Intermediate Level

Dariush Derakhshani

 

Cigarette Smokin’ Babies

 

            The door lock suddenly makes a familiar sound.  Her key forces the tumblers into alignment and the door swings open, casting an unexpected swatch of air to disrupt Koosh’s cigarette smoke flow.  She’s carrying a precarious bag of groceries that she places on top of his black and blue PC tower case.

            “Do you mind,” he says eyeing the bag of primarily vegetable type food.

            “Where’d you get that?” accusing his lit cigarette as it sits on a teacup saucer on his desk smoking.

 

            Koosh pushes the retractable surface of his desk under his monitors and looks at her smiling.

            “Hi, how was your day?”

            “That’s my emergency cigarette isn’t it?”

            “No!” he says like a boy covered in chocolate denying he has had any chocolate.

            A pause.

            “What am I gonna do if I’m having an emergency?” Vicki stammers.

 

            Koosh turns back to his system and pulls out the desk surface.  “Smoke a carrot.”

 

            She picks up her bag and takes it around him and into their small kitchen.  “I never liked you,” she torts back to him.  “If you’re gonna use my emergency cigarette, at least have the decency to smoke the thing and not let it sit there lonely.”

            “It’s a reference.  I’m doing a particle effect.”

            “Particle effect of what?”

            “Duh, a cigarette smoke.”

            “And for that you needed my emergency cigarette?” She points a loaded carrot at him.  “What if I’m suddenly thrust in front of a firing squad?  I’ll have no cigarette, thanks to you.”

            But it’s too late; he’s tuned Vicki out in favor of his Maya’s perspective window, which is currently a blank sheet of pixels.

 

            A loud bite of a carrot precedes her question, “hardware rendered or software?”

 

            “I’m doing this with hardware rendered particles.”

            “Hardware sucks,” she says as she turns back to her dinner making.

            “Well I want a thing wisp of smoke, and the software particles can look blotchy if you’re not really careful, and I wanna do this real fast, so bugger off.”  He sounded stupid saying, “bugger off” since he’s not English.

 

            Notwithstanding, Koosh begins by creating an emitter by going to the Dynamics module of Maya, and then selecting Particles>Create Emitter.  By using a directional emitter, he’d be able to control the direction of the particles and their cone of emission.  He sets the direction to 0,1,0 so the particles will be emitted up, in the Y direction.  The spread attribute governs the width of the emission cone, sort of like the nozzle of a spray hose defines the width of the spray.  He starts with a spread of 0.2, to emit the particles in a very thin cone, seeing as 0 would give him strictly a single file line.

The emission rate and speed he leaves as the default 100, cause he’s crazy like that.  The emission rate corresponds to the number of particles being emitted in a single unit of time, which in this instance is 1 second over 24 frames.  The speed he’s gonna have to tinker with till he gets just the right number.  This attribute regulates how fast the particles are emitted.  Figure 1.

Figure 1

    

         He slings himself back in the lumpy burgundy chair his Croatian architect friend “acquired” for him years ago, and stares at the smoke coming from the cigarette.  As it rises in its column of heated air, it’s batted around on all sides by cooler air surrounding it.  The higher the smoke rises, the slower and the more faint and spread out it gets.  He takes a sip from his short glass of gin and tonic, comparing the movement of the real smoke to his particles in the playblast window.

            “Would you mind not chopping carrots so loudly,” Koosh asks.

            “I’m done with the carrots,” with a final loud chop.  “Now what if I accidentally chopped off my finger and I needed a cigarette to calm me down while we waited for the ambulance to come?”

            It was a rhetorical question, but Koosh decided to answer anyway, “I would douse your stump with my gin to disinfect it, grab the finger off the floor before the cats get at it, and duct tape it back on and give you cab fare to the hospital.”

            Not even paying the slightest mind to his sarcasm, “what are you doing this for, anyway, can’t they just shoot a live cigarette?”

            “I don’t think they want a baby holding a lit cigarette in the spot, so they want CGI smoke coming from the one it’s got.”

            “Why is there a baby holding a cigarette?  Isn’t that illegal?”

            He looks at her.  “I don’t think so, and I’m sure it’s a fake cigarette it’s holding.”

            “Why do you always refer to babies as it?” she mutters, turning to the counter to begin chopping something light green now.

            “Hey I don’t make these decisions, I just make stuff move.  Weren’t you supposed to bugger off a minute ago?”  He still sounded stupid saying, “bugger off.”

     After fiddling with the speed settings, Koosh settles on a speed of 0.3, and a Speed Random setting of 0.5, which will give some of the particles a slightly different speed, which is always a good thing.  Now, the particles are slightly different in speed, but are all traveling in an almost straight line up.  Figure 2.

     By adding a turbulence field to his particles, he’ll be able to give them a bit of a random movement.  A field, being an object in Maya that helps regulate the movement of particles once they have been emitted, can make a wisp of particle smoke subtly affected by pockets of moving air, to simulate real life forces of nature.  He selects the particles and clicks on Fields>Turbulence.

     By selecting the particles first, the field will automatically be connected to them.  It is possible to simply create a field, however, and attach it to a particle object or objects through the Dynamic Relationships Editor.  Regardless of how, though, a field must be connected to a particle (or other dynamic object) to be effective.
Figure 2

Now finding the right settings for the turbulence (and subsequent fields to control the particle smoke) is where the sweat gets poured.  Now that he’s created the field, he sits back, sips his gin and hits play in the playback controls to see what happens with the default settings.

 

“Well that looks like cigarette smoke,” he hears from behind his back followed quickly by a carrot crunching bite.

            “You don’t heckle animators,” he apprises her.  “Go watch Animal Planet, will you?  I’m sure there’s some sort of dog mending show on right now.”  He decided wisely not to use “bugger off” again.

 

     He leans back into his desk.  Koosh has to animate the turbulence settings to get the best result, so he sets his animation clip to be 360 frames long.  Starting at the first frame of 1, he right clicks on the magnitude attribute of the turbulence field (which is set to 5) and chooses key selected from the context menu that appears.  This turns his magnitude attribute orange in the channel editor, the mark of an animated attribute.  He scrubs his animation to frame 80 and sets a keyframe for a magnitude of 4; then a key of 6 at frame 110 and then 3 at 160 and finally back to 5 at frame 210.  Figure 3.

Figure 3

            He rewinds the animation back to frame 1.  With dynamics the animation must play from the beginning of the simulation for the result to be accurate.  Scrubbing the animation for a dynamic simulation will get weird results, and quite frankly, he doesn’t want to solicit anymore comments from Vicki.  Koosh hits play and watches all his particles being blown off the edge of the screen.  He checks to see if Vicki saw that and was about to stab him with another verbal shiv.  Figure 4.

Figure 4

 

            Obviously, the particles need to be slowly wafting upwards, rising, as does real smoke coming off the emergency cigarette Vicki was so protective of.  To do this, he needs to create another field object to either push or pull the particles up.  He chooses to create a Radial Field, which he will position above the smoke to draw it in, as opposed to pushing it up.  A Radial Field will either radiate particles away from or draw toward itself.  This is achieved through the magnitude setting.  A negative number will pull radially, while a positive number will push radially.  A gravity field could also do the job of pulling the particles up (with a negative magnitude), but the radial field will also draw the particles toward it’s specific position, helping keep the particles in a nice fluid stream as opposed to making them merely lift up.

He clicks on Fields>Radial and creates his new field.  He moves it so that it is above the frame, and slightly to the left of the emitter’s Z position.  This will allow the turbulence to push the smoke toward the right (as in figure 4), and the radial will suck it back to the left, creating a nice arc of movement.

            Using the same theory used in keyframing the magnitude of the turbulence, he sets keys for the radial’s magnitude thusly: -0.5 at frame 100, -0.3 at 145, -0.5 at 260, and –0.3 at 360.  This again will help the smoke waft more realistically.  Figure 5.

Figure 5

Hitting play, he notices that the particles do not respond to his new field, prompting him to check their connection.  He clicks Window>Relationship Editors>Dynamic Relationship to open the Dynamic Relationships Window.  Figure 6.

            Clicking on his particle object on the left will select his particles.  Then turning on the Fields button above the right hand panel (which is selected by default) will display all the fields in the scene.  The ones highlighted are connected to the chosen particle object.  Having forgotten to select his particles before he created the Radial Field, Koosh needs to make the connection here, by simply clicking on the radialField1 object in the right panel.  He hits play and notices that his particles are now drawn up, instead of flying out of the frame as before.

Noticing that his reference cigarette has finally burnt down to the filter, Koosh gets up in search of something to burn.  He considers Vicki for a brief, but sweet second.

“I need to make fire and smoke!”

“Well, why don’t you burn the end of one of your fingers,” Vicki points out to him as she watches a vet staple a dog back together on TV.

            “I’ve had enough of you,” he declares, even though he knows he hasn’t and that he never would.  “Tell me where your other emergency cigarettes are, or I’ll take the remote away and force you to watch CNN.”  He snatches the remote from their hideous, toe-mangling-in-the-dark coffee table.

Figure 6

“What makes you so sure I have more?  Now, wouldn’t having another emergency cigarette stash nullify the whole premise of having an emergency cigarette when one quits?  Hmm?  Wouldn’t I just be another smoker in denial as opposed to have actually quit, if I had another stash?”

“Yes it would, Smokey Smokerton.  Now give me the others or face Wolf Blitzer.”  He had the remote in his hand, aimed and at the ready for CNN.  She knew not to get between Koosh and his particles.  “Need I remind you of the time you rolled up a nicotine patch and tried to smoke it?”

“Oh, alright,” she says reaching behind and under the sofa cushion on the right.  They exchange a remote and a crumpled pack of Parliaments as if they were cold war secret agents.  She turns back to Emergency Vets show.  “I want one,” she groans quietly, the smell of nicotine in the air driving her to angrily eat another carrot.

 

Koosh, back at his desk, lights up another cigarette and tosses the rest out into his trash bin.  The smoke rises from it slowly, dancing to the forces of the air around it.  It changes direction as it is driven up to the ceiling by it’s own heat, slowing and speeding in subtle shifts, thickening and thinning in bands and segments, and slowly it fades away like a forgotten lover in a distant past.

 

Now this is perhaps the most important part of the process, the attention to motion placed on the reference will be instrumental in making an effective smoke stream.

At this point, our little Koosh has a stream of smoke that rises and wafts in a pretty straightforward manner.  What he needs more of is nuance, though.  So, to that end he creates another field, a drag field, and connects it to his smoke particle object.

This sort of field creates a drag for the particles connected to it; slowing down whatever movement they are in.  He will want to use this field to slow only a particular segment of his smoke stream, as opposed to the whole.

            Selecting the dragField1 object, he opens the attribute editor and turns on the Volume Shape attribute to the Sphere setting.  This will make the field into the shape of a sphere.  The field will affect only connected dynamic objects inside the volume of this sphere.

           He turns the magnitude from the default 0.05 to 2.4 and begins to position and size (using the regular Maya transform tools – Move, Scale, Rotate) the spherical field to a good place in his smoke stream, right about in the middle.  Figure 7.

Figure 7

 

In this manner, the smoke will rise, then hit a lull in speed and as a result collect and thicken and then speed up and thin out as they exit the drag field’s sphere and head toward the radial field up above.

Resisting the urge to take a break and fire up Ebay to look up “latex” like he likes to do, he finishes off his glass of gin and gets real close to his monitor.  Watching his particles over and over, he determines he needs one more turbulence field to break up some of the stream at the top.  He’s unhappy with how they clump together as they near the radial field.

He clicks Fields>Turbulence, and connects them to the particles, again through the Dynamic Relationships Editor.  As with the drag field, he turns on the Volume Shape, but this time to Cube.

It is entirely possible for him to avoid using the volume shape by turning on the field’s Use Max Distance attribute and setting an appropriate Max Distance value to allow the field to only affect the particles within that radius, but it’s simpler and more visual to turn the field object into a volume as place it as needed.

In this case, it’s placed above the drag field’s sphere, intersecting with it’s upper third.  This will allow the smoke to dissipate a bit towards the top of its flow.  Figure 8.

 

Figure 8

 

“I need more gin,” he declares without breaking eye contact with his screen.

“I need more cigarettes,” she declares without breaking contact with her screen.

Stalemate.

Now that the particles are moving like smoke, Koosh needs to make them look like smoke.  He selects the particle object and opens the attribute editor.  First order of business is to choose the particle render type.  He’s sticking with hardware rendered particles, so cloud, blobby surfaces, and tubes are out.  He selects multi-point as the “Particle Render Type” under the “Render Attributes” heading of the window.

This will increase the number of particle points rendered by creating a radius around each particle where additional points will be rendered.  This is useful because each new point is not an extra particle, therefore it does not slow down the system.  It will give a fuller appearance than regular points without the need for adding extra particles.

Once he selects multi-point, he clicks the button marked “Add Attributes For…Current Render Type.”  This creates a set of attributes particular to a multi-point render type, such as MultiCount, MultiRadius, and Color Accum.  The MultiCount attribute governs the number of points rendered per particle while MultiRadius defines the maximum area around each particle where these extra points are added.  He sets MultiCount to 18 and MultiRadius to 0.9.  Turning ColorAccum on will allow the color to accumulate where the particle stream is thicker.  This will give more body to the smoke stream.

Speaking of color, Koosh needs to add a color to the particles.  To do this, he must first add a color attribute to his particle object.  Toward the bottom of his attribute editor, under the heading “Add Dynamic Attributes,” he clicks on the button marked “Color,” popping up a small window, in which he selects Add Per Object Attribute and clicks the “Add Attribute” button.  This will set a color for the entire particle object, as opposed to creating different colors for every particle.

His attribute editor now reflects 3 more attributes under the “Render Attributes” heading, Color Red, Color Green, Color Blue, each reflecting the separate RGB values of the particle object’s color.  He sets the particles to a light neutral gray with 0.6 for all three RGB Color values.

Lifespan is next.  Even though he is an expression junkie, Koosh chooses the simpler route of setting the Lifespan Mode (under the “Lifespan Attributes” heading of the window) to Random Range.  He enters a Lifespan of 20 and a Lifespan Random of 15.  The lifespan number will correspond to units of time as opposed to frames, so each lifespan will have a lifespan of 20 seconds with an added random range of 15.  Figure 9.

 

Figure 9

 

Now the only thing left for Koosh to do, other than apologize to Vicki for the night before, is to make the particles fade out as they die out.  To do that, he needs an opacity attribute.  So under the “Add Dynamic Attributes” heading, he clicks on “Opacity” to Add Per Particle Attribute.  By doing this, he allows each particle to fade out on its own to create a smoother and more natural overall dissipation of the smoke.

The new attribute will appear under the “Per Particle (Array) Attributes” heading of the attribute editor.  In the blank slot to the right of the newly formed attribute opacityPP, he right clicks to bring up a context menu.  He chooses Create Ramp and the text “<- arrayMapper1.outValuePP” appears in the slot.  Another right click in that slot will allow access to the ramp by choosing Edit Ramp from the nested context menu.

The idea here is to create very thin smoke that gets thicker as it accumulates.  So it’s necessary to create a ramp that is dark throughout.  The darker the colors in the ramp, the more transparent these particles will render.  A white color in the ramp will set the opacity value of the particle to 1, making it fully opaque.  On the other hand, a black color will set the opacity to 0, making the particle entirely invisible.

            Koosh deletes the top two colors of the default ramp (by clicking the square handles on the right hand side of the ramp display) and sets the bottom color of the ramp’s value to 0 (through the HSV section of the Color Chooser Window), so the particles will fade in as they’re born.  The next color he adds at a Position of 0.035 by clicking on the ramp’s display, thereby creating a new ramp handle, and adjusting that handle’s Selected Position attribute to 0.035.  With that ramp’s round handle still selected, he clicks on the Selected Color’s color swatch and sets it to a dark gray with a Value of 0.016.  Since all the colors on the ramp will be so low, the ramp will appear to be black throughout.  Figure 10.

 

He then adds the following ramp positions and colors:

 

Position 0.075               Value 0.074

Position 0.185               Value 0.050

Position 0.400               Value 0.025

 

Figure 10

            He’s almost done.  A few more little things to be done and he can go off and get himself another bottle of gin at the corner store.  All the animation and particle settings have been input, everything has been setup to move and look like cigarette smoke.  Now what he needs to do is render it, and make any tweaks.

            Since these are Hardware Rendered particles, he cannot set them off like any other render.  These particle types need to be rendered through Window>Rendering Editors>Hardware Render Buffer.  This will open a window through which Maya can render via the computer’s video card, through OpenGL.  All other objects (except for a few exceptions) will also render through this window, but will not have the added niceties of detailed lighting or shading maps.  Since there’s nothing else in the scene, Koosh had been planning on rendering these over black to be composited into the background life action plates anyway.

            Once the Hardware Render Buffer has opened, it will default to the perspective window.  Koosh repositions his camera slightly to get the desired angle in the regular perspective window, and those changes are reflected right away in the hardware buffer.

            In the hardware buffer window, clicking Render>Attributes is where the attributes that govern rendered image resolution, filename, frame range, etc. are.  This window is to the hardware render buffer what the Render Globals is to Maya’s software renderer.

            Under the heading “Multi-Pass Render Options,” Koosh needs to turn Multi-Pass Rendering on and choose a fairly high number like the max of 36.  Also, he sets an Edge Smoothing Value of 20 and a Motion Blur of 6.  Without Multi-Pass Rendering turned on, the particles will render out as simple points.  Figure 11.

Figure 10

 

            However, with that option turned on, and the values entered as above, the smoke will soften out and blur to create a much better effect than a bunch of dots.

            Clicking Render>Render Sequence will render the entire sequence specified in the hardware render attributes window (Koosh has chosen frames 1-340), while clicking the middle clapboard icon button will render the current frame.

 

            “Are you done making babies smoke?” Vicki asks from the couch, still glued to the Emergency Vets show.

            “Uh, yeah, I just need to render it out, pull it into After Effects, blur it a bit and then comp it in the plates.  And boom!  Smoking babies,” he replies.

            “Cause everyone’s happier when they’re smoking.”

            “Or drinking.”

            “Especially babies.”

            “Amen sister!”

            Noticing that the hardware buffer is not rendering right (it’s giving him black frames), Koosh clicks in the main Maya window Solvers>Create Particle Disk Cache to run the particle simulation and save it to disk as a file.  This usually helps out weird problems in the hardware renderer.

            A brief lull falls on them while Koosh watches his render.  He’s tempted to surf the web while it processes, but he knows, doing that would disrupt the render.  Hardware renders get messed up if a window or screen saver comes on over them.  So Koosh splits his time between watching the render and throwing little bits of crumpled paper at Vicki.

 

“So you gonna tell me why you need a smoking baby in a commercial?” she finally asks, flicking little pieces of paper off her sweater.

            “No.”

            “I hate you.”

            “Ditto.”

Final Still Image

 

Click to see the animation - 3.3Mb File, please wait for it

(Quicktime required)

 

Copyright © 2002 by Dariush Derakhshani. All rights reserved.  A couple lefts reserved, too.