Animation Alley - Real-Time Spray-Paint Simulation In Maya
Tutorial by nemirc (Sergio Rosa) - Staff Columnist
I have always liked the movies, but it wasn’t until I starting working with Maya 4 that I really became interested in movie Visual Effects (VFX). My interest peaked when viewing the “paint tunnel” sequence in the movie “Minority Report”. It blew me away!
“Anderton (Tom Cruise) is trapped inside a car that is being built. Once the car is assembled, it is sent through the “paint tunnel,” where several nozzles spray paint the vehicle; first orange, then red paint, and finally a gloss coat (giving the car a reflective-chrome look). All the paint sequences are shown in real-time on the screen. In the final sequence, Anderton is seen inside the car, which he uses as an escape vehicle.”
I knew at that moment - I had to learn the secrets of VFX. It took me days to figure that scene out, and now I want to share the techniques with you. This tutorial requires a solid understanding of Maya Dynamics and Expressions as well image composition. With that in mind, let me take you into my version of the making of the “paint tunnel”.
The challenge was to understand how the paint changed the color of the object. At first I thought about using the 3D Texture Paint Tool to create an image sequence, but it proved to be too time-consuming. In the end, I decided on particles.
When using particles, I needed them to conform to the surface. That is easy since Maya does that with the Resilience and Friction Attributes: set the Resilience to 0 so the particles don’t bounce/ set the friction to 1 to prevent them from moving.
To gradually reveal the object, I needed to create an image sequence that would be used as a mask. I wrote a Runtime Expression that changed the PerParticle color from black to white after collision. That worked well on simple objects, but it didn’t achieve the desired effect on this project, so I had to rewrite the expression:
if (particleShape1.event == 1)
particleShape1.rgbPP = <<1,1,1>>;
particleShape1.opacityPP = 1;
particleShape1.rgbPP = <<0,0,0>>;
particleShape1.opacityPP = 0;
This expression makes the particles transparent on birth, and then turns them into white opaque particles after collision. The flying particles must be made transparent, so they will not block other particles that have already collided with the object, affecting the mask. You must keep in mind three things: first, you have to set the particle collision events for the expression to work; second, you also need to add those PerParticle attributes (rgbPP and opacityPP) since they are not created by default; third and finally, this is a Runtime Expression (not a Creation Expression).
After the main pipeline was developed, I went to the following stage: Pre-visualization. Pre-visualization is the part of the preparation stage where you set up your scene, get the right framing, timing and such.
The car would only be moving forward since this was a paint tunnel; however, it had to move at a constant speed. I could simply key the start and end points for the sequence, but I wanted to have more control on the car’s speed. To achieve this I wrote an expression that would move the car at the constant speed of my choice. After many tests and Playblasts, I came to the final expression: car.translateX = time*5;
To start the actual production, I had to model the needed props. I took screens-grabs from “Minority Report” to have a better idea on how to set up all the spray nozzles, then I sketched my own versions. When I was satisfied, I modeled them in Maya.
Most everything was modeled using Polygonal Objects. I also used a little bit of Nurbs and SubD Surfaces for the upper nozzle. Rather then spend time creating a car, I used a third party model.
When all the models were ready, I put them into my previously created pre-visualization scene, replacing the rough geometry with the final geometry. This eliminated the need to redo the placing and coding.
I created 4 different scenes: the first was used to render the background and props; the second was used to render the car; the third one included the Particle Simulation to create the Matte Mask; the fourth one created the particles to simulate the sprays jetting from the nozzles. I also had to use different versions of the car; for the first transition, the car changes from a dull orange color to a red, for the second transition it changes from red to a reflective-chrome look.
To create the mask, I used hardware particles. I set up Emitters on the nozzles and keyed the Emitting Rate so that they would start spraying when I needed them too. I first set the Emitting Rate to 0. When the car approached, I boosted the value to 10000. Maya lets you “enter” values beyond the “limit” of 500. This step is very resource intensive since all the Emitters are jetting a large amount of particles per second.
It is a good idea to activate the Particle Cache, or Maya will calculate the movement and collisions on every frame before rendering. The size of the particles used must be taken into consideration; the smaller the particle size used, the more particles needed to cover the object. This can be translated into a “CPU-intensive” task.
I set the particle size to 5. If hard edges develop on the mask, they can be fixed in post-production. For the spray simulation I used Hardware Particles, keying the Emitting Rate set to Standard Lifespan. I then set the car as a Collision Object and created a Collision Event to make the particles emit “more particles” on contact. This created a nice “fog” effect on the surface of the car. I used Multi-Streak Particles to create that nozzle effect.
All those elements were rendered as separate layers and brought into post-production. I render everything as a .TGA sequence because it saves the alpha channel. Render both the Alpha and RGB channels. With all different layers created, I was ready to begin post-production. For this project I used Combustion 2, but any Video Editor will do, as long as it offers the needed tools.
After rendering the sequences to my satisfaction, I imported them into Combustion and started the composite and layering process. Layering the different sequences is very intuitive since I visualize what goes on the foreground and/or background. The mask layer had to be hidden so it wouldn’t show up on the final composite.
To create the transition from one car to the other I layered the glossy-red car on top of the dull orange one. Then I added a Gradient Wipe Operator to the top layer. The Operator allows you to use any layer as a mask. This is where the Mask Layer I created with the particles comes into action.
Even though the effect works, it’s not what I intended since I had used big particles. The original transition gave the appearance of blobs of paint squares on top of the car. To solve this problem I added a Gaussian Blur Operator. Brightness/Contrast and Glow Operators can be added to extend the effect of the mask, making sure both Operators are placed under the Gaussian Blur Operator.
Next, I used the Gaussian Blur Operator as Source Layer for the Gradient Wipe, which I applied to the painted version of the car. I set the Channel Setting to Luminance and the other two settings were set to 50%. If you are using AfterFX, the “Set Matte” Filter does the same effect.
Now that the transition effect was finished, I still had to add the paint jetting from the nozzles. To create the effect in the first transition, I used the same Hardware Particle sequence twice. The first one was turned into a “fog effect,” while the second one was used to create a “liquid” effect. I used the Discreet Keyer Operator to key out the black color from both layers. For the “fog effect” I applied a Gaussian Blur to the lower layer, setting the blur value to 10. The “spray effect” was made using a Motion Blur Operator, with a Phase Value of 50 and a Shutter of 15.
The same steps were used for the second transition, where the car changes from a standard red into the reflective-chrome look. To improve the metallic effect, I rendered a Highlight Pass that was later layered on top of the reflective car. A Gradient Wipe Operator was also applied to this layer. Color Grading was used to improve the visual appeal of the finished sequence. Finally, I tinted the walls with a subtle blue tone and color-corrected the spray simulations to create a less saturated look.
After several hours of post-working and long render times, I came up with the animation I had been hoping for. This technique is not exclusively used to simulate spray paint, it can also be used to make any kind of transition in post-production. The possibilities are endless!
Happy posing, and keep on animating!
is a regular featured column
with Renderosity Staff Writer
Sergio Rosa [nemirc].
August 1, 2005