Shading with the Adobe Illustrator CS5 Mesh Object

Video Link from Adobe TV

/

By Brian Wood

Date: Oct 19, 2010

Return to the article

Simple lines can convey straightforward ideas, but subtlety often requires shading. Brian Wood, contributor to Adobe Illustrator CS5 Classroom in a Book, demonstrates using mesh objects to add gradients to curves. Brian shares his best tips for saving steps and preventing headaches as you work with mesh objects.

In its simplest form, a gradient is a blend from one color to another. Most of us who start out in Illustrator fall in love with gradients. But then we want more. Painting a curved object with a gradient, we wonder, "How can I get the gradient to follow the shape of the curve?" The answer: By using a mesh object (also known as a gradient mesh).

When I first read the words mesh object in Illustrator Help, I didn't know what that expression meant. All I wanted to do was apply that cool mesh of color to some object. As with other things in Illustrator, when you apply a mesh to an object, it becomes a "mesh object." That means that it's locked in certain ways. For instance, when you apply a gradient mesh to an object and it becomes a mesh object, you can no longer apply a regular ol' gradient fill to it. (You'll learn later how to remove a mesh from an object.)

A mesh object is basically a gradient on steroids. Gradients are either radial or linear. Illustrator CS4 added new gradient functionality, but it still wasn't enough for certain work. A mesh object takes the gradient further by allowing you to break up the gradient into a patchwork of mesh lines and mesh points. Each of these points and lines creates a smaller grid that can have a unique gradient for blending (see Figure 1).

Figure 1 An example of gradient mesh used in the face and hands. (That's me!)

Before you begin applying a gradient mesh to an object, it's important to note that there are several ways to create a mesh object. You can save time when creating the mesh by using the most efficient method. Here's a list of the most common ways to create a mesh object:

  • Create the mesh object from scratch: Click where you want to position the first mesh point. The object is converted to a mesh object with the minimum number of mesh lines.
  • Create a mesh object from a gradient-filled object: Select the object and choose Object > Expand.
  • Select Gradient Mesh and click OK.
  • Create a mesh object using a regular pattern of mesh points.

In this article, we'll focus on creating a mesh by using the regular pattern of mesh points, and you'll see how to edit that mesh.

Creating a Mesh Object from a Regular Pattern of Mesh Points

The easiest way to get started creating a mesh object (in my opinion) is to create a mesh object from a regular pattern of mesh points. This is probably one of the more widely used methods for a consistent mesh. Here's how it works:

  1. Select the object that you're going to turn into a mesh object.

NOTE

You can't apply a mesh to a compound path or a text object.

  1. Apply a color fill to the object that will be used in the mesh. For instance, if you chose an ellipse that will become an orange, apply an orange color to it so that the mesh uses mostly orange. (You'll see what I mean in the next few steps.)
  2. Choose Object > Create Gradient Mesh.
  3. In the Gradient Mesh dialog box, you can change the number of rows and columns, which determines how many mesh patches are created. The greater the number of rows and columns, the greater the number of mesh patches. The more mesh patches, the more complex the gradient mesh. For this example, keep the number of rows and columns set at 4.

TIP

Try to keep the number of rows and columns to a minimum. This takes practice. It's like drawing with the Pen tool—what's the smallest number of points I can use to create a certain shape? Keeping the number small helps later, when redrawing and printing.

  1. In the Appearance menu, choose To Center. You can choose the direction of the highlight (To Center or To Edge), or you can remove the highlight (choose Flat). Try choosing each option and selecting Preview to see the effect on the object.
  2. Change the Highlight value to 80% (see Figure 2). Choosing 100% applies a solid white highlight, and choosing 0% removes the highlight.
  3. Click OK to create the gradient mesh.

Figure 2 Creating a gradient mesh by using a regular pattern of mesh points.

As I mentioned previously, the gradient mesh is made of mesh points with interconnecting mesh lines. When you first create a mesh object, the only colors applied are the original color and white, with shades in between. Each of the mesh points can have a different color or transparency applied. Not only can you add or subtract mesh points or move them to suit your needs, but you can also change the color of each mesh point. We'll try that next.

Editing the Colors of a Gradient Mesh

There are two main ways to edit the colors of a gradient mesh: by editing the color of each mesh point, and/or by editing a mesh area. We'll look at how to make each change so you'll understand why two methods are available.

  1. Click the Mesh tool in the Tools panel.
  2. Position the pointer over the mesh object. Most of the time, a plus sign (+) appears next to the cursor. Now position the pointer over the center point of the mesh. Notice that the plus disappears. The plus indicates that you can add another mesh point (and another set of mesh lines). The cursor without a plus sign indicates that you can edit a point. Click the center point of the mesh to select it.
  3. Make sure that the Fill box is chosen in the Tools panel. Then, by using the Color panel, the Swatches panel, or any other method for making color, choose another color. The color assigned to that point is changed.
  4. With the Mesh tool, click one of the edge points and apply a color in the same way (see Figure 3).

Figure 3 Editing the color of mesh points.

What if you wanted to edit a series of points at the same time, applying the same color? Easy:

  1. Select the Direct Selection tool in the Tools panel.
  2. Either hold down the Shift key and click a series of points on the edge of the shape, or drag a selection marquee across a series of points to select them.
  3. Change the color of the points by using the same method as you used in the preceding steps (see Figure 4).

Figure 4 Editing the color of multiple mesh points.

Another method for editing color in a gradient mesh is to apply color to a mesh patch. See what I mean by following these steps:

  1. With the Direct Selection tool selected, click in an area within the shape (not on a point or line). This action selects all of the points around that area.
  2. Change the color fill of the area, using the same method as previously discussed. This is a way to apply color to a larger portion of the mesh, called a mesh patch (see Figure 5).

Figure 5 Changing the fill color of a mesh patch.

TIP

You can also Shift-click a series of mesh patches with the Direct Selection tool to apply color to a larger area.

Moving the Points of a Gradient Mesh

In addition to editing the color, you can determine the location of the mesh points and mesh lines. This is where some of the real power of using gradient meshes comes into play. By moving mesh points, you can distort the gradient:

  1. After selecting the mesh object with the Selection tool, select the Mesh tool in the Tools panel.
  2. Position the pointer over a central point in the mesh. Notice that the plus sign disappears from the pointer.
  3. Click-and-drag the center point of the mesh a bit down and to the right. Notice that the mesh lines follow and the color in the center shifts down and to the right. This is because the color is associated with that mesh point.
  4. To undo the move, choose Edit > Undo Move Mesh Point (see Figure 6).

Figure 6 Dragging a mesh point.

You can also move an entire mesh patch (a series of mesh points) by using the Direct Selection tool.

  1. Select the Direct Selection tool in the Tools panel.
  2. Click-and-drag at some place where there are no mesh points. Notice that you're dragging a mesh patch.
  3. Choose Edit > Undo Move.
  4. Click in a mesh patch again (between mesh points).
  5. Shift-click other mesh points that are currently deselected, to add them to the selection.
  6. Click in the middle of the select points and drag upward, downward, left, or right. Watch what's happening to the mesh patch onscreen (see Figure 7).

NOTE

If you attempted to move a mesh patch with the Mesh tool, a new mesh point would be added instead.

  1. Choose Edit > Undo Move.

Figure 7 Dragging a mesh patch.

TIP

You can also move mesh points on a mesh line by selecting the mesh point with either the Direct Selection tool or the Mesh tool and pressing any of the arrow keys on your keyboard to move the selected mesh point(s) in the indicated direction. Pressing Shift while using the arrow keys moves the selected mesh point(s) 10 times as far.

Next, let's move the mesh points on the mesh lines to distort the gradient:

  1. Select the Mesh tool in the Tools panel.
  2. Shift-click a mesh point and drag it horizontally. Notice that with the Shift key held down, you can only move the mesh point along the mesh line horizontally.
  3. To undo the move, choose Edit > Undo Move Mesh Point.
  4. Try the same process, but dragging vertically.
  5. Choose Edit > Undo Move Mesh Point (see Figure 8).

Figure 8 Constraining the movement of a mesh point.

Adding or Deleting Points in a Gradient Mesh

In addition to moving the points of a gradient mesh, you can add or subtract mesh points and lines. Subtracting mesh points allows you to create a simpler mesh with less distortion. Adding mesh points, on the other hand, makes your gradient mesh more complex, with more different colors or shades of a single color. More points can be very beneficial when you're attempting to produce realistic artwork (such as a person's face) or a greater variety of gradient, for instance. Let's try it:

  1. Deselect the mesh object on the page.
  2. Select the Mesh tool, if it's not already selected, and position the pointer over the center mesh point. Hold down the Alt (Windows) or Option (Mac) key. A minus sign (-) appears next to the pointer. Click the point to remove that point and its associated mesh lines.
  3. To add a point, position the pointer over the object in a blank area. When the plus sign appears to the right of the pointer, click to add another mesh point.

Notice that a new mesh point and lines are added. Also notice that the color assigned to the mesh point is the same color that was at that spot in the object—it hasn't changed (see Figure 9).

If you want to add a mesh point and add another color to the mesh object, you need to select the color first.

Figure 9 Adding and subtracting mesh points and mesh lines.

  1. Deselect the mesh object by choosing Select > Deselect.
  2. With the Mesh tool selected, choose a fill color in the control panel (or elsewhere) that's different from the mesh object's colors.
  3. Position the pointer over the mesh object. Click in a blank area when the plus sign appears next to the pointer (see Figure 10).

Figure 10 Adding a mesh point and a different color.

TIP

If you've selected a color, and you don't want to apply that color to the mesh, you can Shift-click the mesh object with the Mesh tool to add a mesh point that simply uses the existing color in the object.

Distorting the Points of a Gradient Mesh

Moving, adding, and deleting points is great, but if you want to expand the mesh possibilities, you can also distort the mesh point handles to create more "organic" gradients. Here's how it works:

  1. Deselect the mesh object on the page.
  2. With either the Mesh tool or the Direct Selection tool, click to select a mesh point. Notice the direction lines that appear. Position the pointer over the end of a direction line. The cursor won't display a plus or a minus at this point. Click-and-drag the end of a direction line to distort the mesh in that area.
  3. Choose Edit > Undo Move.
  4. Click and drag the same direction line, but this time hold down the Shift key as you drag. Notice that four direction lines come from the point, and they all rotate together when the Shift key is held down (see Figure 11).

Figure 11 Distorting mesh points by using the direction lines.

Removing a Gradient Mesh from an Object

So what happens if you want the shape and not the mesh applied to it? You can easily remove the mesh from an object by using this simple trick:

  1. Using the Selection tool, select the mesh object on the page.
  2. Choose Object > Path > Offset Path, and enter 0 (zero) for the Offset value (see Figure 12).
  3. This action will outline the object and typically create two objects that you need to separate by using the Selection tool. One object is still filled with a gradient mesh, and the other is a simpler path with no fill.

Figure 12 Removing a gradient mesh from an object.

Tips for Working with a Gradient Mesh

Now that you have most of the basics down for working with a gradient mesh, what next? Following are some techniques for using the gradients effectively. Some of these techniques don't involve the Mesh tool or gradient meshes at all, because sometimes it's easier to create a gradient effect by using other methods.

  • Use global colors! When you're adding colors to a mesh object, make sure that the colors you apply to the gradient mesh points are global colors. Before applying a color swatch in the Swatches panel, double-click the swatch and select Global in the Swatch Options dialog box. This action will save time later. If you get three hours into a mesh project, and then realize that the color you're using for most of the mesh needs to shift just a bit, you can change the global color, and it will update throughout the mesh.
  • Create separate objects whenever possible. One mistake I've made is expecting to create a single shape and simply applying a complex mesh to the object to achieve my color goals. While you might be able to get this technique to work, it's easier in the long run to create multiple objects and apply separate meshes, rather than using one complex object. Figure 13 shows an example. I created a monster with a somewhat complex mesh. Instead of attaching the hands to the arms, I created them separately. This approach allows me to position them differently, and I can more easily create a mesh that follows the contours of the hands.

Figure 13 Create separate objects when you can.

  • Use multiple mesh points. If you want to create the effect of an "edge" in a gradient mesh, create several mesh points in close proximity to each other (see Figure 14).

Figure 14 Creating "edges" in a gradient.

  • Keep it simple. I can't stress this point enough. When you attack a mesh, you want your blends to look a certain way. Believe me, I understand that. But keep it as simple as possible. Using fewer mesh points helps with printing and editing later.
  • Use blends, not gradient mesh in certain areas. Instead of adding gradient details to a complex mesh object, sometimes you can accomplish the same results much more easily with a blend.
  • For instance, suppose you have an image of a face, and you need to add those lines around the mouth that appear in the skin when someone smiles. Here's an easy method to add the detail: Draw one curved line in the shape you want. Copy that line and move it away from the original a bit. Apply two different colors to the strokes of the lines; then select the Blend tool. Click on one line and then the other. With the objects selected, double-click the Blend tool. In the Blend Options dialog box, choose Smooth Color and click OK. There you go! Adjust the lines and the colors, and you have a great little blend that adds detail (see Figure 15).