Shading is the Maya term for applying colors and textures, known in Maya as shaders. A shader defines an object's look—its color, tactile texture, transparency, luminescence, glow, and so forth.
Topics discussed in this chapter include:
After you model your objects, Maya assigns a default shader to them with a neutral gray color. The shader allows your objects to render and display properly. If no shader is attached to a surface, an object can't be seen.
Shading is the proper term for applying a renderable color, surface bumps, transparency, reflection, shine, or similar attributes to an object in Maya. It's closely related to, but distinct from, texturing, which is what you do when you apply a map or other node to an attribute of a shader to create some sort of surface detail. For example, adding a scanned photo of a brick wall to the Color attribute of a shader is considered applying texture. Adding another scanned photo of the bumps and contours of the same brick wall to the Bump Mapping attribute is also considered applying a texture. Nevertheless, because textures are often applied to shaders, the entire process of shading is sometimes informally referred to as texturing. Applying textures to shaders is also called texture mapping or simply mapping. You map a texture to the color node of a shader that is assigned or applied to a Maya object.
Shaders are based on nodes. Each node holds the attributes that define the shader. You create shader networks of interconnected shading nodes, akin to the hierarchies and groups of models. These networks can be simple, or they can be intricate and involved, as when several render nodes are used to create complex shading effects.
Each shader, also known as a shading group, comprises a set of material nodes. Material nodes are the Maya nodes that hold all the pertinent rendering information about the object to which they're assigned, such as their color, opacity, or shininess. The shading groups are the nodes that allow the connection between the surface and the material you've created. When you edit the shader through the Attribute Editor, as you'll do later in this chapter, you edit its material node.
As you learn about shading in this chapter, you'll deal at length with the Hypershade window. See Chapter 2, “Jumping in Headfirst, with Both Feet,” and Chapter 3, “The Maya 2012 Interface,” for the layout of this window and for a hands-on introduction. You can access the Hypershade window by choosing Window Rendering Editors Hypershade. Shading in Maya is almost always done hand-in-hand with lighting. At the very least, textures are tweaked and edited in the lighting stage of production.
Open the Hypershade by choosing Window Rendering Editors Hypershade. In the left column of the Hypershade window, you'll see a listing of Maya shading nodes (Figure 7.1). The first section displays surface nodes, a.k.a. material nodes or shader types. Of these shader types, five are common to other animation packages as well. You'll use two of these later in this chapter.
To understand a bit more about shaders, consider what makes objects appear as they do in the real world. The short answer is light. The way light bounces off an object defines how you see that object. The surface of the object may have pigments that affect the wavelength of light that reflects off it, giving the surface color. Other features of that object's surface also dictate how light is reflected.
For the most part, shader types address the differences in how light bounces off surfaces. Most light, after it hits a surface, diffuses across an area of that surface. It may also reflect a hot spot called a specular highlight. The shaders in Maya differ in how they deal with specular and diffuse parameters according to the specific math that drives them. As you learn about the shader types, think of the things around you and what shader type would best fit them. Some Maya shaders are specific to creating special effects, such as the Hair Tube shader and the Use Background shader. It's important to learn the fundamentals first, so we'll cover the shading types you'll be using right off the bat.
The most common shader type is Lambert, an evenly diffused shading type found in dull or matte surfaces. A sheet of paper, for example, is a Lambert surface.
A Lambert surface diffuses and scatters light evenly across its surface in all directions, as you can see in Figure 7.2.
Phong shading brings to a surface's rendering the notions of specular highlight and reflectivity. A Phong surface reflects light with a sharp hot spot, creating a specular highlight that drops off sharply, as shown in Figure 7.3. You'll find that glossy objects such as plastics, glass, and most metals take well to Phong shading.
The Blinn shading method brings to the surface a highly accurate specular lighting model that offers superior control over the specular's appearance. (See Figure 7.4.) A Blinn surface reflects light with a hot spot, creating a specular that diffuses somewhat more gradually than a Phong. The result is a shader that is good for use on shiny surfaces and metallic surfaces.
The Phong E shader type expands the Phong shading model to include more control over the specular highlight. A Phong E surface reflects light much as a regular Phong does, but it has more detailed control over the specular settings to adjust the glossiness of the surface. (See Figure 7.5.) This creates a surface with a specular that drops off more gradually and yet remains sharper than a Blinn. Phong E also has greater color control over the specular than do Phong and Blinn, giving you more options for metallic reflections.
The Anisotropic shader is good to use on surfaces that are deformed, such as a foil wrapper or warped plastic. (See Figure 7.6.)
Anisotropic refers to something whose properties differ according to direction. An Anisotropic surface reflects light unevenly and creates an irregular-shaped specular highlight that is good for representing surfaces with directional grooves, like CDs. This creates a specular highlight that is uneven across the surface, changing according to the direction you specify on the surface. In contrast with Blinn and Phong types, the specular highlight is evenly distributed to make a circular highlight on the surface.
A Layered shader allows the stacking of shaders to create complex shading effects, which is useful for creating objects composed of multiple materials. (See Figure 7.7.) By using the Layered shader to texture different materials on different parts of the object, you can avoid using excess geometry.
You control Layered shaders by using transparency maps to define which areas show which layers of the shader. You drag material nodes into the top area of the Attribute Editor and stack them from left to right, the left being the topmost layer assigned to the surface.
Layered shaders are valuable resources to control compound and complex shaders. They're perfect for putting labels on objects or adding dirt to aged surfaces. You'll use a Layered shader in the axe-texturing exercise later in this chapter.
A Ramp texture is a gradient that can be attached to almost any attribute of a shader as a texture node. Ramps can create smooth transitions between colors and can even be used to control particles. (See Chapter 12, “Maya Dynamics and Effects,” to see how a ramp is used to control particles.) When used as a texture, a ramp can be connected to any attribute of a shader to create graduating color scales, transparency effects, increasing glow effects, and so on. You'll use Ramp textures later in this chapter.
The Ramp shader is a self-contained shader node that automatically has several Ramp texture nodes attached to its attributes. These ramps are attached within the shader itself, so there is no need to connect external Ramp texture nodes. This makes for a simplified editing environment for the shader because all the colors and handles are accessible through the Ramp shader's own Attribute Editor, as shown in Figure 7.8.
To create a new color in any of the horizontal ramps, click in the swatch to create a new ramp position. Edit its color through its Selected Color swatch. You can move the position by grabbing the circle right above the ramp and dragging left or right. To delete a color, click the box beneath it.
Ramp textures are automatically attached to the Color, Transparency, Incandescence, Specular Color, Reflectivity, and Environment attributes of a Ramp shader. In addition, a special curve ramp is attached to the Specular Roll Off to allow for more precise control over how the specular highlight diminishes over the surface.
Shaders are composed of nodes just like other Maya objects. Within these nodes, attributes define what shaders do. Here is a brief rundown of the common shader attributes with which you'll be working:
Color An RGB or HSV value defines what color the shader is when it receives a neutral color light. For more on RGB and HSV, see Chapter 1, “Introduction to Computer Graphics and 3D.”
Transparency The higher the Transparency value, the less opaque and more see-through the object becomes.
Although usually expressed in a black-to-white gradient, with black being opaque or solid and white being totally clear, transparency can have color. In a color transparency, the shader's color shifts because only some of its RGB values are transparent, as opposed to the whole.
Ambient Color This color affects the Color attribute of the shader as more ambient light is created in the scene. Ambient color tends to flatten an object because this attribute evenly colors the object. This attribute is primarily used to create flat areas and should be used with care. The default is black, which keeps the darker areas of a surface dark. The lighter the ambient color, the lighter those areas are. A bright Ambient Color setting flattens out an object, as shown in Figure 7.9.
Incandescence This attribute is the ability to self-illuminate. Objects that seem to give off or have their own light, such as an office's fluorescent light fixture, can be given an Incandescence value. Incandescence doesn't, however, light objects around it in regular renders, nor does it create a glow. It also serves to flatten the object into a pure color. As you'll see in Chapter 11, “Maya Rendering,” incandescence can also help light a scene in mental ray's Final Gather rendering. The value of Incandescence (as well as the color) of an object is used to calculate the overall brightness in a Final Gather scene. (See Figure 7.10.)
Bump Mapping This attribute creates a textured feel for the surface by adding highlights and shadows to the render. It doesn't alter the surface of the geometry, although it makes the surface appear to have ridges, marks, scratches, and so forth. The bump map has to be a texture node such as a ramp, a fractal noise, or an image file. The more intense the variation in tones of that map, the greater the bump. Bump maps are frequently used to make surfaces look more real, because nothing in reality has a perfectly smooth surface. Using bumps very close up may create problems; bumps are generally good for adding inexpensive detail to a model that isn't in extreme close-up. (See Figure 7.11.)
Close-up geometry, where you have to change the topology of the model physically using texture maps, requires displacement maps. We'll cover displacement maps in Chapter 11.
Diffuse This value governs how much light is reflected from the surface in all directions. When light strikes a surface, light disperses across the surface and helps to illuminate it. The higher this value, the brighter its object is when lit, because more of the striking light is reflected from the surface. The lower the Diffuse value, the more light is “absorbed” into the surface, yielding a darker result, especially in areas that aren't well lit. Metals have very low Diffuse values because they rely on reflections and direct light. (See Figure 7.12.)
Translucence and Translucence Focus The Translucence and Translucence Focus attributes give the material the ability to transmit light through its surface, like a piece of canvas in front of a light. At a value of 1 for Translucence, all light shines through the object; at 0, none does. The Translucence Focus attribute specifies how much of that light is scattered. A light material such as paper should have a high translucence focus, and thicker surfaces should have low focus rates.
Glow Intensity Found in the Special Effects section of the Attribute Editor, the Glow Intensity attribute adds a glow to the object, as if it were emitting light into a foggy area. (See Figure 7.13.) You'll add glow to an object in Chapter 10, “Maya Lighting.”
Matte Opacity Objects rendered through Maya generate a solid matte. Where there is an object, the matte is white; where there is nothing, the matte is black. Mattes helps compositing programs, which bring together elements created independently into a single composite scene, to separate rendered CG from their backgrounds. Turning down the slider decreases the brightness of the object's matte, making it appear more transparent. This technique is usually used for compositing tricks or to make an object render in RGB but not appear in any composites. For more information about mattes, see the sidebar “Image Mattes” in this chapter as well as Chapter 11.
Raytrace Options With raytracing, you can achieve true reflections and refractions in your scene. This subset of attributes allows you to set the shader's raytracing abilities. See Chapter 11 for more on raytracing.
Some attributes are available only with certain shader types. The following are the attributes for the Phong, Phong E, and Blinn shaders:
Specular Color The color of the highlights on a shiny surface. Black produces no specular, and white creates a bright one.
Reflectivity The amount of reflection visible in the surface. The higher the value, the more reflective the object will render. Increasing this value increases the visibility of the Reflected Color attribute or of true reflections in the scene when raytraced.
Reflected Color Gives the surface a reflection. Texture maps are generally assigned to this attribute to give the object a reflection of whatever is in the image file or texture without having to generate time-consuming true reflections with a raytraced render. Using raytracing to get true reflections, however, is the only way to generate reflections of other objects in the scene.
Cosine Power Only available with a Phong shader. This attribute changes the size of the shiny highlights (a.k.a. specular) on the surface. The higher the number, the smaller the highlight looks.
IMAGE MATTES
As you learned in Chapter 1 (and will explore further in Chapter 11), image files are stored with a red, a green, and a blue channel that keep the amount of each color in each pixel of the image. Some image formats, including TIFF and TARGA, also have an alpha channel, known as a matte channel or image matte. This is a grayscale channel that controls the opacity of an image. Completely white parts of the matte make those parts of the image opaque (solid), whereas black parts make those parts of the image fully transparent. Gray in the matte channel makes those parts of the image partly transparent. These mattes are used in compositing—bringing together elements created separately into a single composite scene. See Chapter 11 for an example of how an alpha channel works.
Roughness, Highlight Size, Whiteness Control the specular highlight on a Phong E surface only. They control specular focus, amount of specular, and highlight color, respectively.
mental ray Attributes Because Autodesk now integrates features of its mental ray rendering engine into Maya, an object's Attribute Editor usually includes a set of mental ray options. Shaders are no different. If you open the Mental Ray heading in the Attribute Editor for a shader, you'll see attributes such as Reflection Blur and Irradiance, as well as a few ways to override Maya's shading attributes with mental ray's own.
An in-depth discussion of the mental ray attributes is beyond the scope of this introductory text. But it's a good idea to know that this brief section is available to you after you have more experience with rendering and you want to work with mental ray at its more advanced levels in Maya. You'll work with mental ray in Chapters 10 and 11.
In this section, you'll add shaders to a NURBS modeled axe to make it look real; in the next chapter, you'll import this axe into an animation exercise. Starting animation on a project and then replacing it with a finished and textured model is a fairly common practice with Maya.
Download axe_texture_A.mb from the Axe project on the book's companion web page (www.sybex.com/go/intromaya2012).
You'll start by texturing the metal parts of the axe. Even though you can find a good metal to use for your axe head in Maya's shader library or on Autodesk's website, for this exercise you'll make a simple metal from scratch. Because the look of real metals is greatly affected by their surroundings (that is, by the reflections of the environment), metal is one of the toughest materials to create and to light. In many cases, metals are lighted and rendered with high-dynamic range (HDR) image-based lighting (IBL).
Autodesk's website lists several premade shaders for your use. Maya also includes a shader library on its installation CD.
First, set up your render parameters so that you can render out your axe while you're tweaking the Metal shader to get it right:
This procedure creates a simple Metal shader that works well overall. To create a more polished look for the axe head, you can add a reflection to it using an Environment texture node. This node creates a 3D texture node in the scene that projects its contents onto the Material attribute to which it has been connected. As an object animates through the scene, different parts of the texture are reflected on its surface.
After you create the Env Chrome texture, you'll see a green object in the Modeling windows at the origin, as shown in Figure 7.17. This is the Env Chrome's placement node. You can manipulate this node just as you manipulate other Maya objects—in other words, move, rotate, and scale it.
Altering this will change how the environment chrome projects itself in the scene. For example, if you increase the size of this placement node, the grid showing in the reflection of the axe will get larger. For more on projections and placement nodes, see the “Texture Nodes” section later in this chapter.
A glossy cherry wood would look good for the handle, so a Phong shader will be best:
The Wood texture is a projected 3D texture; it's projected from a source onto the object using a placement node, just like the Env Chrome on the axe head's reflection. To assign the Wood texture from the Hypershade, select the handle, and right-click the shader to select Assign Material To Selection; or MMB+click and drag the icon onto the handle in the viewport. For more on projected textures, see the “Texture Nodes” section later in this chapter.
You can assign a shader to any object by MMB+clicking and dragging its icon from the Hypershade to the object in the viewport.
Instead of moving and scaling the texture placement node and rendering multiple times to get the wood placement just right, you can use Maya's Interactive Photorealistic Rendering (IPR) to see your changes in real time. Choose the camera panel to render, and click the IPR Render The Current Frame icon () in the Status line, or choose Render IPR Render Current Frame.
The Render View window shows a lower-quality render of the axe. It prompts you to select a region to begin tuning. Drag a marquee selection in the Render View window around the handle. IPR refreshes that part of the window. Every change you make to the texture placement node prompts IPR to update that section of the render, giving you a fast update on the positioning and scale of the Wood texture.
The scene file axe_texture_B.mb in the Axe project on the companion web page will bring you up to this point.
Currently, the entire length of the handle is shaded as wood, including the top spike. The spike on the axe head should be metal, like the axe head.
You can approach this in two ways: with geometry or with shaders. If you manipulate the NURBS geometry, you select a horizontal isoparm and detach the spike portion of the handle to make it a separate surface. You then assign a Metal shader to the new tip surface.
Using a shader instead of cutting up or creating more geometry can be desirable in many instances. For example, you may not be able to detach surfaces like this all the time.
The Layered shader is a normal surface shader that allows you to stack materials on top of each other to assign to a surface. You control which layer of material is exposed, and by how much, by assigning transparency values or textures to each layer. Use a Ramp texture to specify where on the handle the wood stops and the metal starts.
To create a Layered shader, follow these steps:
Choosing Lighting/Shading Assign New Material is an easy way to create and assign a material without having to open the Hypershade.
You can see the names of the materials in the Layered shader by pointing to the icons.
When an attribute is already mapped, its Map button turns from a checkerboard to an Input Connection icon. Clicking it opens the Attribute Editor for whatever node is attached to that attribute. In this case, clicking the Map button opens its Attribute Editor because the wood material was assigned to this layer. Here you need to attach a transparency ramp to control where the metal tip starts and the wooden handle ends.
When a projected texture, such as the wood, doesn't “stick” to an object, and the object seems to move through the texture, the object is said to be swimming through the projection. The wood is being projected by the 3D placement node that you positioned to get the grain just right, so you need to group the texture node under the axe's top node. When the axe moves, the texture will stick with it, maintaining its orientation with the axe.
The file axe_texture_C.mb, in the Scenes folder of the Axe project on the companion web page, has the final textured axe for your reference.
Now you have a fully textured axe. Because you used a Layered shader, you didn't need to build another piece of geometry to represent a metal tip. You can embellish a model a lot at the texturing level. Although you may first consider using geometry, you can accomplish a number of tasks by using simple texturing tricks, such as those you used for the axe handle and its metal spike. The more you explore and experience shaders and modeling, the better you'll be at juggling modeling with texturing to get the most effective solution.
You'll begin texturing the red wagon from Chapter 6, “Practical Experience,” later in this chapter and then go into more detailed texturing with the decorative box, which you'll then light and render in mental ray. For even more practice, try loading the locomotive model from Chapter 4, “Beginning Polygonal Modeling,” and texturing it from top to bottom. A great deal of independent geometry needs textures, some of which must be carefully placed with 3D placement nodes. Experiment with as many different ways of shading the locomotive as you can figure out.
Texture nodes generate maps to connect to an attribute of a shader. There are two types of textures: procedural and bitmapped (sometimes called maps). Procedural textures use Maya's own nodes' attributes to generate an effect, such as ramp, checkerboard, or fractal noise textures. You can adjust each of these procedural textures by changing their attribute values.
In the axe handle texturing exercise, you grouped the 3dplacement node for the wood grain to the handle of the axe to make the texture stick to the handle. But you can also bake the texture onto the axe handle by converting the texture projection to a file node. By baking the texture node, you convert the 3dplacement node into an image file that is then mapped to the color channel of the material, discarding the projection node, so you needn't group it with the handle as you did earlier.
Follow these steps to bake the wood-grain texture to the axe:
Notice that the 3dplacement node, as well as the Hypershade view, is removed from the scene. Your axe handle's texture now sticks to the handle as a mapped- file texture instead.
A map, on the other hand, is a saved image file that is imported into the scene through a File texture node. These files are pregenerated through whatever imaging programs you have and include digital pictures and scanned photos. You need to place all texture nodes onto their surfaces through the shader. You can map them directly onto the surfaces' UV values or project them.
UV mapping places the texture directly on the surface and uses the surface coordinates for its positioning (called UVs). In this case, you must do a lot of work to line up the UVs on the surface to make sure the created images line up properly. What follows is a brief summary of how UV mapping works. You'll get hands-on experience with UV layout with the red wagon and decorative box exercises later in this chapter.
Just as 3D space is based on coordinates in XYZ, surfaces have coordinates denoted by U and V values along a 2D coordinate system for width and height. The UV value helps a texture position itself on the surface. The U and V values range from 0 to 1, with (0,0) UV being the origin point of the surface.
Maya creates UVs for primitive surfaces automatically, but frequently you need to edit UVs for proper texture placement, particularly on polygonal meshes after you've edited them. In some instances, placing textures on a poly mesh requires projecting the textures onto the mesh, because the poly UVs may not line up as expected after the mesh has been edited. See the next section, “Using Projections.”
If the placement of your texture or image isn't quite right, simply use the 2D placement node of the texture node to position it properly. See the section “Texture Nodes” later in this chapter for more information.
You need to place textures on the surface. You can often do so using UV placement, but some textures need to be projected onto the surface. It's common to project textures (when texturing polys, for example). A projection is what it sounds like. The file image, ramp, or other texture being used can be beamed onto the object in several ways.
You can create any texture node as either a normal UV map or a projected texture. In the Create Render Node window, clicking a texture icon creates it as a normal mapped texture. To create the texture as a projection, you must right-click the icon and select Create As Projection. (See Figure 7.29.)
When you create a projected texture, a new node is attached to the texture node. This projection node controls the method of projection with an attached 3D placement node, which you saw in the axe exercise. Select the projection node to set the type of projection in the Attribute Editor. (See Figure 7.30.)
Setting the projection type will allow you to project an image or a texture without having it warp and distort, depending on the model you're mapping. For example, a planar projection on a sphere will warp the edges of the image as they stretch into infinity on the sides of the sphere.
Try This In a new scene, create a NURBS sphere and a NURBS cone, and place them side by side. Create a Blinn shader, and assign it to both objects. In the Blinn shader's Attribute Editor, set its Color attribute to a checkerboard pattern, as shown in Figure 7.31.
Try removing the color map from the Blinn shader. In the Blinn shader's Attribute Editor, right-click and hold the attribute's title word Color, and then choose Break Connection from the context menu. Doing so severs the connection to the checker and resets the color to gray. Now, re-create a new checker map for the color, but this time create it as a projection by right-clicking the icon in the Create Render Node window. In the illustration on the top in Figure 7.32, you see the perspective view in Texture mode (press the 6 key) with the two objects and the planar projection placement node.
Try moving the planar placement object around in the scene to see how the texture maps itself to the objects. Figure 7.32 on the bottom shows the rendered objects.
Try the other projection types to see how they affect the texture being mapped.
Projection placement nodes control how the projection maps its image or texture onto the surface. Using a NURBS sphere with a spherical projected checker, with U and V wrap turned off on the checker texture, you can see how manipulating the place3dTexture node affects the texture.
In addition to the Move, Rotate, and Scale tools, you can use the Special Manipulator tool (press T to activate or click the Show Manipulator Tool icon in the toolbar) to adjust the placement. Figure 7.33 shows this tool for a spherical projection.
Drag the handles on the Special Manipulator to change the coverage of the projection, orientation, size, and so forth. All projection types have Special Manipulators. Figure 7.34 shows the Manipulator wrapping the checker in a thin band all the way around the sphere.
To summarize, projection textures depend on a projector node to position the texture onto the geometry.
You can create a number of texture nodes in Maya. This section covers the most important. All texture nodes, however, have common attributes that affect their final look. Open the Attribute Editor for any texture node. (See Figure 7.35.) The two top sections affect the color balance of the texture. The Color Balance and Effects sections are described here:
Color Balance This set of attributes adjusts the overall brightness and color balance of your texture. Use these attributes to tint or brighten a texture without having to change all the individual attributes of the shader.
Effects You can invert the texture's color space by clicking the Invert check box. This changes black to white and white to black in addition to inverting the RGB values of colors.
You can map textures to almost any shader attribute for detail. Even the tiniest amount of texture on a surface's bump, specular, or color increases its realism.
The 2D texture nodes come with a 2D placement node that controls their repetition, rotation, size, offset, and so on. Adjust the setting in this node of your 2D texture in the Attribute Editor, as shown in Figure 7.36, to position it within the Shader network. You used a similar approach when dealing with the wood's 3D placement node in the axe exercise earlier in this chapter.
The Repeat UV setting controls how many times the texture is repeated on whatever shader attribute it's connected to, such as Color. The higher the wrap values, the smaller the texture appears but the more times it appears on the surface.
The Wrap U and Wrap V check boxes allow the texture to wrap around the edges of their limits to repeat. When these check boxes are turned off, the texture appears only once, and the rest of the surface is the color of the Default Color attribute found in the texture node.
The Mirror U and Mirror V settings allow the texture to mirror itself when it repeats. The Coverage, Translate Frame, and Rotate Frame settings control where the image is mapped. They're useful for positioning a digital image or a scanned picture.
A ramp is a gradient in which one color transitions into the next color. You've already seen how useful a ramp can be in positioning materials in a Layered shader. It's also perfect for making color gradients, as shown in Figure 7.37.
Use the round handles to select the color and to move it up and down the ramp. The square handle to the right deletes the color. To create a new color, click inside the ramp.
The Ramp texture is different from the Ramp shader. The Ramp shader automatically has several Ramp textures mapped to some of its attributes.
The Type setting allows you to create a gradient running along the U or V direction of the surface, as well as to make circular, radial, diagonal, and other types of gradients. The Interpolation setting controls how the colors grade from one to the next.
The U Wave and V Wave attributes let you add a squiggle to the U or V coordinate of the ramp, and the Noise and Noise Freq (frequency) attributes specify randomness for the placement of the ramp colors throughout the surface.
Using the HSV Color Noise attributes, you can specify random noise patterns of Hue, Saturation, and Value to add some interest to your texture. The HSV Noise options are great for making your shader just a bit different, to enhance its look.
These textures are used to create a random noise pattern to add to an object's Color, Transparency, or any other shader attribute. For example, when creating a surface, you'll almost always want to add a little dirt or a few surface blemishes to the shader to make the object look less CG. These textures are commonly used for creating bump maps.
These textures help create surface features when used on a shader's Bump Mapping attribute. Each creates an interesting pattern to add to a surface to create tactile detail, but you can also use them to create color or specular irregularities.
When used as a texture for a bump, Grid is useful for creating the spacing between tiles, Cloth is perfect for clothing, and Checker is good for rubber grips. Placing a Water texture on a slight reflection makes for a nice poolside reflection in patio furniture.
You use the file node to import image files into Maya for texturing. For instance, if you want to texture a CG face with a digital picture of your own face, you can use the file node to import a Maya-supported image file.
To attach an image to the Color attribute of a Lambert shader, for example, follow these steps:
You can attach an image file to any attribute of a shader that is mappable, meaning it's able to accept a texture node. Frequently, image files are used for the color of a shader as well as for bump and transparency maps. You can replace the image file by double-clicking the File texture node in the Hypershade and choosing another image file with the file browser. Maya disconnects the current image file and connects the new file.
Maya can also use Adobe Photoshop PSD files as image files in creating shading networks. The advantage of using PSD files is that you can specify the layers within the Photoshop file for different attributes of the shader, as opposed to importing several image files to map onto each shader attribute separately. This, of course, requires a modest knowledge of Photoshop and some experience with Maya shading. As you learn how to shade with Maya, you'll come to appreciate the enhancements inherent in using Photoshop networks.
Try This You'll create a single Photoshop file that will shade this sphere with color as well as transparency and a bump. Again, you're doing this is instead of creating three different image files (such as TIFFs) for each of those shading attributes:
The UVSnapShot layer gives you a wireframe layout of the UVs on the sphere as a guideline to paint your textures. Because the sphere is an easy model, you don't need this layer, so turn it off. You'll use UVSnapShot later in this chapter.
You can now paint whatever image you want into each of the layers to create maps for each of the shader attributes, all in one convenient file. Save the PSD file. You can save over it or create a new filename for the painted file.
If you decide that you need another attribute added to the PSD file's layering, or if you need to remove an attribute, you can edit the PSD network. Select the shader in the Hypershade, and choose Edit Edit PSD Network. In the option box, select new attributes to assign to the PSD file, or remove existing attributes and their corresponding Photoshop layer groups. When you click Apply or Edit, Maya saves over the PSD file with the new layout.
As you saw earlier with the axe, 3D textures are projected within a 3D space. These textures are great for objects that need to reflect an environment, for example.
Instead of simply applying the texture to the plane of the surface as 2D textures do, 3D textures create an area in which the shader is affected. As an object moves through a scene with a 3D placement node, its shader looks as if it swims, unless that placement node is parented or constrained to that object, as you saw with the wooden handle of the axe. (For more on constraints, see Chapter 9, “More Animation!”)
Sometimes, the texture you've applied to an object isn't what you want, and you need to remove it from the shader. To do so, double-click the shader in the Hypershade to open its Attribute Editor.
You can then disconnect an image file or any other texture node from the shader's attribute by right-clicking the attribute's name in the Attribute Editor and choosing Break Connection from the context menu, as shown in Figure 7.41.
Using the wagon model from Chapter 6, you'll now assign shaders to the red wagon shown in Figure 7.42. Take a good look at the image of the toy wagon in the Color Section of this book to see how the red wagon is colored. The wagon is fairly simple; it will need a few colored shaders (Red, Black, Blue, and White) for the body, along with a few texture maps for the decals—which is where the real fun begins. The wagon will also require some more intricate work on the shaders and textures for the wood railings and silver metal screws, bolts, and handlebar; these will be a good foray into image maps and UVs.
This exercise is a prime example of how lighting and shading go hand in hand.
Load the file RedWagonModel_v08.ma from the Scenes folder of the RedWagon project to begin shading the finished model of the wagon.
Shading is the common term for adding shaders to an object.
Study the color images of the wagon, and see how light reflects off its plastic, metal, and wood surfaces. Blinn shaders will be perfect for nearly all the parts of the wagon. Follow these steps:
Look at the photo of the wagon in the Color Section in the middle of this book. The bullnose and tires are black, the wheel rims are white, the floor is blue, the screws and bolts and handlebar are chrome metal, the railings are wood, and the main body is red. Assign shaders to the wagon according to the color photo and the following steps:
Now you have initial assignments for the basic colors of the wagon's body. Let's tweak these shaders' colors next.
Refer to Figure 7.47 to observe how the materials are different between the rim and the tire for the wheels. The rim is glossier and has a tighter, sharper specular, whereas the tire has a very diffuse specular and is quite bumpy. As you did for the axe exercise, you'll create a Layered shader for the wheels with white feeding into the rim portion and black into the tire.
First, you need to determine where the white ends and the black starts on the surface of the wheel mesh:
If the ramp doesn't show up in your view panels, make sure you press 6 to enter Texture Display mode. If the colors and ramp texture still don't display, make sure Use Default Material isn't checked in the view panel's Shading menu.
Now that you've pinpointed where the white rim ends and the black tire begins, you'll use this ramp as a transparency texture to place the Tire shader on top of the Rim shader in a Layered shader that you'll create later.
Why did you go through a Layered shader with two different shaders (one white and one black) when you could more easily use one shader and assign the same black to white ramp to its color? Because the white rim and the black tire are different materials, and you need to use two different shaders to properly show that in renders.
Because the material look and feel on the real wheels differs quite a bit between the rim and the tire, you'll further tweak the white rim and the black tire shaders. The rim is a smooth, glossy white, and the tire is a bumpy black with a broad specular. Follow these steps:
Notice the single, blue connecting line between the fractal1 node and the bump2d1 node in the Hypershade. This means the alpha channel of the fractal feeds the amount of bump that is rendered on the tireShader. You have to alter the alpha coming out of the fractal node with the positioning ramp to block the rim from having any bump. The white areas of the ramp allow an output in alpha from the fractal, which creates a bump for the surface, whereas the black area of the ramp keeps any bump from appearing. Because you already used this ramp to position the Rim shader and the Tire shader on the wheel, it will work perfectly for the bump position as well.
Congratulations! You've made your first somewhat complex shading network, as shown in Figure 7.68. By now, you should have a pretty good idea of how to get around the Hypershade and create shading networks. To recap, you're using a ramp to place the two Tire and Rim shaders on the wheel, as well as using it to place the bump map on just the tire by using a reverse node. The more you make these shading networks, the easier they will become to create.
This type of shading is called procedural shading, because you used nothing but stock Maya texture nodes to accomplish what you needed for the wheels. In the following sections, you'll make good use of image mapping to create the decals for the wagon body as well as the wood for the railings.
You can load the file RedWagonTexture_v01.ma from the Scenes folder of the RedWagon project to check your work or skip to this point.
Figure 7.69 shows you the decals that need to go onto the body of the wagon. They include the wagon's logo, which you'll replace with your own graphic design, and the white stripe that lines the side panels.
Instead of trying to make a procedural texture as you did with the wheel, you'll create an image map that will texture the side panels' white stripe. The stripe is far too difficult to create otherwise. You'll create an image file using Photoshop (or another image editor) to make sure the white stripe (and later the red wagon logo) lines up correctly.
Mapping polygons can involve the task of defining UV coordinates for them so that you can more easily paint an image map for the mesh. When you create a NURBS surface, UV coordinates are inherent to the surface. At the origin (or the beginning) of the surface, the UV coordinate is (0,0). When the surface extends all the way to the left and all the way up, the UV coordinate is (1,1). When you paint an 800 × 600–pixel image in Photoshop, for example, it's safe to assume that the first pixel of the image (at X = 0 and Y = 0 in Photoshop) will map directly to the UV coordinate (0,0) on the NURBS surface, whereas the topmost right-corner pixel in the image will map to the UV (1,1) of the surface. Toward that end, mapping an image to a NURBS surface is fairly straightforward. The bottom of the image will map to the bottom of the surface, the top to the top, and so on. Figure 7.70 shows how an image is mapped onto a NURBS plane and a NURBS sphere.
The locations in the image, marked by text, correspond to the positions on the NURBS plane. The sphere, because it's a surface bent around spherically, shows that the origin of the UV coordinates is at the sphere's pole on the left and that the image wraps itself around it (bowing out in the middle) to meet at the seam along the front edge as shown.
When you're creating polygons, however, this isn't always the case. You must sometimes create your own UV coordinates on a polygonal surface to get a clean layout on which to paint in Photoshop. Although poly UV mapping becomes fairly involved and complicated, it's a concept that is important to grasp early. When poly models are created, they have UV coordinates; however, these coordinates may not be laid out in the best way for texture-image manipulation.
First, let's look at how the UVs are laid out for the A panel that you modeled in Chapter 6:
This section assumes that you have some working knowledge of Adobe Photoshop. You can skip the creation of the maps and use the maps already on the companion web page, which are called out in the text later in the exercise.
The UV Texture window works almost like any other view panel. You may navigate the window and zoom in and out using the familiar Alt+mouse button combinations.
Feel free to select parts of the UV layout in the UV Texture Editor to see what corresponding points appear on the mesh in the persp view panel. This will help orient you as to how the UV layout works on this mesh.
Next, you'll go into Photoshop to paint your map according to the UV layout you just output:
Now, let's create the shader and get it assigned to the geometry:
You may skip the image creation using Photoshop and use the ApanelStripe.tif image file found in the Sourceimages folder of the RedWagon project on the companion web page instead.
You need to put the stripe on the other side's A panel. Select the other A panel, and assign the ApanelStripe shader to it. You'll notice that no stripe appears. (See Figure 7.86.) This is because the UV layout for this A panel hasn't been set up yet. Don't worry; you don't have to redo everything you did for the first A panel. You can essentially copy the UVs from the first A panel mesh to this one:
You can load the file RedWagonTexture_v02.ma from the Scenes folder of the RedWagon project to check your work or skip to this point.
The file texture you'll use for the panels were painted in Photoshop to place the stripes and logo properly on the wagon using their UV layouts. Study the image file, and see how it fits on the mesh of the wagon. Try adjusting the image file with your own artwork to see how your image map affects the placement on the mesh.
With the A panels done, you'll move on to the B panels, using much the same methodology you did with the A panels. To begin, follow these steps:
You may skip the image creation in Photoshop and use the BpanelStripe.tif image file found in the Sourceimages folder of the RedWagon project on the companion web page.
Finally, you need to create the shader for the other side's B panel. Assign the BpanelStripe shader to the other B panel. Nothing happens, because the UVs for the second B panel aren't set up yet.
However, because there is a logo with text, setting up its UVs won't be as simple as copying the UVs from the first B panel and then mirroring the mesh, as you did with the A panel with a Scale X value of −1.0. Doing so will make the logo and text read backward. First, let's copy and flip the UVs to the other B panel:
Right now, the floor of the wagon is red, like the rest of its body. However, the real wagon has a blue floor, not red. If you select the mesh for the wagon's floor (named wagonFloor) and assign the Blue shader you created, the whole body of the wagon turns blue, and that isn't what you want. You only need the inside and bottom of the floor to be blue, not the front and back sides of the wagon's body.
You'll make a face assignment instead of dealing with UVs and image files. RMB+click the wagon floor mesh, and select Face from the marking menu. Select the two faces for the floor, as shown in Figure 7.101.
With the faces selected, assign the Blue shader from the Hypershade window, and you're done! You have a blue floor. All that remains now are the screws, bolts, handle, and wood railings.
You can load the file RedWagonTexture_v03.ma from the Scenes folder of the RedWagon project to check your work or skip to this point.
You'll go back to procedural shading and use the Wood texture available in Maya to create the wood railings, as you did with the axe exercise earlier in the chapter. Begin here:
The wood railings are finished. Now, for some extra challenge, you can use pictures of real wood to map onto the railings for a more detailed look. The procedural Wood texture can give you only so much realism. If you create your own wood maps, use your experience with the side panels to create UV layouts for the railings so you can paint realistic wood textures using Photoshop. You'll use custom photos and texture image maps next to simulate the rich wood in the decorative box later in the chapter.
Now that the railings are done and you have test renders, there are only two parts left to texture: the bullnose front of the wagon and the metal handle and screws. From here, take your time and create a bump map based on a fractal, as you did for the tires, and apply it to the bullnose's black shader. Figure 7.107 shows a nice subtle bump map on the bullnose.
And last, you'll need a metal shader for the screws, bolts, and handlebar for the wagon, just as you did for the axe exercise earlier in the chapter. Use a Phong shader with a blue-gray color and a low diffuse value, and assign it to all the metal parts of the wagon, as shown in Figure 7.108. You can then add an environment map to the reflection color, as you did for the axe earlier in this chapter to give the metal a reflective look.
Because metal is a tricky material to render, and a lot of metal's look is derived from reflections, you'll finish setting the Metal shader's attributes in Chapter 11 when you render the wagon. You'll enable raytracing to get realistic reflections and gauge how to best set up the Metal shader for a great look.
Figure 7.109 shows the wagon with all its parts assigned to shaders. Figure 7.110 shows a quick render of the wagon as it is now.
You can load the file RedWagonTexture_v04.ma from the Scenes folder of the RedWagon project to check your work or skip to this point.
With all the references you can find to any given object on the Internet, why not use real photos to create the textures for a model? That's exactly what you'll do here, with the decorative box you modeled in Chapter 3, using pictures of the real box.
You'll take this texturing exercise one important step further in Chapter 11 and experience how you can add detail to an object through displacement mapping, after you assign the colors in this chapter. This will allow you to add finer detail to a model without modeling those details.
The UVs on the decorative box aren't too badly laid out by default, as you can see in Figure 7.111. The only parts of the box that are missing in the UV layout are the feet. That is a common issue when extruding polygons: their UVs are rarely laid out automatically as you extrude them. Frequently, they're bunched up together in a flat layout that is difficult, if not impossible, to see in the UV Texture Editor.
First, you have to make room for the feet UVs:
Laying out UVs can be a time-consuming affair, as you've seen with the wagon. Although it's recommended that you follow along with this exercise to lay out UVs for the box, because doing so will give you more practice and experience with UVs, you can skip straight to colormapping the box in the next section by downloading the file boxTexture01.mb in the Scenes folder of the Decorative_Box project on the companion web page.
Position the UV layout of this foot onto the front of the box, as shown in Figure 7.119. Scale down the UVs to match the size of the foot in the model, more or less. Keep in mind that the box-front UV layout is upside down in the UV Texture Editor.
When you're all done, your UV Texture Editor should resemble the one shown in Figure 7.132. Because the box's decorations are seamless from the top of the box down to the four sides, let's lay out the UVs to make painting and editing in Photoshop easier.
Individually select the UVs for the right and left sides of the box, and rotate and position them to match Figure 7.133. Line up the sides to the top as closely as you can.
This was quite a tedious exercise. UV layout is a chore, but when it's completed, you're free to lay out your textures. You can check your work against the file boxTexture01.mb in the Scenes folder of the Decorative_Box project on the companion web page. You can also take a much needed breather. I sure hope you've been saving your work!
Now that you have a good UV layout, you can output a UV snapshot and get to work editing your photos of the box to make the color maps. Start with the following steps:
Click the Browse button, and select a location for your UV snapshot image. Generally, the project's Sourceimages folder is the best place for it. Make sure you don't write over the UV snapshot already created for you. Type in a name for your UV snapshot, and click OK to create the image. Figure 7.134 shows the option box, and Figure 7.135 shows the UV snapshot image.
These photo images of the box have been retouched and painted to create an overlap. This means that parts of the sides of the box show in the top image. As you can see in Figure 7.138, the top image extends slightly all around the four sides. This allows the different parts of the texture map (top and four sides) to overlap and blend with each other better when put on the model.
Save your work as boxColorMapWork01.tif in the project's Sourceimages folder. Make sure you're saving the TIF file with layers to preserve your layer work. You can also save the file as a PSD to preserve the layers.
Save the final Photoshop file as boxColorMap.tif, again keeping all the layers. (Change the name if you don't wish to overwrite the file already created for you in the Sourceimages folder.) Then, resave the file as a JPEG called boxColorMap.jpg. This is the file you'll map. (See Figure 7.141.)
Let's map this color image to the box and see how it fits. Based on rendering the box, you can make adjustments to the UVs and the image map to get everything to line up. This, of course, requires more Photoshop and/or image-editing experience, which could be a series of books of its own. If you don't have enough image-editing experience, have no fear: The images have been created for you, so you can get the experience of mapping them and learn about the underlying workflow that this sort of texturing requires. Follow these steps:
This gives you a pretty good place to work from. You need to adjust the color map image to be more seamless. The scene file boxTexture02.mb in the Scenes folder of the Decorative_Box project on the companion web page will catch you up to this point.
This is where image-editing experience is valuable. From here on, it's all about working in Photoshop to line up the sides to the top and the sides to each other to minimize lineup issues and yield a seamless texture map. Although we won't get into the minutia of photo editing here, we'll show the progression of the images and the general workflow used in Photoshop to make the color map's different sides and top line up or merge better. The images have already been created and are on the companion web page under the Sourceimages folder for this project.
First, using masking in Photoshop, spend some time feathering the intersection of the box's sides in boxColorMap.jpg so there is no hard line between the different sides and the top. Figure 7.146 shows a smoother transition between the different parts. This image has been created for you: it's boxColorMap02.jpg in the Sourceimages folder. Make sure you don't overwrite that file if you're painting your own.
In Maya, replace the original boxColorMap.jpg with boxColorMap02.jpg. Render and compare the difference. The top and front should merge a little better. In the persp view panel, orbit around the box in Texture View mode (press 6) to identify any other lineup issues. In some cases, as you can see in Figure 7.147, gray or black is mapped onto the box on its right side, and there is a warped area. Also, the crease where the lid meets the box is lower than you've modeled.
The blank areas on the box are outside the bounds of the image in the Photoshop image and can be fixed by adjusting the UVs in Maya. The same goes for the distorted areas on the side of the box—you just need to adjust the UVs:
Be careful when you're selecting the UVs of one side so that you don't select UVs from an adjacent side in the UV Texture Editor.
Figure 7.152 shows the UV Texture Editor and a persp view of the box with UVs lined up and ready to go. You can compare your work to the scene file boxTexture03.mb in the Scenes folder of the Decorative_Box project on the companion web page. Render a few different views to take in all the hard work. In Chapter 10, you'll light the box and prepare it for rendering, and in Chapter 11, you'll use displacement maps created from these photos to detail the indentations and carvings that are in the actual box. You've had enough excitement for one chapter.
For a challenge and more experience, create new image maps for the wagon and try out your own decal designs. As previously suggested, you can try to create more realistic wood maps for the wagon's railings. In Chapter 10, you'll begin to see how shading and rendering go hand in hand; you'll adjust many of the shader attributes you created in this chapter to render the decorative box in Chapter 11.
You can also try to create textures to map onto the hand model you created in Chapter 4, using photos of your own hand with extensive UV manipulation.
In this chapter, you learned about the types of shaders and how they work. Each shader has a set of attributes that give material definition, and each attribute has a different effect on how a model looks.
To gain practice, you textured a NURBS axe model using various shaders, including the Layered shader, to create a wooden handle with a metal spike tip.
Next, you learned about the methods you can use to project textures onto a surface and how you can bake these projections onto an object to avoid “swimming.” You learned about Maya's texture nodes, including PSD networks and the basics of UVs, and how to use them to place images onto your wagon and decorative box models in detailed exercises exposing you to manipulating UVs and using Photoshop to create maps.
Texturing a scene is never an isolated process. Making textures work involves render settings, lighting, and even geometry manipulation and creation. Your work in this chapter will be expanded in Chapters 10 and 11 with discussions of lighting and rendering.
Just like everything else in Maya, it's all about collaboration—the more experience you gain, the more you'll see how everything intertwines.
However, for Maya to be an effective tool for you, it's important to have a clear understanding of the look you want for your CG. This involves plenty of research into your project, downloading heaps of images to use as references, and a good measure of trial and error.
The single best weapon in your texturing arsenal, and indeed in all aspects of CG art, is your eye, your observations of the world around you, and how they relate to the world you're creating in CG.