The next step is to replace a surface's solid color with a texture. Normally, a texture refers to applying a 2D image around a 3D surface, rather like wallpapering a curvy surface. Because a 2D image can be stretched, wrapped, and projected onto a surface in many different ways, you must take control of how the image is applied.
Mapping coordinates, also known as UV coordinates, tell the 3D renderer how to place the 2D map across the geometry, which varies depending on whether the model is created from NURBS or polygons. For NURBS, parametric mapping is inherent to the surface and this is typically what's used. Because NURBS are already parametric surfaces, mapping can automatically flow smoothly across the surface. You can also adjust NURBS mapping, to move and rotate how the map is positioned on the object.
For polygon surfaces, mapping is normally applied by projecting 2D maps across the 3D surface in one of several ways: planar, cylindrical, spherical, and a special method called automatic mapping. As you might expect, when you apply a 2D texture to a 3D object with a planar map projection, you'll see a smearing effect in areas of the object that's perpendicular to the direction of the map projection. The cylindrical and spherical projections would seem to solve this problem, but both mapping types have their drawbackssingularities. These are points at the poles of the sphere or cylinder where the mapping is pinched into a point (see Figure 8.15). Generally, you must apply the best mapping method for the surface and the areas seen during the animation. That is, if the ugly part is in an area that won't be visible to the camera during the animation, the problem is solved. In tough cases, a combination of automatic mapping, multiple mapping coordinates, and lots of photoediting work can usually fix the problem.
Figure 8.15 Three teapots with planar, cylindrical, and spherical mapping (from left to right).
Maya's Interactive Texture Placement
To make adjusting mapping on a surface less confusing, Maya offers interactive texture placement. This feature lets you see the maps move on the surface in real time as you move, rotate, and scale the manipulator for the mapping. To make this work, you need to have Hardware Texturing turned on for at least one of the 3D panels. To do that, select the panel (RMB-click over the panel) and then click Hotbox | Shading | Hardware Texturing (hotkey: 6). By default, materials with a texture applied to the Color attribute have the color texture map set to appear in the hardware-textured panels.
Procedural Maps Explained: 2D Versus 3D
In addition to applying an image or movie to a surface, Maya provides many other texture types called procedural textures. Instead of using actual images for mapping, procedural textures use formulas. Many patterns, such as bricks, tiles, and gradients, are so repetitive that they can easily be represented by an equation. By using special forms of seemingly random values, many natural effects can be simulated mathematically: Marble, leather, water, granite, and many other complex and random textures are included with Maya as procedurals.
Maya's procedural textures come in two varieties: 2D and 3D. You can think of the 2D procedurals as a calculated form of a bitmap. A formula is responsible for the image, but the image must be applied to the 3D geometry with some form of mapping, so it's subject to all the benefits and drawbacks of 2D mapping. When 3D procedurals are applied, however, they exist throughout 3D space, and object surfaces define where you see the texture. It's like carving the object from a block of the material. This method has the benefit of not requiring any mapping, but if the object bends or warps, the procedural texture can seem to "swim" through the object (but Maya has an advanced option for getting around this limitation called Texture Reference Objects).
Procedural textures have several benefits. Because they are formula based, their parameters can be adjusted to instantly synthesize all kinds of different effects. Because the simulated random "noise" used for the natural textures varies at every point in space, the procedurals don't repeat, as is common with a tiled image of, say, marble. Also, because 3D procedurals exist throughout 3D space, you often get good results on objects that would otherwise be hard to map. Instead of trying to wrap a 2D texture around a complicated sculpture, you can apply a 3D procedural and it will appear to be perfectly mapped.
Maya's 2D procedurals can be divided into two categories: regular patterns and noise patterns. The regular patterns include grid, checker, bulge, cloth, and ramp. With these patterns, you can create tiles, bricks, and many other man-made repeating effects. Noise patterns include fractal, mountain, noise, and water. These psuedorandom textures are excellent for creating the complex "dirty" surfaces common in nature.
All of the 3D procedurals but snow are random types. Some, such as wood and marble, clearly imitate nature. However, all are excellent for synthesizing random effects. Even when animating a man-made world such as a building interior, you still need noisy patternsthe bump texture on ceiling tiles, some splotchy carpet patterns, and even the brushed solid-color paint on walls are slightly randomly textured.
Tutorial: Applying Textures
In this tutorial, you'll apply some textured materials to the objects and edit the placement of those textures. You can load the scene file noted here to pick up from the end of the "Creating Solid Materials" tutorial.
On the CD
Open Hypershade (hotkey: Shift+T). Make sure the Create Bar and both tab panels are displayed. RMB-click the Create Bar and set it to Create Materials. MMB-drag a Blinn material to the bottom tab panel, and double-click it to open the Attribute Editor.
On the CD
Rename the material checkerfloor, and click the checkered button to the right of the color swatch. The Create Render Node dialog box opens to the Textures tab, displaying all the 2D and 3D procedurals and textures (see Figure 8.16). Click on the Checker type to apply it to the Color attribute.
Figure 8.16 The Create Render Node dialog box lists all available map types.
Make the Perspective view full screen and set it to Shaded view (hotkey: 6). Activate Hardware Texturing for this view (Hotbox | Shading | Hardware Texturing).
You'll use the drag-and-drop method to apply a material to an object. MMB-drag the checkerfloor swatch from the top tab panel of Hypershade to the scene's floor surface. You should see a checkerboard appear on the floor.
Double-click the checkerfloor material in Hypershade to make it active in the Attribute Editor. In the Attribute Editor for the material, open the Hardware Texturing section, and set the Texture Quality to High. You should see the checkerfloor texture sharpen in the Shaded view.
In the Attribute Editor for the checkerfloor material, the Color swatch is light gray, and the icon to the right of the Color slider has changed from a checkered button to a right-pointing arrow, indicating that the color has been overriden by something else. Click the right-arrow icon to have the Attribute Editor display the parameters for the Checker node.
To navigate back to the original node after you have applied a texture, click the right-arrow icon. If you need to undo a texture's assignment, RMB-click on the name of the entry and choose Break Connection, as shown in Figures 8.17A and 8.17B.
Figure 8.17A Use the lower of the two connection buttons, "go to input connection," to return to the material's base properties when finished editing a texture.
Figure 8.17B Right-click over the text label for a material attribute to get a dialog option to "break connection"removing the texture that was assigned to that attribute.
A dialog box opens where you can change the colors of the checkerfloor material from black and white to other colors, as shown in Figure 8.18. To the right of these color sliders are checkered buttons you can click to replace one of checkerfloor's solid colors with another texture. To replace the white squares in checkerfloor with a 3D marbled texture, click the checkered button to the right of Color1 (white), and then click Marble under 3D Textures in the Create Render Node dialog box.
The Attribute Editor now shows the settings for the marble texture. The veins in the marble are much too tiny for your scene, however. To scale the procedural marble texture higher, click the place3dTexture tab in the Attribute Editor, and set the three Scale values to 10. Render the Perspective view, and you should see a marbled checkerfloor material. The floor is somewhat reflective because the default Reflectivity value of 0.5 was assigned to checkerfloor.
Figure 8.18 The Checker texture node in the Attribute Editor.
Next, you'll place a 2D texture on the polygonal shield object with the text "Maya Fundamentals." Create a new Blinn material, and open the Attribute Editor. Name the material m4fshield. Click the checkered button next to Color, and in the Create Render Node dialog box, select File in the 2D Textures section. Next to the Image Name text box in the Attribute Editor, click the button with the folder icon to select the image you want to apply. For this object, it's the file noted below the CD icon. After selecting and accepting the file, click the m4fshield material in the top tab area of Hypershade. Then MMB-drag the material onto the shield object to the right of the flower pot. You should see the texture appear in a distorted way.
The shield is a polygonal object made with a revolve. Mapping is applied to the revolve, but it's applied circularly in the direction the spline spins to create the surface. In this case, you simply want a flat sign on the front of the shield, so you need to override the default mapping that has been applied.
Select the shield object and planar map it (Hotbox | Edit Polygons | Texture | Planar Mapping). You should see the mapping on the surface change immediately, and the mapping manipulator is displayed.
Now you can adjust the size and position of the map manipulator to make the text fit neatly on the shield. In one corner of the manipulator is a red "L"; when you click on it, it turns yellow and three manipulator handles appear: a single circle (for activating Rotate mode) and the Scale and Move icons with X, Y, and Z active, as shown in Figure 8.19. If you click on the circle, the Rotate X, Y, and Z manipulators appear, as shown in Figure 8.19. Using these manipulators, you can transform the application of the image to the shield until it's placed correctly. Note that if you click the corner "L" again, the manipulator reverts to its original mode, which is designed for easy sizing. Use the corner Ls (to the left in Figure 8.19) to adjust the map's size.
Figure 8.19 The planar mapping manipulators have been pulled away from the geometry to show the two placement modes, toggled by clicking the corner "L" at the lower left of the manipulator.
Now render the view to see what the materials look like. Figure 8.20 shows the planar mapping manipulator in its adjusted placement.
If you need to bring the manipulator handles back for texture placement, you can do so by selecting the object, opening the Channel Box (hotkey: Shift+C), and clicking the polyPlanarProj entry. If this fails, you need to open the Tool Box (Hotbox | Display | UI Elements | Tool Box). The sixth icon from the top in the Tool Box, just below Scale, is the Show Manipulator Tool button. Click that to get your map manipulator back. The hotkey for the Show Manipulator Tool is t.
Figure 8.20 The final scene, rendered with the shield map in place. Note that the glass torus doesn't appear in the Shaded view.
On the CD