Publishers of technology books, eBooks, and videos for creative people

# Maya 4.5 Materials

This chapter is from the book

## Texture Mapping

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

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 drawbacks—singularities. 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.

#### 2D Procedurals

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.

#### 3D Procedurals

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 patterns—the 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

Chapter_08\movies\ch08tut04.wmv

1. 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

Chapter_08\ch08tut01end.mb

1. 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.

1. Make the Perspective view full screen and set it to Shaded view (hotkey: 6). Activate Hardware Texturing for this view (Hotbox | Shading | Hardware Texturing).

2. 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.

3. 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.

4. 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.

TIP

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.

1. 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.

2. 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.

1. 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.

1. 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.

2. 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.

1. Now render the view to see what the materials look like. Figure 8.20 shows the planar mapping manipulator in its adjusted placement.

2. 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

Chapter_08\ch08tut04end.mb

### Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

## Overview

Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

## Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

### Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

### Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

### Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

### Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

### Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

### Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

## Other Collection and Use of Information

### Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

### Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

### Do Not Track

This site currently does not respond to Do Not Track signals.

## Security

Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

## Children

This site is not directed to children under the age of 13.

## Marketing

Pearson may send or direct marketing communications to users, provided that

• Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
• Such marketing is consistent with applicable law and Pearson's legal obligations.
• Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
• Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

## Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

## Choice/Opt-out

Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

## Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

## Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

## Sharing and Disclosure

Pearson may disclose personal information, as follows:

• As required by law.
• With the consent of the individual (or their parent, if the individual is a minor)
• In response to a subpoena, court order or legal process, to the extent permitted or required by law
• To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
• In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
• To investigate or address actual or suspected fraud or other illegal activities
• To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
• To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
• To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.