![]() |
Paul Naas |
![]() |
MART420: 3D Modeling & Animation I |
UV MAPPING |
Introduction
There are several techniques for texture mapping 3D surfaces depending on the surface type (NURBS, polygons, subdivision surfaces). Some techniques involve preparing the surfaces for texture mapping. For example, when texture mapping polygonal and subdivision surface types you need to understand how textures are applied using UV texture coordinates. UV texture coordinates, or UVs as they are more commonly called, are two-dimensional coordinates that reside with the vertex component information for a 3D surface. UVs control the placement of a texture map on a 3D model by correlating the pixel position of the 2D texture map to the vertex positions on the model, so that the texture gets positioned (mapped) correctly. For polygonal and subdivision surface type models, which have an arbitrary surface topology, the UVs can be explicitly created and modified to suit the requirements of the texture map. In this lesson you’ll learn the basic principles of UVs by applying (mapping) an existing image (texture) to a simple polygonal model and creating and modifying the UV texture coordinates so that the texture map appears correctly on the surface. In this lesson you learn how to: Creating a cracker box model You begin the lesson by creating a model of a cracker box using a polygonal cube primitive. The dimensions you’ll use for the cracker box are based on a texture map you’ll apply to the model in this lesson. To create a cracker box model using a cube primitive 1. Select Create > Polygon Primitives > Cube > . 2. In the Polygon Cube Options window, select Edit > Reset Settings, set the following options, and then click Create: A cube primitive in the shape of a rectangular box appears in the scene view. When the Create UVs option is on it ensures that the primitive object is created with a set of default UV texture coordinates. All polygon primitives in Maya provide an option for creating UV texture coordinates at the time of creation. 3. Using the Channel Box, set the Translate Y attribute to 5 so that the cracker box is repositioned to rest on the X axis. 4. Rename the pCube1 primitive to: cracker_box.
Applying a texture map to a polygon mesh In Maya, surfaces appear in a rendered image based on the shading materials you apply to them. The default shading material that gets assigned to surfaces provides basic attributes such as color, transparency, and incandescence. Depending on your final image requirements, you can enhance the visual impact of an object by adding one or more texture maps to the assigned shading material. One basic texture map you can apply is a bitmap image also referred to as a file texture. In this lesson, you apply a texture map we’ve created for your use on the cracker box. For more basic information on shading materials and texture maps see the Rendering chapter of this guide and the Maya Help. To assign a shading material to the cracker box This displays the cracker box with a default gray, smooth shading material, lit using default lighting. Turning on Smooth Shade All displays the assigned shading material you apply to the cracker box in the steps following.
2. In the scene view, right-click on any region of the cracker box and select Assign New Material > Lambert from the marking menu. A new Lambert shading material is created and assigned to the cracker box. The Attribute Editor appears and displays the various attributes for the new Lambert shading material.
The new Lambert material is identical to the default gray material that was previously assigned to the cracker box. However, it’s always a good practice not to modify the default shading material in the scene and create a new shading material and modify it to suit your requirements. 3. In Attribute Editor, double-click in the lambert2 box and then type: box_material to rename the shading material.
Renaming the shading material lets you easily identify it later on when you need to edit it. Naming items uniquely in Maya is a useful habit. 4. In the Attribute Editor, move the Color slider fully to the right so that the color box appears white.
The shading material assigned to the box model also updates in the scene view so it appears in a brighter tone. 5. Click the Map button located to the right of the Color slider. The Create Render Node window appears and lists the various texture options you can apply (or connect) to the color channel of the box material. 6. Click PSD File from the list of 2D Textures.
Choosing this option specifies that you want to apply an Adobe® Photoshop® format file as a texture. A PSD format file lets you keep the various components of your texture map on multiple layers. This is useful when you need the ability to edit a component of the texture during production. The Attribute Editor updates to display the options for the PSD File texture. Tip 7. Click the Browse button (folder icon) to the right of the Image Name attribute to specify the image file for the texture map.
A browser window appears with the path set to the default project directory. By default, Maya looks for source images for texture maps in a sourceimages folder whenever the project folder is set. Maya can use file texture images from anywhere on your workstation or local network. For example, you can have images on a central disk drive that is shared among users in a production environment. 8. Select the image file named UVLesson.psd that is provided on the "Handouts" page and then click Open. The image contains 2D artwork for the front, back, top, bottom, and sides of the cracker box that was generated in Adobe® Photoshop®.
A small preview of the image appears in the Texture Sample box in the Attribute Editor. When a texture is applied to a shading material its attributes get added to the existing attributes for shading material. That is, all of the existing shading attributes remain unchanged except for the attribute that gets modified by the texture. In this case, the grey color is substituted by the image of the cracker box artwork. 9. In the scene view, select Shading > Hardware Texturing from the panel menu to display the texture map on the cracker box model.
The texture map does not appear correctly on the cracker box model. The texture map was designed so that specific sides of the box receive specific regions of the image. Instead, the complete image is being placed on every side of the object. To correct this problem you must modify the default UV texture coordinates for the model so they match the layout of the texture image. To do this, you use the UV Texture Editor. Viewing UVs in the UV Texture Editor The UV Texture Editor lets you view and interactively edit the UV texture coordinates for polygon and subdivision surface types. UVs appear laid flat within the UV Texture Editor’s 2D view. It also lets you display the 2D image for the texture map in relation to the UVs. These features are critical for accurate and efficient placement of texture maps on polygon and subdivision surface types. In this lesson, your goal is to ensure that the shape and placement of the UVs match the image as it appears in the 2D view of the UV Texture Editor. This will ensure that the map appears correctly on the cracker box model in the 3D scene view. To open the UV Texture Editor in a two pane layout 1. In the scene view, right-click any of the Quick Layout buttons on the Toolbox to display the pop-up menu of Quick Layout shortcuts and select Persp/UV Texture Editor from the list.
The panel layouts update to display the Perspective view in the left pane and the UV Texture Editor in the right pane simultaneously. (You can close the Attribute Editor if it is still displayed.)
This two pane layout is helpful for two reasons: • The two view layout shows you how one item selected in the 3D view relates to the UVs displayed in the 2D view of the UV Texture Editor and vice versa, without having to open and close the views repeatedly. UVs do not initially appear in the 2D view of the UV Texture Editor until you select an object or change the selection mode for an object in the scene view. To view UVs in the UV Texture Editor 1. In the scene view, right-click any region of the cracker box model and select Object Mode from the marking menu.
2. Select the cracker box model. 3. In the UV Texture Editor, dolly the view outwards so you can see the UVs for the cracker box as shown below. (To dolly, press the Alt key and drag the mouse to the left while holding down the right button on your mouse.) The UV texture coordinates for the cracker box model appear in the 2D view of the UV Texture Editor as a flattened, two-dimensional representation. The UVs appear highlighted with lines connecting the UVs to indicate the region of the texture the UVs represent. The image you specified as the texture map for the box also appears in the 2D view of the UV Texture Editor in the upper right quadrant of the 2D cartesian graph called the UV image range or UV Texture Space. The coordinates for this quadrant range from 0, 0 to 1,1 and represent the texture space for the surface. How the UVs appear in this quadrant in relation to the displayed image has a direct bearing on how the texture gets mapped onto the surface. Tip
In this example, the UVs for the cracker box appear like a box where all six sides have been cut open and then unfolded flat. The texture map does not appear correctly on the cracker box for a number of reasons: • The UVs for the cracker box extend well beyond the default 0 to 1 UV range for the texture map in the 2D view of the UV Texture Editor. As the texture map displays within the 0 to 1 range, the UVs should also be positioned to fit within the 0 to 1 UV range, in most cases. Otherwise, the texture map repeats on the surface mesh, as it does in this case. • The position of the UVs do not match the specific regions of the image we’ve provided for the texture map. The regions of the image show the front, back, top, bottom, and sides of the box. The UVs should specifically match these regions to display the texture correctly. UVs do not automatically align themselves to a texture, you must manually reposition them. • The shape of the UVs don’t match the aspect ratio of the cracker box model in the scene view: -10 (Height) X 8 (Width) X 3 (Depth). This is because the default UVs for a Maya cube primitive are created based on a predetermined default shape and do not get updated if the shape or scale of the primitive is modified later on. There are a number of things you can do to correct these issues depending on the situation. For this lesson, you will correct the UV and texture map misalignment by doing the following: • Map a new set of UVs for the cracker box model that better matches the individual faces of the cracker box. (While the existing UVs could be modified, you’ll learn how to create new UVs in this lesson that will better match the size and scale of the 3D model. • Ensure the new UVs fit within the 0 to 1 UV range in the UV Texture Editor. • Reposition the UVs so that they correlate to specific locations on the 2D image using the UV Texture Editor. This will ensure that the various sides of the box receive the correct regions of the texture map. Mapping UV texture coordinates It is often necessary to create new UVs for a surface mesh in order to texture map it correctly. These situations include: • Texture mapping a surface that doesn’t have existing UVs. This can occur when you import 3D models from other software applications that don’t create UVs. • When the UVs for a surface are badly jumbled or are missing some UVs. This can occur when a surface has been edited or modified in some way and it becomes hard to determine what UVs may be missing as a result. • When you need a unique set of UVs for a particular purpose. For example, if you want to paint a texture map directly onto a 3D surface, you may want to map UVs that allow you to paint using the 3D paint tools in Maya. Alternatively, you may want to create a unique set of UVs specifically for baking textures or light maps. Maya lets you create UVs for polygonal and subdivision surfaces using a process called projection mapping, also referred to as mapping UVs. Maya provides several projection mapping types that map what gets viewed by a particular projection to a flat 2D view that can be subsequently correlated to your texture map using the UV Texture Editor. In this lesson, you use a feature called Automatic Mapping to create new UVs for the cracker box model. Automatic mapping lets you specify the number of planes that will be used for the UV projection. Automatic Mapping is normally used when mapping UVs that require multiple projections of organic shaped models as it has the advantage of producing UVs that are proportional in scale to the world space area of the mesh faces of the surface. Automatic mapping is useful when your mapping requirements are for non-overlapping UVs which fit within the 0 to 1 texture space, but which do not have to be contiguous; for example, when using the 3D Paint tool, Maya® Paint EffectsTM, Maya® FurTM or Maya® HairTM. You use Automatic Mapping in this lesson because it can produce a UV projection from three planar directions simultaneously which makes it a good choice for the shape of the cracker box model. That is, you can map UVs for the front and back, top and bottom and the two sides in one operation. This projection type is referred to as a triplanar projection. To map UVs using Automatic Mapping 1. In the perspective view, select the cracker box as an Object. 2. From the Polygons menu set, select Create UVs > Automatic Mapping > . The Automatic Mapping Options window appears. 3. In the Automatic Mapping Options window, select Edit > Reset settings, set the following options, and then click Project: • Planes: 3
Setting Planes to 3 creates UVs based on projections from three separate directions. Setting the Percentage Space option to 2 sets the size of the space that appears between each of the separate UV projections when they are laid out in the UV Texture Editor.
When the projection is complete the new projected UVs from the triplanar projection appear in the UV Texture Editor. Note 4. In the UV Texture Editor, dolly the view so it shows only the 0 to 1 UV range area that displays the image for the texture map and the new UVs (as shown below). 5. In the UV Texture Editor, select Image > Dim Image.
The intensity of the image map is reduced so you can view the UV borders on the projected UVs more easily. The new UVs appear in the UV Texture Editor as shown below.
• The six rectangular UV shapes, referred to as UV shells or simply shells, now match the aspect ratio for each of the six sides of the cracker box better than the earlier UVs. • The UV shells fit within the 0 to 1 UV texture range. Automatic mapping fits the UVs to the 0 to 1 range by default. The texture map still does not appear correctly on the cracker box because the UV shells need to be repositioned so they align with the corresponding components of the image map. While the shape of each UV shell is now recognizable as being associated with the cracker box, it is not apparent which components in the UV Texture Editor correspond to a particular face on the cracker box. In the next section you learn how to select and reposition the UV shells so they better match the image for the texture map. Working with UVs in the UV Texture Editor When texture mapping a polygon or subdivision surface type model it is often necessary to modify the UV components for a model so they match the texture map. The UV Texture Editor provides many tools for working with UVs. In this section you learn how to: • Select UVs from either the scene view or the UV Texture Editor and accurately correlate them. Selecting UV components is critical to modifying them accurately. • Sew UV shells together to reduce the number of UV components you need to work with. • Move and rotate UVs within the UV Texture Editor to make the UV shells align to the cracker box texture map. Selecting UV components You can select UV components from either the scene view or within the UV Texture Editor. Displaying both the 3D scene view and the 2D view of the UV Texture Editor lets you easily correlate which UV components are associated with a particular edge or vertex on the 3D model. This is very helpful to understand the layout and orientation of your UV texture coordinates in relation to the image used for a texture map and how the map appears on the model in the 3D scene view. To select UVs for a 3D model in the scene view 1. In the UV Texture Editor, select Image > Display Image to turn off the display of the texture image. Display Image works by turning the display of the assigned texture on or off in the 2D view of the UV Texture Editor. Turning the image off temporarily aids in viewing only the UV components. This will be useful in the steps that follow.
2. In the scene view, right-click on the cracker box model and select UV from the marking menu that appears. 3. In the scene view, select one UV on any corner of the cracker box. Selecting a UV is very similar to selecting a vertex on an object. That is, you select a point that resides in exactly the same position as the vertex. When you select a UV in the scene view, the corresponding UV is also selected in the UV Texture Editor. Note 4. In the scene view, right-click on the cracker box model and select Edge from the marking menu that appears. 5. In the perspective view, select the top front edge of the cracker box.
When you select this edge in the scene view, notice that two corresponding shell edges also get selected in the UV Texture Editor. This indicates the following: • The selected edge is shared by two faces; the front and the top. • Selecting the top front edge in the scene view, identifies the corresponding front and top UV shells for the box. (indicated by the selection in the UV Texture Editor.) This is useful when you need to understand how the various UV shells relate to each other, especially when you have many UV shells for a model in the scene; for example, when you sew two UV shell edges together. In the steps that follow you select edges in the UV Texture Editor so you can sew them together. Sewing UVs Sewing UV shells together merges the UV shells together along a shared edge that you specify. Sewing UVs is useful for the following reasons: • You can move and modify the UV shells as larger contiguous texture units. This makes it more efficient to match the UVs to the texture in many situations. • Texture maps can appear more uniform across texture borders when the texture is applied to one or more sewn UV shells compared to many separate UV shells. Sewing shells together reduces the chance that an unwanted texture mismatch occurs along the texture edge. To sew shell edges together in the UV Texture Editor 1. In the scene view, ensure that only the top front edge of the cracker box is still selected.
2. In the UV Texture Editor, select Polygons > Move and Sew UV Edges. The small rectangular UV shell is repositioned to match the top of the large UV shell and the two shells are combined into one. When you later select and move this sewn shell, it will move as one piece. When two UV shells are selected for sewing, the smallest UV shell is moved to the larger.
3. Repeat steps 1 and 2 for the remaining three edges on front face of the cracker box keeping in mind the following: • Select only one edge at a time in the scene view. • When you’ve completed the move and sew operation, your UV Texture Editor should show the front UV shell with the corresponding top, bottom, and side shells sewn to it. When fully complete, you will have only two UV shells to match to the texture image for the cracker box.
4. To display the texture borders for the two shells, select Display > Polygons > Texture Border Edges. (You can also launch this window by right-clicking the Toggle Texture Borders button on the UV Texture Editor’s toolbar.
In the UV Texture Editor, the texture borders for two UV shells now appear with a thicker line.
Displaying texture borders on the UV shells is useful for visualizing where the texture borders exist on the 3D model in the scene view. That is, any portion of the texture image that appears outside of the texture border will not appear on the surface. It is particularly useful for troubleshooting texture mismatches when they occur. Displaying the texture borders can also help to identify which UV shells are combined and which shells are not when you have many UV shells displayed in the UV Texture Editor. If you want to be able to view areas where UV shells overlap in the UV Texture Editor select Image > Shade UVs. When Shade UVs is turned on any selected UV shells appear shaded in a semitransparent fashion. Areas where the shading appears more opaque indicate the regions of shell overlap. In the steps that follow, you reposition the two UV shells in the UV Texture Editor so they coincide with the texture image. Moving UV components You manually reposition UV components in the UV Texture Editor using the tools within the Toolbox. To reposition an individual UV component you must first select it before selecting the Move Tool. To reposition an entire UV shell you must first select one individual UV from the shell it belongs to and then convert the selection to a shell before using the Move Tool. To move UVs in the UV Texture Editor 1. In the UV Texture Editor, select Image > Display Image. The texture image displays in the 2D view of the UV Texture Editor dimmed, as before. You need the image displayed so you can accurately reposition the two UV shells. Dimming the image aids in seeing the selected UVs. 2. In the UV Texture Editor, right-click and select UV from the marking menu that appears. 3. In the UV Texture Editor, select one UV on the UV shell you sewed earlier in the lesson. The UV coordinate appears highlighted in the 2D view. 4. Convert the selection to a UV shell by pressing the Ctrl key and right-clicking in the 2D view of the UV Texture Editor. Choose To Shell from the marking menu that appears. The selection changes from a single selected UV to selecting the entire UV shell. 5. From the UV Texture Editor menu, select Tool > Move UV Shell Tool > . 6. In the Move UV Shell Tool options window, turn off the Prevent overlap option which prevents UV shells from being moved so they overlap and then select Apply and Close. The Move Tool manipulator icon appears over the selected UV shell. 7. Drag the green (Y axis) and red (X axis) Move Tool manipulator handles to reposition the UV shell so it matches the displayed texture image.
The position of the texture updates on the cracker box model in the scene view as you do this. 8. Select one UV on the other remaining UV shell. The UV coordinate appears highlighted. 9. Convert the UV selection to a shell selection by pressing the Ctrl key and right-clicking in the UV Texture Editor. Choose To Shell from the marking menu that appears. The selection changes from a single selected UV to selecting the entire UV shell. 10. In the UV Texture Editor’s toolbar, click one of the Rotate UVs buttons to rotate the UV shell so it appears in the same orientation as the texture image. (Click the other Rotate UVs button to rotate it in the opposite direction.)
11. Confirm that the texture appears correctly on the cracker box model in the scene view by tumbling the scene so you can view the back of the box. Tip 12. From the UV Texture Editor menu, select Tool > Move UV Shell Tool. A move manipulator icon appears over the selected UV shell. 13. Drag the green (Y axis) and red (X axis) manipulator handles to reposition the UV shell so it matches the displayed texture image. The texture map should now appear correct on all sides of the cracker box when you’re finished. Tip
Tip If you need to move a single UV so it precisely matches a particular location on the texture map you can turn on Pixel Snap (Image > Pixel Snap). When you select and move the UV using the Move Tool, it will reposition the UV coordinate based on pixel boundaries. Beyond the lesson In this lesson you were introduced to a few of the basic techniques required to assign and accurately position texture maps on polygonal models using UV texture coordinates: • UV coordinates are essential for applying and accurately positioning texture maps on polygonal and subdivision surfaces. • UVs can be explicitly created for a surface mesh using a variety of UV mapping techniques. (Planar mapping, spherical mapping, cylindrical mapping, and Automatic mapping) • UVs are represented as 2D coordinates and are viewed and edited with respect to the 2D texture map using the UV Texture Editor. The UV Texture Editor provides many other tools for editing UVs. • UVs are usually positioned to fit within the 0 to 1 UV coordinate space unless the texture map requirements are such that the map needs to repeat across the surface mesh. • It is useful to display both the 3D scene view and the 2D UV Texture Editor simultaneously when texture mapping so that a correlation between the 3D model and 2D UV coordinates can be made. • You can visualize texture borders using Display > Polygons > Texture Border Edges. • You can view the regions where UVs overlap each other in the UV Texture Editor by selecting the UV shells and selecting Image > Shade UVs. You can open the PSD file you used in this lesson using Adobe® Photoshop® to learn how layers were used for the texture map. You can edit one or more of the layers to experiment with how the texture can be modified. After you modify and save the file in Photoshop®, remember to select Image > Update PSD Network in the UV Texture Editor so the texture map gets updated on the model in the Maya scene. If you would like to learn how to render an image of the cracker box model see the Rendering chapter of this guide as well as the Maya Help to learn more about lighting, shading, and rendering. This lesson used a simple polygonal model to introduce the fundamental concepts. When you work with more complex polygonal and subdivision surface models, you can also: • layout overlapping UV shells that occur as a result of UV projection mapping to ensure they fit within the 0 to 1 texture space using Edit UVs > Layout. • maximize the use of texture space by forcing the UV borders to be mapped to the full area of the 0 to 1 UV texture range using Edit UVs > Map UV Border • align UVs to one another or snap them to the grid in the 2D view • untangle a UV mesh that contains overlapping UVs using Edit UVs > Relax. • modify a group of selected UVs using UV Lattice and UV Smudge tools In general, you should begin texturing a model only after the model is fully complete. Otherwise, changes to the model may affect the associated UV texture coordinates which in turn will affect how the texture appears on the model. In this lesson you matched the UVs to an existing texture image. Many texture artists create good UV layouts for their models prior to creating the actual 2D images for their texture maps. This is done only after the model is fully complete. You can export a bitmap image of the 2D view of the UV Texture Editor to use as a guide for painting a texture in your favorite image creation software. In the UV Texture Editor, select Polygons > UV Snapshot to export the image. If you use Adobe® Photoshop® for image creation and editing you can create a UV snapshot in a .PSD file format that creates the UV image on a separate layer. To create the .PSD format file while working in the UV Texture Editor, select Image > Create PSD Network. If you want to learn more about a particular tool or feature that was used in this lesson, please refer to the Maya Help. |