Chapter 8. Paint Effects and Toon Shading

Paint Effects is a special Maya module designed to allow artists to quickly build, animate, and render large amounts of organic and natural detail. Trees, grass, flowers, clouds, blood vessels, vines, rocks, and even small towns can be interactively painted into a scene in three dimensions. Paint Effects is both a dynamic particle-based system and a procedural modeling tool. There are many options for rendering the objects that you create using Paint Effects, giving you an astonishing amount of creative flexibility when incorporating natural elements into your projects.

Paint Effects is also a part of Maya's Toon Shading system, which is used to simulate the look of hand-drawn cartoons when rendering 3D animations. This chapter looks at how Paint Effects works through several short, experimental projects. By the end of the chapter, you'll understand how to design and apply your own custom Paint Effects objects in a scene.

In this chapter, you'll learn to:

  • Use the Paint Effects canvas

  • Paint on 3D objects

  • Understand strokes

  • Design a brush

  • Create tubes

  • Add growth

  • Shape strokes with behaviors

  • Animate strokes

  • Render Paint Effects strokes

  • Use Toon Shading

Using the Paint Effects Canvas

Maya actually contains a 2D paint program that can be used to paint illustrations, create textures, or experiment with Paint Effects brushes. The Paint Effects canvas works like a simplified version of a digital paint program such as Corel Painter. You can paint on the canvas using any of the Paint Effects brushes; it's a great way to test a brush before applying it in a 3D scene.

The Paint Effects Window

The Paint Effects window is like a mini digital paint program inside Maya. In this section, you'll experiment with some basic controls to create simple images on the canvas.

  1. Create a new scene in Maya.

  2. In the view panel, choose Panel

    The Paint Effects Window
  3. The viewport now appears white with some icons at the top. This white area is the Paint Effects canvas. If you see a 3D scene instead, choose Paint

    Opening the Paint Effects Window
  4. Click and drag on the canvas; you'll see a black line resembling ink appear wherever you paint on the canvas. If you are using a digital tablet, vary the pressure as you paint: the line becomes thinner when less pressure is applied and thicker where more pressure is applied.

  5. Click on the color swatch next to the C on the Paint Effects menu bar. This opens the Color Chooser. You can use this tool to change the color of the brush. Move the V slider to change the value (brightness) of the paintbrush color (see Figure 8.2).

  6. The color swatch labeled with a T and the slider next to it control the transparency of the current stroke. Experiment with changing color and transparency as you paint on the canvas (see Figure 8.3).

    Choosing Paint Canvas from the Paint menu switches Paint Effects to 2D paint mode.

    Figure 8.1. Choosing Paint Canvas from the Paint menu switches Paint Effects to 2D paint mode.

    The Paint Effects canvas is a 2D paint program within Maya. Clicking on the C color swatch opens the Color Chooser, allowing you to change the brush color.

    Figure 8.2. The Paint Effects canvas is a 2D paint program within Maya. Clicking on the C color swatch opens the Color Chooser, allowing you to change the brush color.

    The icons on the menu bar of the Paint Effects window

    Figure 8.3. The icons on the menu bar of the Paint Effects window

    These are the other icons on the panel, from left to right, as shown in Figure 8.3:

    • The eraser icon clears the canvas.

    • The color icon displays the RGB channels (color) of the canvas.

    • The white circle icon displays the alpha channel of the strokes on the canvas.

    • The 1:1 icon displays the actual size of the canvas.

    • The camera icon takes a snapshot of the canvas.

    • The paintbrush icon opens the Attribute Editor for the current brush settings.

    • The double paintbrush icon opens the Visor, which displays the available Brush presets.

    • The folder icon opens the sourceimages folder. When this button is active, every time you make a change to the canvas, you'll be prompted to save the image in the sourceimages folder.

    • The sideways arrow allows horizontal tiling. As you paint off one side of the canvas, this stroke is continued on the opposite side. This is useful when you want to create seamless tiling textures.

    • The down arrow enables vertical tiling. Strokes that you paint off the top or bottom of the canvas are continued on the opposite side.

    • The branching stroke icon enables tube painting. This will be discussed in more detail.

    • The diagonally split icon flips tube direction. This will be discussed along with tubes.

  7. Click the eraser icon to clear the canvas. Click the double brush icon to open the Visor (or choose Window

    The icons on the menu bar of the Paint Effects window
  8. In the Visor, make sure the Paint Effects tab is selected at the top. From the list of folders on the left side, open the flesh folder and select hands.mel. This switches the current brush to the hands brush—you'll see the current brush highlighted in yellow in the Visor (Figure 8.4).

  9. Paint some strokes on the canvas. Instead of an inky line, you'll see numerous hands appear as you paint. The hands vary in color while you apply them to the canvas (Figure 8.5).

    Select the hands.mel brush from the Visor.

    Figure 8.4. Select the hands.mel brush from the Visor.

    When the hands.mel brush is selected, painting on the canvas produces a number of images of human hands.

    Figure 8.5. When the hands.mel brush is selected, painting on the canvas produces a number of images of human hands.

    Note that when you switched to the hands brush, a new slider labeled TS appeared on the upper-right corner of the Paint Effects panel menu. This is the Tubes Per Step slider. Increasing this value raises the number of stamp images created when you paint on the canvas.

    To interactively change the size of the hands as you paint, hold the B key and drag left or right on the canvas; you'll see the circular brush icon grow as you drag to the right and shrink as you drag to the left.

    If you want to change the background color of the canvas, select Canvas

    When the hands.mel brush is selected, painting on the canvas produces a number of images of human hands.
  10. Open the Visor and select some other brushes; make a mess on the canvas. Try the defaultSmear.mel brush found in the airbrush folder. When you paint on the canvas, the brush smears the strokes already painted.

Some Paint Effects brushes create colors and images, while others alter the colors and images painted on the canvas. And some, such as the smearColor.mel brush, smear the strokes and apply color at the same time (see Figure 8.6).

Some brushes, such as the smear brush, alter the strokes painted on the canvas.

Figure 8.6. Some brushes, such as the smear brush, alter the strokes painted on the canvas.

Painting in Scene Mode

You can use Paint Effects brushes to paint in 3D. The strokes actually produce three-dimensional images that are incorporated into the scene. While in the Paint Effects window, you can preview what strokes will look like in a 3D scene.

  1. In the Paint Effects window, choose Paint

    Painting in Scene Mode

    The Paint Effects window now displays a perspective view, but notice that the Paint Effects menu is still at the top of the canvas. You are now in scene mode of the Paint Effects window. You can switch cameras using the Panels menu in the Paint Effects menu bar.

  2. Open the Visor and choose the hands.mel brush from the flesh folder. Paint some strokes on the grid.

  3. The grid quickly becomes littered with dismembered hands (see Figure 8.7). Tumble around the scene. The hands switch to wireframe mode to help improve performance. If you'd like the hands to remain visible, choose Stroke Refresh

    Painting in Scene Mode
    Painting in scene mode allows you to paint strokes directly in a 3D scene.

    Figure 8.7. Painting in scene mode allows you to paint strokes directly in a 3D scene.

Notice that the brush icon appears as a 3D wireframe sphere. You can change its size interactively by holding the B key and dragging left or right in the perspective view.

Painting on 3D Objects

Once you are comfortable selecting and applying Paint Effects brushes, you're ready to actually paint on some 3D objects. Both NURBS and polygon objects can be painted on the canvas using Paint Effects. You can add grass and flowers to rolling fields, clouds in the sky, and whiskers on an old man's chin.

You're not limited to using the Paint Effects window when adding Paint Effects strokes to a scene. You can apply Paint Effects while working in any camera view in a standard Maya scene. However, if you'd like to see a more accurate preview of what the stroke will look like when rendered, then use the Paint Effects window in scene mode. For these exercises, you'll paint strokes in a scene using the standard Maya viewports.

  1. Open the skull_v01.ma scene from the chapter8scenes directory on the DVD.

    This Maya scene consists of a polygon skull resting on a NURBS pedestal. The pedestal is resting on a polygon plane (see Figure 8.8). This scene will serve as your laboratory as you experiment with Paint Effects brushes.

    The skull_v01.ma scene consists of a polygon skull on a NURBS pedestal.

    Figure 8.8. The skull_v01.ma scene consists of a polygon skull on a NURBS pedestal.

  2. Choose Window

    The skull_v01.ma scene consists of a polygon skull on a NURBS pedestal.
  3. In the scene, paint across the polygon floor and the pedestal. You'll see the vines appear on the floor but not on the pedestal.

    What's actually going on here is that you're painting on the grid, not on any of the 3D objects (including the floor). To paint on an object, you need to make it "paintable."

  4. Open the Outliner; you'll see two new nodes named strokeVineLeafy1 and curveVineLeafy (see Figure 8.10). Select these nodes and press the Backspace button to delete them.

  5. Switch to the Rendering menu set. In the Outliner, Shift+click the floor, the pedestal, and the skull; then choose Paint Effects

    The skull_v01.ma scene consists of a polygon skull on a NURBS pedestal.
    Hold the cursor over the brush icon to see its name in a pop-up window. Select the vineLeafy.mel brush.

    Figure 8.9. Hold the cursor over the brush icon to see its name in a pop-up window. Select the vineLeafy.mel brush.

    Two nodes are created in the Outliner when you paint a stroke in the scene.

    Figure 8.10. Two nodes are created in the Outliner when you paint a stroke in the scene.

    After you've painted a few strokes, you'll notice the vines are on the floor and the pedestal; some will even be stretched between the floor and the pedestal. However, there are no strokes on the skull itself (see Figure 8.11).

    The leafy vine stroke is painted on the 3D objects in the scene. However, no strokes appear on the skull.

    Figure 8.11. The leafy vine stroke is painted on the 3D objects in the scene. However, no strokes appear on the skull.

    The reason for this is that the skull has no UV texture coordinates applied. This is a common problem when working with Paint Effects on polygon objects. Paint Effects strokes need UV coordinates to determine their position. If an object has no UVs or has poorly mapped UVs, the strokes will not appear or they will behave strangely. This is also true for animated objects that have UVs that move around (this occurs when you apply UVs but forget to delete history on the object). If your Paint Effects are behaving strangely when applied to a polygon object, double-check the UVs of the object.

  6. Select the strokeLeafyVine nodes in the Outliner and delete them (notice that there is no curve node—we'll explain this a little further on).

  7. Switch to the Polygon menu set and select the skull. Choose Create UVs

    The leafy vine stroke is painted on the 3D objects in the scene. However, no strokes appear on the skull.
  8. When the planes appear, select the skull in the Outliner, and choose Edit

    The leafy vine stroke is painted on the 3D objects in the scene. However, no strokes appear on the skull.
    UV texture coordinates are created for the skull using the Automatic Mapping method.

    Figure 8.12. UV texture coordinates are created for the skull using the Automatic Mapping method.

    To learn more about creating and working with UV texture coordinates, consult Chapter 11. You can, and should, spend time creating a more efficient UV map for your models, but in a pinch automatic UVs should work well enough. Remember to delete history on the skull object after creating the UVs.

  9. Now that the skull has UV coordinates, save the scene as skull_v02.ma.

  10. Select the skull and choose Paint Effects

    UV texture coordinates are created for the skull using the Automatic Mapping method.

Understanding Strokes

When you create a Paint Effects stroke in a scene, several nodes are automatically created and connected. Some of the nodes are visible and some are not. These nodes work together to produce the strokes you see in the scene.

The Anatomy of a Paint Effects Stroke

In this section, you'll look at the nodes created when you add a Paint Effects stroke to a scene. Some of these nodes you will most likely ignore; some of the nodes you will use to edit and animate the strokes.

  1. Continue with the scene from the previous section or open the skull_v02.ma scene from the chapter8scenes directory on the DVD.

  2. Switch to the Rendering menu set. Select the skull and choose Paint Effects

    The Anatomy of a Paint Effects Stroke
  3. Choose Window

    The Anatomy of a Paint Effects Stroke
  4. Zoom in to the skull and start painting grass on the skull. It's a Chia-skull! Paint exactly three strokes. Each time you release the mouse button (or the pen from the tablet), a stroke node is added in the Outliner (see Figure 8.13).

    The skull does not have to be selected to paint on it, but it must be made paintable (Paint Effects

    The Anatomy of a Paint Effects Stroke
    Astroturf is painted on the surface of the skull.

    Figure 8.13. Astroturf is painted on the surface of the skull.

  5. Once you have three strokes applied, look in the Outliner. You'll see that a stroke node was created each time you painted on a paintable surface.

    Each stroke has a transform node and a shape node. Figure 8.14 shows the Outliner with one of the stroke nodes expanded, so you can see that the stroke's shape node is parented to the stroke's transform node (for more about transform and shape nodes consult Chapter 1).

    The Astroturf nodes appear in the Outliner for each stroke painted on the skull. Each stroke has a transform node and a shape node.

    Figure 8.14. The Astroturf nodes appear in the Outliner for each stroke painted on the skull. Each stroke has a transform node and a shape node.

    The transform node contains information about the stroke's position, scale, and rotation. Most likely you'll almost never edit the transform node's attributes except maybe to hide the node by changing its Visibility attribute.

    The shape node has a number of attributes specific to how the node appears and behaves.

  6. Select the strokeAstroturf 1 node and open the Attribute Editor. You'll see a tab for the transform node labeled strokeAstroturf1. Open the Attribute Editor for the shape node by clicking on the strokeShapeAstroturf1 tab in the Attribute Editor.

  7. The strokeShapeAstroturf1 node has attributes that control how the stroke is displayed in the scene, how it renders, the pressure settings, and other settings specific to the individual stroke (see Figure 8.15).

    The strokeShapeAstroturf1 tab contains settings that control the stroke in the scene.

    Figure 8.15. The strokeShapeAstroturf1 tab contains settings that control the stroke in the scene.

  8. In the Attribute Editor, switch to the astroturf1 tab. This tab contains settings for the astroturf1 brush. Editing these settings also changes the way the stroke appears in the scene.

    The relationship between the shape node (strokeShapeAstroturf1) and the brush node (astroturf1) can be a little confusing at first. Think of it this way: If you draw on a wall with a crayon, the mark on the wall is the stroke, and the shape node controls the appearance of that particular stroke. The crayon you used to make the mark on the wall is the brush (using Paint Effects terminology). Changing the settings on the brush would be like changing the crayon itself, which would affect the appearance and behavior of the strokes themselves. However, unlike in the real world where changing the crayon only affects each subsequent mark made by the crayon, there is a construction history connection between the stroke and the brush that made the stroke, so that changing the settings on the brush causes a change in the strokes already created in the scene that used that brush.

  9. In the astroturf1 tab of the Outliner, set Global Scale to 0.1. The size of strokeAstroturf1 shrinks. Notice that the other strokes are not affected (Figure 8.16).

    Changing the Global Scale setting in the astroturf1 brush node affects only the size of one of the strokes painted on the skull.

    Figure 8.16. Changing the Global Scale setting in the astroturf1 brush node affects only the size of one of the strokes painted on the skull.

Brush Sharing

Another aspect of the relationship between the brush node (astroturf1) and the shape node (strokeShapeAstroturf1) is that even though you have the same brush selected when you create multiple astroturf strokes on the skull, Maya creates a new brush node for each stroke. It's as if you had a box of identical crayons, and each time you make a mark on the wall, you switch to a new crayon. This is confusing at first, but it means you have more options for varying strokes in a Maya scene. To understand this relationship further, let's take a closer look at the nodes in the scene.

  1. In the Outliner, expand the Display menu and turn off DAG Objects Only. This causes the Outliner to display all of the nodes in the scene (for more on DAG nodes, consult Chapter 1).

  2. In the Outliner, you'll see several astroturf brush nodes (the nodes with the brush icon; in some cases one of the nodes may be listed with the other astroturf nodes). These nodes are labeled astroturf, astroturf1, astroturf2, and astroturf3.

    The first astroturf node is really an instance of the currently selected brush. If you change your current brush selection to a different brush, the node changes to match the name of the new brush. Think of this as a placeholder for the current brush settings. Each time a stroke is created in the scene, a copy of this node is created and associated with the stroke. Figure 8.17 shows how the node name changes when the grass ornamental brush is selected in the Visor (middle image); if the scene is reloaded in Maya, the brush is relabeled brush1.

  3. Select astroturf2, and open the Attribute Editor to the astroturf2 node. Making a change to the settings—such as the Global Scale—affects only the associated stroke (in this case strokeAstroTurf2).

    The name of the first brush node changes depending on the brush currently selected in the Visor.

    Figure 8.17. The name of the first brush node changes depending on the brush currently selected in the Visor.

    The ability to change the brush settings associated with each stroke means that you can easily create variations of the brushes within the scene. However, let's say you have 200 brush strokes that all use the same brush and you need to change a setting, such as the Global Scale for all of them or maybe even just 99 of them. Instead of changing each brush stroke individually, you can enable brush sharing so that the same brush node affects all of the associated strokes.

  4. In the Outliner, Shift+click strokeAstroturf1, strokeAstroturf2, and strokeAstroturf3. Choose Paint Effects

    The name of the first brush node changes depending on the brush currently selected in the Visor.

    If you look in the Outliner, only one brush node is labeled astroturf3. The strokes adopt the brush settings of the last selected brush.

  5. Select the astroturf3 node in the Outliner, and change its Global Scale slider. All three strokes update as you make the change.

  6. Select the three strokeAstroturf nodes in the Outliner, and choose Paint Effects

    The name of the first brush node changes depending on the brush currently selected in the Visor.

If you find yourself in a situation in which you need to change 200 different brushes at once, you can select the strokes, enable brush sharing, make the change, and then remove brush sharing to return to a state where each brush can be edited individually. Note that turning on brush sharing applies only to changes made to the settings in the brush node. Each individual brush still has its own shape node. The settings in the shape node can't be shared among multiple brushes. We'll discuss this further in the section on creating custom brushes.

Brush Curve Nodes

When you paint a Paint Effects stroke in a scene, the stroke is attached to a curve that determines the overall shape of the stroke. The curve node itself may be visible or not depending on how the stroke is created. If you paint directly on the grid (Paint Effects

Brush Curve Nodes

If you select a NURBS object, choose Paint Effects

Brush Curve Nodes
A stroke painted on the NURBS pedestal is graphed in the Hypergraph. The node named curveBrushShape121 is the curveOnSurface node.

Figure 8.18. A stroke painted on the NURBS pedestal is graphed in the Hypergraph. The node named curveBrushShape121 is the curveOnSurface node.

When you paint on a polygon surface, Maya creates a curveFromMeshCom node, which allows Maya to draw a curve on a polygon surface. When you graph a stroke painted on a polygon, you can see both the curve node and the curveFromMeshCom node. You can also see the curves parented to the shape node of the polygon geometry in the Outliner (see Figure 8.19).

A stroke painted on a polygon surface creates a curve node and a curveFromMeshCom node.

Figure 8.19. A stroke painted on a polygon surface creates a curve node and a curveFromMeshCom node.

You may not be immediately concerned with the curve nodes Maya creates when you paint a stroke on a surface; however, a situation may arise in which you need to access the curve nodes to make some kind of change to the connection (for instance, if you decide you want to transfer a stroke from a regular curve to a dynamic hair curve). In these situations, it's good to have a basic understanding of how the paintbrushes are actually applied to 3D objects.

Designing Brushes

There's no better way to learn how to use Paint Effects than to get some hands-on training designing a custom brush. Once you have practical experience working with the many settings available for Paint Effects brushes, you'll have a much easier time working with the brushes listed in the Visor.

Most of the time when you create your own brushes you'll start with one of existing brushes available in the Visor and then edit its settings until you get the look and the behavior you want. For instance, if you want to create a creepy nerve growing in a test tube, you may start with a brush preset that looks similar to what you want, such as a tree branch, and then experiment with the settings in the Attribute Editor until the branch looks and acts like a creepy nerve.

Paint Effects is a procedural modeling and animation workflow—meaning that the objects created by Paint Effects and the animation applied to the models are derived from mathematical algorithms (as opposed to pushing and pulling vertices). The math involved is beneath the hood, so you don't need to worry about breaking out the slide rule. However, this does mean that you'll be working with a lot of interconnected sliders, settings, and controls. It's a very experimental process. Changing one setting affects a number of others. There's no particular order in how you edit the settings either; in fact, you'll find yourself bouncing around among the various controls and nodes in the Attribute Editor. Although this may seem overwhelming at first, after some practice you'll see that there's a lot to discover in Paint Effects, and you can create many very unusual and unexpected things, which is always a lot of fun.

Painting with the Default Paintbrush

You'll start by painting with the default paintbrush on the skull and pedestal in the skull scene. At this point there is no particular goal in mind; it's all about experimenting and seeing what happens.

  1. Open the skull_v02.ma scene from the chapter8scenes directory on the DVD. In this scene the polygon skull model already has UV texture coordinates applied, so you are ready to start painting brush strokes.

  2. In the Outliner, Shift+click the skull1 and pedestal objects. Switch to the Rendering menu set, and choose Paint Effects

    Painting with the Default Paintbrush
  3. Choose Window

    Painting with the Default Paintbrush
  4. Choose Paint Effects

    Painting with the Default Paintbrush
  5. Rotate the perspective view so you can see part of the top of the skull. Paint a stroke starting at the top of the skull. Create a meandering stroke that moves down the skull onto the pedestal. If you are using a digital tablet, vary the pressure as you paint on the surfaces. The stroke will change in width, growing thicker when more pressure is applied.

  6. Avoid painting around the back of the pedestal or on areas you can't see. This creates a long, stretched section of the stroke. You want a nice continuous stroke that moves down across the surface of the skull and pedestal. Use Figure 8.20 as a reference.

    Create a meandering paint stroke, starting from the top of the skull and moving down to the floor. Changes in pressure applied to the pen on a digital tablet cause variations in the stroke width.

    Figure 8.20. Create a meandering paint stroke, starting from the top of the skull and moving down to the floor. Changes in pressure applied to the pen on a digital tablet cause variations in the stroke width.

    If you want the stroke to continue onto the floor, you can make the floor object paintable as well, but sometimes this can make painting the strokes trickier. When a NURBS surface has a paintable polygon object behind it in the perspective view, you may find that the stroke jumps from the pedestal to a point on a distant part of the floor. It may be easier to create a number of strokes on the skull and pedestal first and then make the floor paintable and paint new strokes to continue the lines drawn on the pedestal.

  7. Use the same method to paint four or five more brush strokes. Start each stroke at the top and move down (see Figure 8.21).

  8. Save the scene as skull_v03.ma. To see a version of the scene so far, open skull_v03.ma from the chapter8scenes directory on the DVD.

Paint additional strokes on the surfaces.

Figure 8.21. Paint additional strokes on the surfaces.

Brush Types

In this section, you'll learn about the various brush types. You'll start at the top of the brush settings and work your way down. However, keep in mind that when working on your own brush designs, you will most likely not edit the settings in any particular order. A variety of brushes are available.

  • The Paint type brush creates strokes that are a series of dots stamped along the path of the stroke. The strokes look much smoother when a higher number of dots is used.

  • Smear and Blur type brushes distort or soften (respectively) the appearance of paint strokes applied to the canvas.

  • ThinLine/MultiStreak type brushes render strokes as groups of thin lines. This works well for hair and whisker effects.

  • The Erase type brush creates a black hole in the alpha channel of a scene. It can be used to paint holes in the rendered image.

    The Mesh type brush actually creates geometry from the stroke. This type of brush works well for hard-edge objects that appear close to the camera, such as trees or buildings. There are several folders in the Visor that contain mesh type brush strokes. Using the mesh type stroke is not the same as converting a stroke to polygons. Mesh type strokes, like all of the other types, will not render in mental ray.

  1. Continue with the scene from the previous section or open the skull_v03.ma scene from the chapter8scenes directory. If you don't have a digital tablet, you may want to use the scene on the DVD so you can see the effect that variations in pressure have on the strokes.

  2. Shift+click the strokes in the Outliner, and choose Paint Effects

    Brush Types
  3. Select any of the brushes and open the Attribute Editor. Select the defaultPaint tab. (The name of the tab may vary depending on how many brushes you have in your scene. In the example scene this tab is labeled defaultPaint6.)

    You can set the type of brush using the Brush Type drop-down list at the top of the settings. The brush types determine how the strokes are constructed (see Figure 8.22).

    The type of brush is set using the menu at the top of the Attribute Editor for the brush node.

    Figure 8.22. The type of brush is set using the menu at the top of the Attribute Editor for the brush node.

    The Global Scale slider sets an overall scale for the stroke. This can be adjusted to ensure that the stroke matches the scale of the other objects in the scene. When you use the b hot key to adjust the size of the brush, you are interactively setting its global scale.

  4. Make sure the Brush Type is set to Paint and the Global Scale to 5.

Brush Profile

The settings in the Brush Profile area control how the brush looks when rendered.

  1. Open the Render Settings Window (Window

    Brush Profile
  2. Open the Render Preview window and create a test render of the scene. Store the image in the Render Preview window (choose File

    Brush Profile

    Adjusting the Brush Width value changes the size of the area covered by the brush stroke. For simple strokes, such as the default stroke, it appears as though changing the Brush Width is similar to changing the Global Scale. However, with more complex brushes that use tubes, changing the Brush Width changes the amount of area covered by the tubes. For instance, paint a stroke using the astroturf brush; the Brush Width changes the width of the area covered by the grass. Changing the Global Scale changes the overall size of the stroke, including the size of each blade of grass. This is shown in Figure 8.23.

    Three strokes are painted on the grid using the astroturf brush. The two strokes on the left have different Brush Width values; the stroke on the right has a larger Global Scale.

    Figure 8.23. Three strokes are painted on the grid using the astroturf brush. The two strokes on the left have different Brush Width values; the stroke on the right has a larger Global Scale.

  3. Increasing the brush Softness creates a fuzzy edge to the rendered stroke. Set Softness to 1, and create an image (see Figure 8.24).

  4. Store the image in the render view, set Softness to 0, and create another test render. Store the image in the render view, and compare the two renders using the scroll bar at the bottom of the Render View window. Notice that the softer brush appears thinner than the brush in the render with 0 Softness.

    Negative Softness values create a very unusual-looking brush.

  5. Set Softness to 0.5. Set Flatness1 to 0.

    Increasing brush Softness adds a fuzzy edge to the rendered strokes.

    Figure 8.24. Increasing brush Softness adds a fuzzy edge to the rendered strokes.

    The defaultPaint brush is a rounded tube. Increasing the Flatness1 setting makes the brush appear as a flat strip. You can then use the Twist controls (under the Twist rollout a little farther down in the Attribute Editor) to rotate the stroke around its path curve. Increasing Twist Rate twists the stroke like a ribbon. Flatness2 is available only for strokes that use tubes (tubes are discussed later in the chapter).

    Stamp Density controls how many dots are used to create the stroke when the Type is set to Paint. Increasing this setting creates a smoother stroke; decreasing the setting breaks the stroke into visible dots.

  6. Set Stamp Density to 1 and create a test render. The strokes appear as dotted lines. This is shown in Figure 8.25.

  7. Set Stamp Density to 8.

If you want the brush size to remain constant regardless of how close the camera is to the stroke, you can use the Screen Space Width controls. These controls are very useful when working with toon lines. They will be discussed in more detail in the Toon Shading section later in the chapter.

When you decrease Stamp Density, the brush appears as a series of dots.

Figure 8.25. When you decrease Stamp Density, the brush appears as a series of dots.

Coloring Strokes

In the Attribute Editor, scroll down to the Shading controls and expand the Shading rollout. This contains some basic controls to adjust the color of the strokes. These controls are very simple. The Color 1 slider applies a flat color to the stroke. This color is mixed with the color chosen in the Incandescence control. When the Transparency slider is increased, the incandescence has a stronger influence on the shading of the stroke. A transparent stroke with a bright incandescence setting creates a nice neon glow or laser beam effect.

  1. Set Color to bright red, Incandescence to a very dim yellow, and Transparency to a very light gray.

  2. Expand the Glow rollout. Set Glow to 0.256. Set Glow Color to a dim red. Set Glow Spread to 2.

  3. The Shader Glow setting adds a more realistic glow to the stroke. Set this to 0.074.

  4. Create a test render. A render using these settings is shown in Figure 8.26.

  5. Save the scene as skull_v04.ma.

Add a glow to incandescent strokes. The Shader Glow setting adds a more realistic glow.

Figure 8.26. Add a glow to incandescent strokes. The Shader Glow setting adds a more realistic glow.

Texturing Strokes

To create variation in the surface of a stroke, you can apply textures to the color, opacity, and even the displacement of the strokes.

  1. Continue with the scene from the previous section or open the skull_v04.ma scene from the chapter8scenes directory.

  2. In the Attributes for the defaultPaint node, set the Glow and Shader Glow settings to 0. Set the Glow Color to black.

  3. In the Shading rollout, set the Incandescence at 1 and Transparency color to black.

  4. Expand the Texturing rollout. Click the box next to Map Color. This applies a texture to the color channel.

  5. Scroll down in the Attribute Editor until you can see the Texture Type drop-down list. Leave this set to Checker. Create a test render (see Figure 8.27).

    A checker pattern is applied to the color channel as a texture.

    Figure 8.27. A checker pattern is applied to the color channel as a texture.

    Notice that the red color still appears in the texture. When Texture Color Scale is set to 1, the color chosen in the Shading section of the brush attributes overrides the colors chosen in the Tex Color 1 and Tex Color 2 sliders. Lowering Tex Color Scale to 0 replaces the red color in the checker pattern with the color chosen in Tex Color 1. The Tex Color Scale and Tex Color Offset sliders are similar to the Color Gain and Color Offset sliders found in the Color Balance section of a standard texture node. For more information on how the Color Balance and Color Offset controls work, consult Chapter 2.

    The Map Method setting controls how the texture is applied to the strokes. Both the Tube 2D and Tube 3D methods wrap the texture around the stroke. However, when Map 2D is used, the texture is always centered on the stroke. This eliminates any visible seam as the texture wraps around the stroke. Using the Map 3D method may give better results if the view of the stroke is animated.

    Using Full View maps the texture across the entire view scene in the viewport.

  6. Set Texture Type to File. Scroll down and click the folder next to Image Name. Use the File Browser dialog box to select the metalPlate.tif file from the chapter8sourceimages directory on the DVD. Figure 8.28 shows the image.

    The metal plate texture that will be applied to the stroke

    Figure 8.28. The metal plate texture that will be applied to the stroke

  7. Set Map Method to Full View and Tex Color Scale to 0. Create a test render. The image is revealed by the stroke. The image fills the viewable area. If this stroke covered most of the screen, you would see the entire metalPlate image (see Figure 8.29).

    Full View maps the texture to the stroke based on the viewable area of the scene.

    Figure 8.29. Full View maps the texture to the stroke based on the viewable area of the scene.

    One possible use for this mapping method would be to animate a logo reveal by mapping an image file of a logo to the stroke using the Full View method. The stroke could then be animated by drawing on the screen to reveal the logo. Animating strokes will be covered a little later in the chapter.

    The Brush Start method works similarly to the Full View method. However, the image is scaled to fit within the viewable area defined by the stroke.

    You can map a texture to the opacity of the stroke and use a texture as a displacement. When using a displacement, Stroke Type should be set to Mesh, and you may need to increase the Tube Sections and Sub Sections settings in the Mesh controls. Setting Softness to 0 helps make the displacement more obvious. At this point you can see how designing strokes involves a lot of moving back and forth among settings in the Attribute Editor.

  8. Disable Map Color and Map Opacity. Enable Map Displacement.

  9. Scroll up to the top of the Attribute Editor, and set Brush Type to Mesh. Set Softness to 0. In the Mesh rollout, set Tube Sections to 30 and Sub Sections to 20.

  10. Scroll back down to the Texturing section. Set Texture Type to Fractal.

  11. At the bottom of the Texturing rollout, set Fractal Amplitude to 0.256.

  12. Expand the Illumination settings just below the Texturing rollout, and enable Illuminated and Real Lights.

  13. Set Lighting Based Width to 0.68. This causes lighter areas of the stroke to become thinner.

  14. Create a test render. You can see that the fractal texture displaces the stroke, making it appear lumpy (see Figure 8.30).

  15. Save the scene as skull_v05.ma. To see a version of the scene, open the skull_v05.ma scene from the chapter8scenes directory on the DVD.

Applying a fractal texture as a displacement makes the surface of the stroke appear lumpy.

Figure 8.30. Applying a fractal texture as a displacement makes the surface of the stroke appear lumpy.

Creating Tubes

Paint Effects brushes become much more interesting when you add tubes. Tubes are smaller brush strokes that radiate from the center of the area defined by the brush width. Using tubes, you can create a series of crawling vines as opposed to the long singular strands created by the default brush. The tubes themselves can grow branches, twigs, leaves, and flowers. A complex brush can create a row of trees. Each tree can have its own branches and leaves.

In this section, you'll create crawling vines over the surface of the skull and pedestal using the strokes painted in the first part of the chapter.

Tubes Controls

You'll start by adding tubes to the strokes in the skull_v04.ma scene. Tubes have a lot of controls. Rather than describe what every control does, this section uses hands-on exercises to get you used to using the controls. The goal is to add curling vines to the stroke.

The Maya documentation has descriptions for every control available for Paint Effects. Go to the help files and enter Paint Effects into the Search field. The page listed as Paint Effects Brush Settings provides you with brief descriptions of all of the controls found in the brush node for a Paint Effects stroke. In this exercise, you'll add tubes to the strokes painted on the skull and pedestal.

  1. Open the skull_v04.ma scene from the chapter8scenes directory on the DVD, or go back to your own version 4 of the scene.

  2. Select the strokeDefaultPaint1 stroke in the Outliner, and open the Attribute Editor to the defaultPaint6 tab (the number of the stroke may be different in your version of the scene).

  3. Under Brush Profile, set Softness to 0.1.

  4. In the Shading section, set Color to a dark brown. Set Incandescence to 1 and Transparency1 to 0.

  5. In the Glow section, set Glow to 0, Glow Color to black, and Shader Glow to 0.

  6. Expand the Tubes section and activate Tubes. Immediately you'll see the strokes appear as long, thin spikes shooting from the stroke path (Figure 8.31). The thick central brush stroke is gone.

  7. Turn off Tube Completion. When Tube Completion is off, tubes near the end of a Paint Effect stroke are not complete, just as younger branches at the top of a tree may be shorter than older branches toward the bottom.

  8. Expand the Creation settings. These settings define how the tubes grow from the stroke. To set the number of tubes, adjust the Tubes Per Step. Set this to 0.8.

    Turning Tubes on creates long thin lines that grow from the original brush stroke.

    Figure 8.31. Turning Tubes on creates long thin lines that grow from the original brush stroke.

    Tubes Rand randomizes the placement of tubes along the stroke. Start Tubes is useful if you want a single tube or a clump of tubes to appear at the start of the stroke. So if you want to precisely position a tree or a bolt of lighting, you can set Start Tubes to 1 and Tubes Per Step to 0 and draw a short stroke wherever you want the tree or lightning placed in the scene.

  9. Set Segments to 60.

    Each tube is made up of segments. By increasing the number of segments per tube, the tube will appear smoother. This also exaggerates any curling or bending applied to the stroke. If the growth of the tube is animated, more segments will mean that the tube takes longer to reach its final length. We cover animation of tubes later in the chapter.

  10. Length Min and Length Max define a range of lengths for the tubes. Setting these to the same value means all the tubes are at the same length. To create a more random look for the vines, set Length Min to 0.165 and Length Max to 0.579.

  11. Tube Width 1 controls the width of a stroke at its base; Tube Width 2 controls the width of the tube at the tip. Set Tube Width 1 to 0.02 and Tube Width 2 to 0. This creates a pointy tip to the tubes.

    The Width Rand slider randomizes the width of the tubes. It's a multiplier, so in some cases it increases the width of some of the tubes beyond the range specified by Tube Width 1 and Tube Width 2. The Width Bias slider helps bias the randomization of widths.

  12. Set Width Rand to 0.65 and Width Bias to −0.5. The negative bias means the tubes are more likely to be thin than thick.

  13. Set Segment Length Bias to 0.4. This means that segments closer to the base of each tube will be longer. If you zoom in on a selected tube, you can see the segments in the wireframe display (Figure 8.32). Setting a negative Segment Length Bias would produce longer segments toward the tip of each tube.

    Zooming in on a selected tube reveals its segmentation in the wireframe display.

    Figure 8.32. Zooming in on a selected tube reveals its segmentation in the wireframe display.

  14. Set Segment Width Bias to 0.175. A positive Segment Width Bias makes longer segments thicker. A negative value would make shorter segments thicker.

    You can also make tubes flatter at the base or tip using the Flatness 1 and Flatness 2 sliders. These controls are found in the Brush Profile section at the top of the Attribute Editor.

  15. Save the scene as skull_v06.ma. To see a version of the scene to this point, open the skull_v06.ma scene from the chapter8scenes directory on the DVD.

Width Scale

If you want more precise control over the shape of the tubes, you can use the ramp curve in the Width Scale section of the Tube Creation controls.

  1. Continue with the scene from the previous section or open the skull_v06.ma scene from the chapter8scenes directory of the DVD.

    The Width Scale controls modify the settings used to define the width of the tubes. To more easily see how the controls work, you can set the Width1 and Width2 sliders to the same value.

  2. In the Creation rollout, set Width1 and Width2 to 0.02.

  3. You can edit the width curve in the Attribute Editor, but sometimes it is easier to edit it in a separate window. Click the arrow button to the right of the Width Scale curve. The curve opens in a new window (Figure 8.33).

  4. Add points to the curve, and move them around to define a shape for the tubes.

    Clicking the arrow button to the right of the curve opens a larger curve for editing.

    Figure 8.33. Clicking the arrow button to the right of the curve opens a larger curve for editing.

    The curve describes the profile of each tube, so to create a bulbous end to the tubes, make the points at the right end of the tube higher and the points on the left end lower. The Selected Position and Selected Value fields allow you to enter numeric values for each selected point. You can type values higher than 1 in the Selected Value slider to make parts of the profile even thicker (see Figure 8.34).

    A test render is created after changing the profile of the tubes using the Width Scale Editor.

    Figure 8.34. A test render is created after changing the profile of the tubes using the Width Scale Editor.

    The Interpolation controls set the smoothness of the line to the right of the selected point. To make a more curved profile, set Interpolation to Smooth or Spline.

  5. Create test renders as you make changes to the curve to see how the profile will look (Figure 8.34).

  6. Save the scene as skull_v07.ma. To see a version of the scene to this point, open the skull_v07.ma scene from the chapter8scenes directory on the DVD.

Tube Color

The controls for setting the color of tubes are found in the Shading section of the brush Attribute Editor under Tube Shading.

  1. Open the skull_v06.ma scene from the chapter8scenes directory, or return to your own saved version of the scene.

  2. Select the strokeDefaultPaint1 brush in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. Under Shading, expand the Tube Shading section.

  4. Click on the Color2 swatch, and use the Color Chooser to select a reddish-brown color.

    The color at the base of the tube is determined by the settings in the Color1 control in the Shading section. The Color2 slider determines the color at the tip of the tube. You can also control incandescence and transparency at the tube tips using the Incandescence2 and Transparency2 controls.

    To add variation to the tubes, you can use the Rand sliders. Hue Rand varies the hue of the tubes; the higher the value, the more variation in the colors of the tubes. Similarly the Sat Rand slider randomizes color saturation, and the Val rand slider randomizes value.

  5. Set the Val Rand slider to 0.125.

  6. The Root Fade and Tip Fade sliders add transparency to the ends of the tubes. Set Root Fade to 0.025 and create a test render. Figure 8.35 shows the results of changing the Tube Shading settings.

    Edit the tube colors by using the controls found in the Tube Shading section of the Attribute Editor.

    Figure 8.35. Edit the tube colors by using the controls found in the Tube Shading section of the Attribute Editor.

Tube Direction

The sliders in the Tube Direction section control the overall direction in which the tubes point. As you develop your own custom brushes, you're likely to return to this section a lot because changes further in the process may require you to tweak the tube direction.

You're likely to constantly experiment with these controls as you work, but it's good to have an understanding of what the controls actually do.

Setting Tube Direction to Along Normal makes the tubes point in a direction based on the normal of the path curve. Usually this means perpendicular to the curve itself. Setting Tube Direction to Along Path means the tubes point in the direction of the path.

Elevation refers to the direction the tubes point up and down, relative to the path. If you were lifting a flagpole to position it in the ground, the elevation of the pole at 0 would mean the flagpole is lying on the ground, and an elevation of 1 would mean the flagpole is sticking straight up out of the ground. Values above 1 push the flagpole over in the opposite direction.

Azimuth refers to the direction the tubes point as they rotate around their origin on the path. If you pointed a flashlight straight in front of you, the azimuth of the light beam would be 1. If you pointed it 90 degrees to the side, the azimuth would be 0.5. At 1.5 the flashlight would point in the opposite direction from 0.5 (see Figure 8.36).

The top image demonstrates changes in the elevation of a 3D arrow. The bottom image demonstrates changes in the azimuth of a 3D arrow.

Figure 8.36. The top image demonstrates changes in the elevation of a 3D arrow. The bottom image demonstrates changes in the azimuth of a 3D arrow.

Together the sliders can be used to define a range of elevation and azimuth for the tubes. How these sliders work is affected by the setting used in Tube Direction. Keep in mind that if Elevation Min and Elevation Max are both set to 1, changing the azimuth will have no effect.

  1. Set Tube Direction to Along Normal.

  2. Set Elevation Min to 0.273, Elevation Max to 0.843, Azimuth Min to −0.686, and Azimuth Max to 0.256, as shown in Figure 8.37.

  3. Save the scene as skull_v08.ma.

The direction of the tubes is controlled using the Elevation and Azimuth sliders.

Figure 8.37. The direction of the tubes is controlled using the Elevation and Azimuth sliders.

Add Growth

You can increase the complexity of the objects you create with Paint Effects by adding branches, leaves, twigs, flowers, and buds. These elements grow from tubes and can be used to create very natural-looking organic objects.

Paint Effects Tubes use L-systems to control the growth of tubes, branches, and twigs. An L-system is a mathematical language developed by the Hungarian botanist Aristid Lindenmayer in 1968 to describe the growth of plants. While using Paint Effects you won't need to work directly with L-systems, but if you're curious as to how Paint Effects creates such natural-looking objects, you may want to do some reading on L-systems.

The Growth Controls

The options for adding branches, twigs, leaves and other natural elements are found in the Growth rollout in the brush Attribute Editor (see Figure 8.38).

You can add branches, twigs, leaves, and other elements using the options in the Growth section of the Brush attributes.

Figure 8.38. You can add branches, twigs, leaves, and other elements using the options in the Growth section of the Brush attributes.

These options are:

Branches

Activating this option creates one or more splits in the growth of Paint Effects tubes.

Twigs

Activating Twigs creates additional tube sections that grow from both the tube and the tube branches.

Leaves

Leaves are a secondary set of tubes that grow off of the main tubes. There are controls available for coloring and shaping leaves that are very similar to the controls available for tubes.

Flowers

Flowers are similar to leaves in that they are another tube system that grows from the original tubes. A variety of controls allow you to simulate real flowers, such as roses, or to create your own unique flowers.

Buds

Buds are tiny tubes that are placed at the ends of branches and leaves.

These elements can be added in any combination. It's usually a good idea to start out by adding one element at a time to limit the amount of confusion that can be caused by working with so many controls.

The elements can be used to imitate real plants, and they can also be repurposed to create any number of custom objects. Flowers can be turned into eyeballs; leaves can become hands. The names given to these elements describe the basic idea behind how they work, but they are not limited to replicating just plants.

Adding Branches and Twigs

In this section, you'll continue to experiment by making edits to the tubes growing along the skull and pedestal.

  1. Continue with the scene from the previous section or open the skull_v08.ma scene from the chapter8scenes directory on the DVD.

  2. Select strokeDefaultPaint1 in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. Scroll down to the Creation rollout controls, and set Tubes Per Step to 0.25. Reducing the number of tubes improves scene performance and makes it easier to see what's going on.

  4. Scroll down to the Growth section, and activate the Branches option. Expand the Branches controls (see Figure 8.39).

    Adjusting the Branches controls defines how the tubes split into branches.

    Figure 8.39. Adjusting the Branches controls defines how the tubes split into branches.

  5. Set these attributes for the controls:

    • Start Branches: 0.25. This defines the number of branches at the tube root.

    • Num Branches: 2. This specifies the number of branches at each split.

    • Split Max Depth: 2. This sets a limit to the number of branches that can be created.

    • Branch Dropout: 0.1. This prunes the number of branches to create a more natural look.

    • Split Rand: 0.364. This randomizes branch spacing.

    • Split Angle: 30. This sets the angle where the branches split.

    • Split Twist: 0.5. This rotates the branches relative to the root.

    • Split Size Decay: 0.65. As this value approaches 1, the branches become closer in size to the original tube. Making this value larger than 1 produces branches that are larger than the root.

    • Split Bias: −0.339. This moves the split closer or farther from the root. Positive values move the branch split closer to the tip.

    • Min Size: 0. This sets a minimum size for the pruning created using the Branch Dropout control.

    • Middle Branch: Off. When this is on, the tube continues to grow through the middle of the split.

  6. Save the scene as skull_v09.ma.

Twigs are very similar in concept to branches, and their controls are similar to those used in the Creation section of the Attribute Editor. Experiment using twigs with and without branches. Sometimes they can be used to extend branches; sometimes they work well as an alternative to branches.

Adding Leaves and Flowers

Leaves create another set of tubes that grow from tubes, twigs, and branches. You can shape and color them to create some interesting Paint Effects objects.

  1. Continue with the scene from the previous section or open the skull_v09.ma scene from the chapter8scenes directory on the DVD.

  2. Select strokeDefaultPaint1 in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. In the Growth section, activate Leaves. Immediately the leaves look huge compared to the rest of the Paint Effects brush.

  4. Scroll down to the Leaves controls. Set Leaf Length to 0.022, Leaf Base Width to 0.058, and Leaf Tip Width to 0.05.

  5. The leaf size and shape can be edited using the Leaf Width Scale curve. This is similar to the Tube Width controls discussed earlier in the chapter. Expand the curve control by clicking the arrow button to the right of the curve, and make changes.

    If you shape the leaf using the profile curve, you'll need to set Brush Type to Mesh; otherwise the changes made using the curve won't show up in the render.

    You can map an image to the leaves to increase the realism of the Paint Effects brush. A leaf is used in this example, but keep in mind that you can use anything you want.

  6. Set Leaf Color 1 and 2 to white. Scroll down and uncheck the option for Leaf Use Branch Tex. Click the folder next to Image Name, and use the file browser to find the leaf.tif image in the chapter8sourceimages folder on the DVD.

    The leaf image has an alpha channel, which can be used to define the shape of the leaf.

  7. Remove any changes made to the Leaf Width Scale curve so it appears as a solid gray box.

  8. Create a test render of the image (see Figure 8.40).

    Map an image to the leaves to create more realism.

    Figure 8.40. Map an image to the leaves to create more realism.

  9. Set Brush Type to Mesh. Images will work on both Mesh and Paint brush types, but some of the deformations you can apply to the leaves look better when Brush Type is set to Mesh.

  10. Try experimenting with different settings for Leaf Curl, Leaf Twirl, Leaf Hue Rand, Leaf Sat Rand, Leaf Bend, and Leaf Val Rand. Increasing the Leaf Segments value will improve the quality when you increase the Leaf Bend settings.

    Lowering the Leaf Flatness setting creates a more three-dimensional shape. This works well when you shape the profile of the leaf using the Leaf Width Scale curve editor.

    Activating Leaf Forward Twist ensures that the leaf always faces the rendering camera.

  11. Save the scene as skull_v10.ma. To see a version of the scene to this point, open the skull_v10.ma scene from the chapter8scenes directory on the DVD.

Flowers are very similar to leaves. To add flowers, activate the Flowers options under Growth. To change the size of the flowers, use the Petal Length, Petal Base Width, and Petal Tip Width sliders in the Flowers section of the Attributes.

Shaping Strokes with Behavior Controls

The controls found in the Behavior section of the brush attributes are similar to deformers that you apply to models. You can use behaviors to shape the strokes and control how they appear in the scene.

Forces

You'll continue using the skull-and-pedestal scene to see how the stroke can be further shaped using the settings in the Behavior section of the brush node.

  1. Continue with the scene from the previous section or open the skull_v10.ma scene from the chapter8scenes directory on the DVD.

  2. Select strokeDefaultPaint1 in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. In the Growth section, deactivate Leaves so that you can clearly see the tubes and branches crawling on the skull.

  4. Scroll down, and expand the Behavior rollout.

    The order in which these settings are placed in the Attribute Editor is not exactly intuitive. Displacements are listed above Forces, but I have found that it's easier to work with the Forces settings first to establish a shape to the strokes and then use the Displacement settings to add detail to the shape of the strokes.

  5. Expand the Forces rollout.

    The various controls in the Forces rollout offer different ways of pushing and pulling the strokes. They can be used separately or in combination. Once again, applying these settings is an experimental process.

  6. Increase the Path Follow slider—this causes the strokes to grow along the length of the path used to define the stroke. A setting of 1 causes the strokes to cling to the original path. A negative value makes the strokes grow in the opposite direction.

  7. Set Path Follow to 0 and try adjusting Path Attract. This slider causes the original stroke to influence the growth of the tubes and branches. Increasing this value makes the tubes bend toward the path; decreasing this value makes the tubes bend away.

  8. Set Path Follow to 0.256 and Path Attract to −0.4.

    The Curve Follow and Curve Attract settings work the same way as Path Follow and Path Attract; however, they use a separate control curve rather than the original path curve. If there is no control curve present, these settings have no effect.

    To add a control curve, draw a curve in the scene. Select the strokes in the Outliner and the curve, and choose Paint Effects

    Forces
  9. Set Random to 0.5 to add some additional randomization to the direction in which the strokes grow.

    The Uniform Force and Gravity controls apply a force to the strokes along a specified axis. You can define the axis of influence by entering numeric values in the Uniform Force fields. By increasing the Gravity slider, the force is applied in the negative Y direction.

  10. Set Gravity to 0.5.

    When applying forces, you may find that the strokes are getting pushed through the surface they have been painted on. You can use deflection to fix this.

  11. Turn Deflection on and set Deflection Max to 0.107. If you zoom into the pedestal surface, you can see the stroke is raised above the surface when Deflection is activated. The settings are shown in Figure 8.41.

    Forces are used to push the strokes along the original stroke path.

    Figure 8.41. Forces are used to push the strokes along the original stroke path.

Displacement, Spiral, and Bend

You can add details to the stroke shape using the sliders in the Displacement section. It is sometimes easier to add displacements after adding forces.

Displacement Delay causes the changes made with the Displacement controls to be stronger toward the ends of the tubes. Setting this to 0 means that displacements are applied along the length of the tube.

The Noise, Wiggle, and Curl sliders add tiny bends to the tubes and branches to create randomness. A larger Frequency value adds more detail to the changes. The Offset sliders are used when animating these attributes. Keyframing the offset over time will make the strokes appear to wiggle, curl, or move randomly. We'll discuss other stroke-animation techniques later on in the chapter. The following example shows how you can change the shape of the strokes using Displacement, Spiral, and Bend.

  1. Try the following settings:

    • Displacement Delay: 0.074

    • Noise: 1

    • Noise Frequency: 0.1

    • Wiggle: 0.3

    • Wiggle Frequency: 2

    • Curl: 0.326

    • Curl Frequency: 5

    Figure 8.42 shows the result.

    The Spiral and Bend settings toward the bottom of the Displacement controls are an additional set of controls that define the shape and behavior of the strokes.

    You can add detail to the stroke shape using the controls in the Displacement settings.

    Figure 8.42. You can add detail to the stroke shape using the controls in the Displacement settings.

    Spiral and Bend are similar except that increasing the Spiral attribute creates a curve in the tubes, leaves, and flowers that bends the stroke around the stroke normal, whereas increasing the Bend attribute curves the stroke bend along the direction of the path. Once again, the best way to understand these behaviors is through experimentation.

  2. Set Spiral Min to 0.107 and Spiral Max to 0.355. Set Spiral Decay to 0.5.

    Positive Spiral Decay values create tighter spirals; negative values create looser spirals.

    Set Spiral Min and Spiral Max back to 0. Set Bend to 3.4 and Bend Bias to 0.554.

    Bend Bias determines where, along the length of the tube, the bend starts. A Bias value of 0 makes the bend start at the base. Higher values cause the bend to be closer to the tip.

  3. Set Spiral Min to 0.107 and Spiral Max to 0.355. Turn Leaves back on and create a test render (Figure 8.43).

  4. Save the scene as skull_v11.ma.

The vines are bent and twisted around after the Spiral and Bend settings are applied.

Figure 8.43. The vines are bent and twisted around after the Spiral and Bend settings are applied.

Animating Strokes

There are a number of ways that Paint Effects strokes can be animated. Animation creates the sense that the strokes are alive and organic. Even a small amount of animation can have a major impact on the mood of a scene. In this section, you'll learn some of the techniques available for animating Paint Effects.

Animating Attribute Values

As you have no doubt noticed, a Paint Effects brush has a large number of attributes. Almost every single one of these can be animated using keyframes, expressions, driven keys, and textures. There's almost no limit to the number of wild effects that you can achieve by animating attribute values. This section demonstrates just a couple creative ways to keyframe the attributes.

  1. Open the skull_v07.ma scene from the chapter8scenes directory on the DVD. In this version of the scene, the strokes are shaped using the Width Scale curve so their ends are bulbous.

  2. Select the strokeDefaultPaint1 stroke in the Outliner, and open the Attribute Editor to the defaultPaint6 tab. Scroll down to the bottom of the Attributes section, and expand the Behavior controls.

  3. Expand the Displacement rollout, and set Wiggle attribute to 0.12.

  4. In the field next to Wiggle Offset, type =time;. This creates a very simple expression that sets the Wiggle Offset value equal to the current time (in seconds). See Figure 8.44.

    Add a simple expression to the Wiggle Offset attribute.

    Figure 8.44. Add a simple expression to the Wiggle Offset attribute.

  5. Set the timeline to 200 and play the animation. The strokes wiggle as a sinusoidal pattern moves along the length of the stroke.

  6. Rewind the animation. Scroll up to the Tube Shading section, and set the color of the tubes to a bright red.

  7. Set the Hue Rand value to 0.5. Right-click this value and choose Set Key.

  8. Move the timeline to frame 20. Set Hue Rand to 1, and set another key.

  9. Open the Graph Editor (Window

    Add a simple expression to the Wiggle Offset attribute.
  10. Select the keyframes on the graph, and choose Tangents

    Add a simple expression to the Wiggle Offset attribute.
  11. Select the animation curve, and choose Curves

    Add a simple expression to the Wiggle Offset attribute.
  12. Close the Graph Editor, rewind, and play the animation. The colors of the tubes now change over time.

Edit the animation curve for the Hue Rand attribute in the Graph Editor.

Figure 8.45. Edit the animation curve for the Hue Rand attribute in the Graph Editor.

Adding Turbulence

Paint Effects strokes have built-in Turbulence controls that are similar to the fields used with a dynamic system, such as nCloth and nParticles. Adding turbulence is very simple, and you can choose among several types of turbulence.

  1. Open the skull_v11.ma scene from the chapter8scenes directory.

  2. Select the strokeDefaultPaint1 stroke in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. In the Creation controls, set Tubes Per Step to 0.1. Under Growth, turn off Leaves.

  4. Toward the bottom of the Attribute Editor, expand the Behavior rollout. Within the Behavior settings, expand the Turbulence settings. Take a look at the options in the Turbulence Type menu.

    The options are Off, Local Force, World Force, Local Displacement, World Displacement, Grass Wind, and Tree Wind.

    Turbulence as a force causes the ends of the tubes to move back and forth as though the turbulence is moving laterally through a field of tubes. Turbulence as a displacement causes the tubes to bob up and down so the strokes are being displaced based on the normal of the stroke.

    You can choose to have the turbulence force or displacement applied in local or world space. World space is generally a better option if you want a number of separate strokes to appear as though they are all affected by the same turbulence.

    Grass Wind and Tree Wind are similar in that the turbulence affects the ends of the tubes more than the roots so it appears as though the strokes are blowing in the wind. Grass Wind affects the tips of the tubes; Tree Wind affects the tips of branches. Both forces are applied using world space coordinates. The options are shown in Figure 8.46.

    The interpolation adjusts the quality of the turbulence. A linear setting causes a jerkier, random motion; Smooth Over Time and Smooth Over Time And Space create a more natural motion. Smooth Over Time And Space offers the highest quality, while Linear and Smooth Over Time work better for higher turbulence speeds.

  5. Set Turbulence Type to Tree Wind and Interpolation to Smooth Over Time.

  6. Set Turbulence to 1, Frequency to 0.405, and Turbulence Speed to 0.174.

  7. Play the animation. To get a sense of how the branches behave, create a Playblast.

  8. Save the scene as skull_v12.ma.

You can choose from a number of different types of turbulence.

Figure 8.46. You can choose from a number of different types of turbulence.

Animating Growth

The most interesting way to animate a stroke is to animate its growth using the Flow Animation controls. Flow animation animates the growth of tubes, branches, leaves, twigs, and flowers along the path of the stroke.

  1. Continue with the scene from the previous section or open the skull_v12.ma scene from the chapter8scenes directory on the DVD.

  2. Select the strokeDefaultPaint1 stroke in the Outliner, and open the Attribute Editor to the defaultPaint6 tab.

  3. Scroll to the bottom of the attribute list, and expand the Flow Animation controls. Set Flow Speed to 1.

  4. Turn on the options for Stroke Time and Time Clip. When Time Clip is enabled, the display of the strokes automatically converts to wireframe; this does not affect how the strokes appear in the render.

    If Stroke Time is on, the tubes at the start of the stroke will grow first, and the tubes at the end of the stroke will grow last, so that the growth moves along the path of the stroke. If Stroke Time is off, all of the tubes grow at the same time.

    Time Clip enables the growth animation. If this option is off, the strokes will not grow. However, if Texture Flow is on and Time Clip is off, textures applied in the Texturing section appear to move along the tubes. This is a great way to animate things like blood cells moving through blood vessels.

    Time Clip uses the Start and Time values to establish the beginning and end of the animation. These values refer to seconds. So if your animation is set to 24 frames per second and you enter 2 for the start time, the growth will not begin until frame 48 (24 × 2).

    The End time is usually set to a high value, but you can create very interesting effects by lowering this setting. If the End time is within the range of the animation, the strokes will appear to fly off of the path as they disappear from the root of each tube. This is great for creating the look of fireworks or solar flares.

  5. Play the animation and observe the growth of the vines. The Flow Animation controls combined with turbulence give a very creepy look to the animation.

  6. Try setting the End time to 1, and play the animation.

  7. Save the scene as skull_v13.ma.

Modifiers

Modifiers can be used to affect specified regions of a stroke. A modifier appears as a sphere or a cube. The modifier's position, rotation, and scale can be animated. You can use this when an object or character moves past Paint Effects strokes and you'd like the strokes to react to the object or character's movement. The modifier can be attached to the object or character.

To add a modifier, select one or more strokes, and choose Paint Effects

Modifiers

Rendering Paint Effects

When Maya renders Paint Effects strokes, they are added to the image after the rest of the image has been created. This is known as post-process. Because the strokes are rendered after the rest of the scene elements have been rendered, very complex Paint Effects objects can render very quickly. However, it takes a little work to smoothly integrate Paint Effects into a realistic rendering.

Paint Effects are rendered normally using Maya Software. At the bottom of the Maya Software Tab in the Render Settings window are a number of options specific to Paint Effects. Strokes will not render unless Stroke Rendering is enabled. You can improve the quality of rendered strokes by enabling Oversampling, and you can also choose to render only the strokes by themselves.

Illumination

There are two ways to light Paint Effects strokes in the scene. You can use the scene lights or a default Paint Effects light. In the Illumination section of the Brush attributes, you'll find the controls for these options.

If the Illumination option is not checked, the strokes render as a flat color using the color specified in the Shading options of the Brush attributes. If the Real Lights option is not selected, then you can specify the direction of the default Paint Effects lights numerically using the Light Direction fields.

The Lighting Based Width option alters the width of the tubes based on the amount of light they receive.

There are a number of options, including Translucence and Specular, that affect the shading of the strokes and tubes when they are lit (see Figure 8.47).

The Illumination options determine how strokes react to lighting.

Figure 8.47. The Illumination options determine how strokes react to lighting.

Shadow Effects

Paint Effects strokes can cast shadows in a number of different ways. The options are set in the Shadow Effects controls in the Brush attributes.

If you want the shadows to be cast based on the actual lights in the scene, activate Real Lights in the Illumination options, set the Fake Shadow option to None, and activate the Cast Shadows option at the bottom of the Shadow Effects section. To change the quality of the shadows, you should use the Shadow controls for the lights in the scene (see Figure 8.48). The other options in the Shadowing section of the Brush attributes will have no effect on the render. Paint Effects works only with Depth Map shadows (shadows are covered in Chapter 9).

Paint Effects also has a number of controls for creating fake shadows. You can use 2D Offset to create a simple drop shadow, much like a drop-shadow effect created in a paint program such as Photoshop. You can also create fake 3D cast shadows. When you select 3D Cast in the Fake Shadows menu, Paint Effects creates an invisible plane beneath the surface of the stroke. Shadows are cast onto this plane and rendered in the scene (see Figure 8.49).

To cast shadows from scene lights, activate the Real Lights and the Cast Shadows options in the Brush attributes.

Figure 8.48. To cast shadows from scene lights, activate the Real Lights and the Cast Shadows options in the Brush attributes.

Some of the options available include the following:

Shadow Diffusion

Increasing this setting softens the edge of the shadows.

Shadow Offset

This determines the distance between the stroke and the 2D Offset fake shadow type. This option is not available for 3D cast shadows.

Shadow Transparency

Increasing this value makes the fake shadow more transparent.

Back Shadow

This darkens the areas of the stroke that face away from the light source.

Center Shadow

This is useful when painting a clump of strokes, such as tall grass. The areas inside the clump are shaded darker than the areas that are more exposed to light. This makes a clump of strokes look more realistic.

Depth Shadow

This darkens the tube based on its distance from the surface or path. When you increase this setting, you can fine-tune the look by choosing Path Dist or Surface Depth from the Depth Shadow Type menu. Path Dist darkens the parts of the stroke that are closer to the path; Surface Depth darkens parts of the stroke that are close to the surface.

Depth Shadow Depth

If the distance between the stroke and the shadow-receiving surface is greater than this setting, the shadow will not appear.

These two strokes demonstrate the difference between the two types of fake shadows. The top stroke uses 2D Offset; the bottom uses 3D Cast.

Figure 8.49. These two strokes demonstrate the difference between the two types of fake shadows. The top stroke uses 2D Offset; the bottom uses 3D Cast.

Rendering Strokes with mental ray

If you need to render Paint Effects strokes using mental ray, the best way to accomplish this is to convert the Paint Effects strokes into geometry. You can convert strokes into polygons or NURBS geometry. When you do this, Maya automatically creates a shader and applies it to the converted surface. The shader attempts to replicate any shading and texturing applied to the stroke in the brush panel. However, you'll most likely need to tweak the shader a little (or replace the shader with one of your own) to get the best results. A new shader is created for each stroke, so if you have a grass lawn made up of 30 strokes, Maya creates 30 identical shaders. You may want to apply one shader to all of the strokes and then delete the unused shaders.

To convert the stroke to polygons, select it and choose Modify

Rendering Strokes with mental ray
A Paint Effects tree is converted into a polygon model. Shaders for the model are automatically generated and appear in the Hypershade.

Figure 8.50. A Paint Effects tree is converted into a polygon model. Shaders for the model are automatically generated and appear in the Hypershade.

When you convert strokes to polygons, there is a limit to the number of polygons that Maya can generate. This limit can be adjusted in the options for Convert Paint Effects To Polygons. If the conversion exceeds the polygon limit, you'll see a warning, and the resulting geometry will be incomplete.

To convert the stroke to NURBS, select the stroke and choose Modify

A Paint Effects tree is converted into a polygon model. Shaders for the model are automatically generated and appear in the Hypershade.

When converting Paint Effects to geometry, you can choose to hide the original strokes in the scene; this option is on by default. There is a history connection between the converted stroke and the geometry, so any animation applied to the stroke will be carried over to the geometry.

If you convert a stroke that uses flow animation into polygons, you may find that at some point during the growth of the stroke the polygon limit is exceeded. To avoid this, set the timeline to the end of the stroke's growth when it has reached its full length, and then convert the Paint Effects to polygons. You'll get a warning if the limit is exceeded. You can then take measures such as reducing the number of tubes or re-creating the animation using a number of shorter strokes.

Toon Shading

You can make your 3D objects and characters look as though they are hand-drawn cartoons using Toon Shading. Toon Shading is simple to apply and use, and it generally renders very quickly.

Toon Fills

A toon fill is simply a ramp shader that you apply to the objects in a scene. There are several Fill presets you can apply from the Maya Rendering menu set. Each one is a ramp shader with different settings designed to give you a starting point from which you can design your own custom look.

  1. Open the toon_v01.ma scene from the chapter8scenes folder on the DVD. The scene consists of several cartoon mushrooms on a hill. There is also a directional light in the scene.

  2. In the perspective view, switch to the shotCam camera. Switch to the Rendering menu set, and choose Toon

    Toon Fills
    Choose a background color for the scene.

    Figure 8.51. Choose a background color for the scene.

  3. To use the preset fills, select an object and choose Toon

    Choose a background color for the scene.
  4. Create a test render using Maya software (choose Production Quality from the Quality presets). Compare the look of the different shaders (see Figure 8.52).

  5. Open the Hypershade to see the newly created shaders. Select one of the shaders and change its settings in the Attribute Editor.

  6. Try some of the other presets, such as Dark Profile and Rim Light.

All of the Fill presets are created from ramp shaders. Ramp shaders use ramps to apply a color to the surface based on an input, such as light angle, facing angle, or brightness. You can add or remove colors from the various ramps by clicking them in the Attribute Editor. The Interpolation option determines the smoothness of the transition between each color in the ramp (see Figure 8.53).

You can apply fills to objects using the presets in the Toon menu.

Figure 8.52. You can apply fills to objects using the presets in the Toon menu.

Toon fills are created from ramp shaders. The settings can be adjusted in the Attribute Editor to customize the look of the fill.

Figure 8.53. Toon fills are created from ramp shaders. The settings can be adjusted in the Attribute Editor to customize the look of the fill.

Toon Outlines

Toon outlines are a special type of Paint Effects stroke. When you add a Paint Effects toon outline to an object and then rotate the object or the camera, the outline adjusts its position automatically so that it always remains on the contour of the object regardless of the viewing angle.

  1. Open the toon_v02.ma scene from the chapter8scenes directory on the DVD. This version of the scene has the same mushrooms as toon_v01.ma. In this case, fill shaders have already been applied to the mushroom characters.

  2. In the Outliner, Shift+click the hill and each mushroom group. Choose Toon

    Toon Outlines
  3. Select the pfxToon1 node in the Outliner, and open the Attribute Editor. Select the pfxToonShape1 tab. This is where you'll find all of the settings for tuning the look of toon lines. The toon lines are visible in the viewport window as well.

  4. Expand the Common Toon Attributes, and set Line Width to 0.025. Create a test render in the render view from the shotCam camera.

  5. Save the scene as toon_v03.ma. To see a version of the scene to this point, open the toon_v03.ma scene from the chapter8scenes directory (see Figure 8.54).

    Toon lines are applied to the contours of the mushroom characters.

    Figure 8.54. Toon lines are applied to the contours of the mushroom characters.

There are a large number of settings you can use to control the look of the toon lines. Some of the more important settings are listed here:

Profile Lines

A profile line is the line that is attached to the contours of the geometry. If you draw an apple on a piece of paper, the line that describes the outside edge of the apple is the profile line. Profile lines can be Paint Effects strokes or an offset mesh. An offset mesh is a copy of the surface that is scaled slightly larger than the original. The faces of the offset mesh are inverted to create the look of toon lines. This technique can be used when rendering with mental ray.

Border Lines

These lines can be set to appear at the open edge of geometry, such as the lip of a cup. They can also appear at the border between two shaders that have been applied to the geometry or both.

Crease Lines

These lines appear at the hard edges of geometry, such as the corner edge of a cube.

Intersection Lines

These appear at the intersection of two pieces of geometry. In the mushroom scene, the base of each mushroom character intersects with the geometry of the hill. If intersection lines are activated, a line will appear where these two surfaces meet.

In the lower section of the Attribute Editor there are settings available to control how each of these types of lines appears. You can edit their color, width, and specific attributes that apply to these types of lines.

Using Paint Effects Presets for Toon Lines

You can replace the toon lines assigned to a model with a Paint Effects preset. You can use any brush available in the Visor or any brush that you create. The process for doing this is very simple.

  1. Continue with the scene from the previous section or open the toon_v03.ma scene from the chapter8scenes directory on the DVD.

  2. Choose Window

    Using Paint Effects Presets for Toon Lines
  3. Choose the brokenWiggle.mel brush from the Toon presets. The icon should turn yellow when its selected, indicating that it's the currently loaded brush.

  4. Select the pfxToon1 node in the Outliner, and choose Toon

    Using Paint Effects Presets for Toon Lines
  5. Create a test render of the scene. You may want to increase the Line Width setting in the pfxToon1 node to see the line more clearly.

The brokenWiggle brush now replaces the original toon lines (see Figure 8.55). You can edit the settings on the pfxToon1 node to change how the toon lines behave. You also now have the brokenWiggle1 brush attributes available. These attributes work just like any other Paint Effects brush.

The toon lines are replaced by the brokenWiggle Paint Effects stroke.

Figure 8.55. The toon lines are replaced by the brokenWiggle Paint Effects stroke.

To edit the settings for the brokenWiggle brush, select the pfxToon1 brush and open the Attribute Editor. You may need to click the right arrow in the upper-right corner of the Attribute Editor about a dozen or so times to find the brokenWiggle1 tab. Alternatively, you can turn off the DAG Objects Only option in the Display menu of the Outliner and select the brokenWiggle1 node.

The Bottom Line

Use the Paint Effects canvas.

The Paint Effects canvas can be used to test Paint Effects strokes or as a 2D paint program for creating images.

Master it

Create a tiling texture map using the Paint Effects canvas.

Paint on 3D objects.

Paint Effects brushes can be used to paint directly on 3D objects as long as the objects are either NURBS or polygon geometry. Paint Effects brushes require that all polygon geometry have mapped UV texture coordinates.

Master it

Create a small garden or jungle using Paint Effects brushes.

Understand strokes.

A Paint Effects stroke has a number of associated nodes that are created and connected when the stroke is painted in the scene. These include the stroke's transform node, shape node, brush node, and curve node. Most of the time you'll edit settings on the stroke's shape node and brush node. You can use brush sharing to connect all of the strokes in the scene to the settings on a single brush node.

Master it

Use the Leafy Vine stroke to add a series of vine strokes to a simple wall model. Change the Global Scale setting of all the strokes at the same time.

Design a brush.

Custom Paint Effects brushes can be created by using a preset brush as a starting place. You can alter the settings on the brush node to produce the desired look for the brush.

Master it

Design a brush to look like a laser beam.

Create tubes.

Tubes are short strokes that grow outward from the main path of the stroke. They can assume a variety of shapes and sizes to create any number of objects.

Master it

Create a paintbrush that resembles the strokes used in Vincent Van Gogh's painting "Starry Night."

Add growth.

Branches, twigs, leaves, flowers, and buds can be added to Paint Effects tubes. You can use these to simulate plants or apply them creatively to design unique shapes.

Master it

Create a mushroom tree using the Cortinarius Mushroom stroke found in the plantsMesh folder of the Visor

Shape strokes with behaviors.

Behaviors are settings that can be used to shape strokes and tubes, giving them wiggling, curling, and spiraling qualities. You can animate behaviors to bring strokes to life.

Master it

Add tendrils to a squashed sphere to create a simple jellyfish

Animate growth.

Paint Effects strokes can be animated by applying keyframes, expressions, or animated textures directly to stroke attributes. You can animate the growth of strokes by using the Time Clip settings in the Flow Animation section of the Brush attributes.

Master it

Animate blood vessels growing across a surface. Animate the movement of blood within the vessels

Render Paint Effects strokes.

Paint Effects strokes are rendered as a post process using Maya software. To render with mental ray, you should convert the strokes to geometry.

Master it

Render an animated Paint Effects tree in mental ray

Use Toon Shading.

Toon Shading uses Paint Effects to create lines around the contours of an object and a ramp shader to color the surface of the object to replicate the look of a hand-drawn cartoon.

Master it

Add glowing contour lines to a futuristic vehicle to imitate the look of a vector-style rendering in a computer display

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset