13 March 2010

How to paint using the Gradient Mesh tool

Gradient Mesh is a grid-based painting technique in Illustrator that enables advanced colouring of vector objects with smooth and malleable color transitions.

If you’re reasonably familiar with Illustrator’s Pen tool and other path-drawing, selection, and colour tools, you can use the Gradient Mesh feature to add realistic colouring, lighting, and 3D characteristics to a flat vector object. Ultimately, gradient mesh can give you the effect of photo-realistic painting with all the benefits and freedom of resolution-independent vector artwork.

The Illustrator Create Gradient Mesh dialog.

Why use a gradient mesh? Gradient mesh is usually compared to three other colour techniques: standard gradients; object blends in Illustrator; or painting in Photoshop or Corel Painter.

Gradient mesh vs. standard gradient: Standard gradients are extremely limited. You can choose between linear gradients, which transition from one colour to the next in a straight line, and radial gradients, in which colours transition between concentric circles. A gradient mesh can transition colors in any direction, in any shape, and can be controlled with the precision of anchor points and path segments.

Gradient mesh vs. object blend: Blending objects in Illustrator involves selecting two or more objects and creating intermediary objects that morph into each other. For example, the blend of a red triangle in front of a blue square would create additional objects between the two that gradually morph the shape and colour of the triangle into those of the square -- at the exact midpoint you get a purple shape that is half triangle, half square. Object blending is an effective way to create irregularly shaped color transitions and gradients, but it’s labour intensive. Each new gradient must be created as two objects -- the starting and ending color object -- and blended individually. A gradient mesh, on the other hand, is a single object inside of which different color areas transition into one another with the effect of a blended object.

Left to right: Colour transitions in a gradient mesh object, an object filled with a standard (radial) gradient, a blended object, and an image coloured in Photoshop

Gradient mesh vs. painting in Photoshop or Corel Painter: Painting in Photoshop or Painter is far easier than creating a gradient mesh. But such painting means working with fixed-resolution pixels. Conversely, a gradient mesh in Illustrator is a resolution-independent vector object, which means you can scale it up or down to infinity and maintain its original quality. Pixel-based imagery loses quality as it’s scaled up. Moreover, colours in a gradient mesh object can be perpetually adjusted and altered, whereas adjusting a painting in Photoshop requires re-painting, potentially destroying data.

Creating a gradient mesh

Creating a gradient mesh is fairly intuitive once you grasp the basics. So let’s get started by colouring a simple tomato via a gradient mesh.

The path that will become a tomato.

Begin by drawing the shape of your tomato as a single closed path with the Pen, Pencil, or shape tools.

Choose a base color for the tomato, and fill the path with that colour. You can pick any colour you like, but for reference I started with RGB: 185, 44, 7.

With the tomato path selected, choose Object->Create Gradient Mesh. You will see the Create Gradient Mesh dialog.

Because a gradient mesh is a grid, when converting a path to a gradient mesh object, you must initially divide the object into expected areas of colour -- you can add and remove rows and columns later. At each intersection of column and row lines within the grid is a mesh point, which behaves very much like -- and may be called on your screen -- an anchor point, which controls the direction and curvature of path segments emanating from it. The difference is that a mesh point can also hold a colour value, and that is the whole point of a gradient mesh. Colours transition between mesh points. For instance, in a 2-by-2 black mesh, colouring the centre mesh point white will create a smooth gradient from that centre point outward in all eight directions -- up, down, left, right, and toward each of the four corners.

A basic 2-by-2 gradient mesh with the
centre mesh point coloured white and
all others coloured black.

In the Gradient Mesh dialog, choose a suitable number of starting columns and rows. How many you start with depends on the size and shape of your tomato or other object. You want enough rows and columns to easily colour the tomato with light, shadow, and different surface colours, but you always want sufficient space between columns and rows that colours will transition smoothly rather than sharply. The further away two mesh points are, the smoother and more subtle the change between their respective colours; the closer two mesh points are together, the sharper the colour transition.

Turn on Preview (if it is not already on) and notice that the mesh lines, which comprise the grid, are not perfectly horizontal and vertical; they adapt to the shape of the object defined by its outer path. Thus dimensionality is often already infused into the gradient mesh object.

To follow my lead, begin with 8 rows and columns. Appearance should be Flat and the Highlight 100 percent. Click OK.

The path converted to an 8-by-8
gradient mesh object.

The tomato is now a gradient mesh object, with all the mesh points selected (notice that they’re filled or selected rather than empty points). Switch to the white arrow Direct Selection tool and individually select a mesh point, and then change its colour by choosing a swatch from the Swatches panel or mixing a new colour from the Color panel. To give the tomato its first highlight, select a mesh point near the top left and colour it white. If the highlight you get is too small, colour other mesh points around the first white.

If the shape of the highlight isn’t exactly what you want, you can move mesh points with the white arrow and even drag their curve handles to reshape the mesh lines attached to them, and thus the direction and depth of their colour transitions. Remember, mesh points behave just like anchor points; the only difference is that they also contain colour data instead of just curve direction and depth data. You can even use the Convert Anchor Point tool on mesh points to change them from smooth to corner points or manipulate the curvature of mesh lines on either side independently.

The initial highlight. There are curve handles
on the mesh points.

If you need more mesh points, switch to the Mesh tool, which is located on the Tools panel between the Column Graph and Gradient tools. When you click with the Mesh tool in a mesh patch, the empty space between rows and columns, you’ll create a new row and column. Clicking the Mesh tool directly on a mesh line, however, will create a row or column—clicking on a vertical mesh line creates a new row at that point, clicking on a horizontal mesh line creates a new column. If you add a new row or column to an area that has already been colored, the resulting mesh points will pick up the colors at the point of insertion.

If you need fewer mesh points, perhaps because colors are transitioning too sharply, hold down the option key and click with the Mesh tool on a mesh point. That will delete the column and row intersecting at that mesh point.

Note that you can also assign color to the mesh points at the outside of your path shape, at the ends of column and row lines. This is how I gave my tomato the backlighting on its right edge.

For larger areas of color, the shadow on the front of my tomato for instance, click with the white arrow (not the Mesh tool) inside a mesh patch. That will automatically select, and enable you to color simultaneously, all four mesh points that define the shape of that patch.

Colour four mesh points at a time by clicking
within the mesh patch rather than on a specific
mesh point.

Continue colouring until you’re happy with the result. If you make a mistake, use Command-Z to undo, or just recolour the mesh point; they’re always editable, even after saving, closing, and re-opening the Illustrator document.

When the tomato is done, you can finish it off with leaves and maybe a stem, each of which can also be colored via a gradient mesh.

Believe it or not, the tomato I used for this example took me only 15 minutes to create from start to finish—including drawing the initial paths and adding and colouring the leaves and stem. Initially, your artwork might take longer; but with a little practice, you can quickly create stunningly coloured gradient mesh objects.

The finished tomato, complete with gradient mesh leaves and stem, and a standard radial gradient cast shadow.

In part two of this tutorial, which runs on Monday, I'll outline some easy keyboard shortcuts you can use to accomplish the tasks above.

Pariah S Burke

2 comments:

  1. Looks very realistic, good work!

    ReplyDelete
  2. I have a question for you... I have had this happen several times now and it is stumping me.

    When creating mesh art, the smooth lines become square. I notice if I resize using the scale tool, this happens and there is no fix as far as I can tell.

    I don't seem to have that problem if I use the numeric scale.

    However, today, I returned to a piece of art that I hadn't scaled and it is now square.

    I have clicked on the anchors hoping to apply the rounding tool, but that option doesn't exist at in the tools when in mesh mode. Please, if you have any suggestions, I would so very much appreciate it.

    ReplyDelete

Apply to be a Chitika Publisher!
Follow on Buzz