An In-Depth Look at UVW Mapping an Object

3ds Max 5 includes an incredible array of new tools for UVW-mapping an object. Depending on your project, and on your budget for extra plugins, mapping and texturing an object is a breeze (especially when compared to earlier versions of the program.)

In this tutorial, I'll show you the basics of getting around the Unwrap UVW interface, a few methods for automatically mapping the object, and some techniques you can use when the automatic mapping doesn't quite do what you need it to. I've also included a brief explanation of how you can use Deep Paint 3D, by Right Hemisphere, to streamline your texture mapping process. Hopefully, by the time we're done, you'll be familiar enough with the new tools that you'll be able to find a quick and effective method for mapping any object. Note: Some images have been scaled down, to fit better on the page. Simply click an image to bring up the full-resolution version.

Credits go to Phil Bedard and Francis Bernier for the model and texture.

If you think of your 3d mesh as a sculputure, then you can think of your mesh's texture map as your sculpture's paint job. It fills in all the colors and details that geometry can't. The only problem is, while you can paint directly onto a sculpture, a texture map has to be a flat image. Perhaps a better analogy, then, would be if you had to paint on a sheet of paper, cut it up into little pieces, and paste them onto your statue.

That's the essence of what a texture map is - a flat drawing that's cut up, rotated, and fitted onto your mesh. A UVW map is the template that tells your 3D software exactly how to cut up the texture map and where to place it on your object.

If you've painted texture maps in the past, you probably know that bad UVW mapping coordinates can make the texturing process a major pain. I'll explain in this tutorial how to actually go about setting up UVW coordinates, but it helps to know ahead of time what can make a UVW map good or bad. There are a few main points to keep in mind, but if you stick to the analogy of gluing paper to a statue, you should do alright.

First, you usually want to break your UVW map into as few pieces as possible. This makes drawing the texture map a lot easier, because you have fewer seams that you have to make sure line up, and it's easier to keep track of which part of the map goes onto which part of the object.

Second, you want to minimize stretching. Stretching is what happens when there's less texture detail on one polygon than on the next. If you go back to the wallpaper analogy, stretching would mean the wallpaper just doesn't fit right on your statue - about your only option is to crumple it up a bit to fit the shape correctly. Of course in your 3D program, it doesn't crumple, it acts a lot more like you had drawn your texture on a rubber balloon. If it doesn't fit perfectly, you have to stretch it to cover the whole form, and your paint job will look distorted.

Third, avoid overlapping mapping coordinates. You can't paint two different things on the same part of the texture map. The exception is when you have two parts of your object that will be getting the same texture map anyway - this is especially common when you have a symmetric object, or an object with repeating details. In the space ship image above, only half of the bottom of the ship is textured, but both halves of the object make use of the same texture space. The engines also use the same texture map as each other.

Fourth, you want to make sure your mapping coordinates use the texture space as efficiently as possible. If you're restricted, say, to a 256x256 image for your texture, any large gaps between mapping coordinate clumps are just wasted space - if you could scale all your coordinates up a little bigger, and rearrange them to fill in the space (without overlapping, of course) all your details would be a little bit higher resolution.

Finally, it often helps if your mapping coordinates all map the same amount of texture space into 3D space. If one three-meter panel has 64 texels mapped to it, every other three-meter panel should use 64 pixels. It looks strange if one part of an object has a lot more detail than another, and it's much easier to match up seams if the texture resolution is consistent. There are exceptions to this, of course - when mapping a character, for instance, the head and face often get more detail than the rest of the body, since they're much more important.

In practice, you have to balance these guidelines against each other to create an efficient UVW map. You also need to keep in mind that UVW mapping an object is an art form in its own right, though an incredibly dull one that you want to spend as little time on as possible. There's no "perfect" set of mapping coordinates for an object, and you can always do a better job. The trick is to decide what's good enough for your project, and get there as quickly as possible.

The Basics

In this tutorial I'll be working with a space ship I recently modeled. It's a fairly complicated object mapping-wise - it has lots of curved surfaces mixed in with a lot of chamfered edges and beveled segments, and they're all going to require a different method for mapping. I'm going to assume that you have your own model that needs UVW-mapping coordinates, though hopefully it isn't as complicated as this. (As a note, don't be fazed by the fact that this ship has multiple smoothing groups and materials set up. None of this should affect the UVW-mapping process.)

Before we begin, I'm going to go over a few basics, and mention a few shortcuts. First, three hotkeys you'll find immensely useful are F2, F3, and F4. F2, when pressed, toggles "Shade Selected Faces" mode - essentially, when this mode is on, selected faces will appear in bright red. F3 toggles wireframe/shaded mode, and F4 toggles "Edged Faces" mode. All are very useful throughout the modeling process, but especially when doing UVW-mapping.

If you haven't already, select your object, and add an "Unwrap UVW" modifier.

Last on our list of basics... Clicking on the "Unwrap UVW" modifier in the modifier stack will go to the "Select Face" sub-object level. This means you can click on your object, in the viewport, to select the faces you want to work on. And... I hope you know this already, but you can ctrl-click to add more faces to the selction set, and alt-click to remove faces.

The Unwrap UVW Interface

With that out of the way, let's begin. Click on the "Edit" button to bring up the UVW-mapping window. What you see will probably be a garbled mess, that's fine, that's what this tutorial is for.

Let's simplify things a little. If you didn't do so earlier, in the modifier stack, click on "Unwrap UVW" to go to "Select Face" mode. Drag a selection box around your entire object to select all the faces. Now, click on the "Planar Map" button in the Unwrap UVW rollout. This should make your uvw mapping coordinates look a lot simpler (but still not ideal for texturing.)

Now, if you'll switch back to the Edit UVWs window, we'll briefly go over the major features of the interface. In the top-left corner of the dialog, you have your usual modifier tools (move, rotate, scale, freeform, and mirror.) Once again a handy little tip, with the move and scale tools, holding [SHIFT] before clicking will allow you to move (or scale) the selection along only one axis - try it, I'm sure you'll see where that can come in useful.

In the bottom-right corner of the interface you'll find all the panning and zooming options,and below those are two buttons - "Rotate +90" and "Rotate -90". Very straightforward, but very useful.

To the left of those is the "Selection Modes" box. This contains some of the most significant improvements over previous versions of the Unwrap UVW tool. By default, vertex sub-object mode is selected - but to the right are buttons to change to edge and face sub-object mode, respectively. (These will be a welcome change to users of older versions of Max.) In Vertex mode, you modify mapping coordinates by moving around the corners of polygons in UVW space. In edge mode, you move the edges between two vertices. In face mode, you got it, you move faces around (which effectively moves the surrounding vertices.)

Also note the + and - buttons, which allow you to expand and contract the current selection. Select Element is quite nice too, but we're not in a good position to demonstrate its uses yet. Don't worry, we'll get to it soon enough.

Another great feature of the Unwrap UVW tool is that the selection in the Edit UVW window is the same as the selection in the 3d viewports, so you'll never have problems finding the right polygon. (this is one situation where turning on "Shade Selected Faces" mode, F2, is useful.)

Automatic Mapping Features

Now that you have a passing familiarity with the Unwrap UVW interface, let's do some actual mapping. Before we begin, I always like to apply a checkerboard texture to my objects, so that it's obvious when polygons are mapped well. Go into the material editor, select an unused material, expand the "Maps" rollout, and click on the button to the right of "Diffuse Color", labeled "None". In the window that pops up, double-click "Bitmap", and go find a suitable checkerboard texture (don't have one? Here, use mine!) Don't forget to click the "Show Map in Viewport" button, and apply the material to the object. Your object should look something like the image to the right.

Close the material editor, and go back to your Edit UVWs window (you may have to click "Edit" again.) Note that the object's material now shows up as the background in the Edit UVWs box - isn't that handy? If you don't like it, you can always disable it by clicking the "Show Map" button at the top of the Edit UVWs window. Also note the dark blue box in the grid. That designates the boundaries of your texture map. If you mapping coordinates go outside of it, they'll wrap around to the other side - so be careful. (You really don't need to worry about that until the end.)

Let's take a look at the first automatic UVW mapping method. Click on the "Mapping" menu, then "Flatten Mapping". Make sure the three checkboxes are checked, and hit "OK". You'll see your object broken up into chunks, almost like pieces of a puzzle. If you printed this out and cut out all the pieces, you could actually assemble them into a rough version of your object - they're not perfect, but they're pretty close.

This is a good place to stop and demonstrate the "Select Element" feature. Check the box as shown, then click on any of the chunks in the Edit UVWs window. Notice it selects the entire element, not just the face (or edge or vertex) you clicked on. This is a great feature if you need to move whole chunks around.

But now that you've seen the default settings for Flatten Mapping, let's experiment a bit more. Go back to Mapping->Flatten Mapping, and play with the parameters a bit - specifically the "Face Angle Threshold" spinner. A bigger number will generally result in larger chunks, while a smaller number will produce smaller, but more numerous chunks (there will also be less stretching.) I used values of 75 and 25 for these examples. Depending on how you're going to texture the object, both results have their merits. As for me, I'm not quite happy yet, so let's play with some other mapping methods.

Go back to the "Mapping" menu, and click on "Normal Mapping." In the dropdown menu at the top, select "Box Mapping". All of the options are useful, but box mapping more than others. Hit OK to see the results. The object has been broken into six chunks, each mapped from a different direction. This has a major advantage over the box mapping option in the normal "UVW Map" modifier - the six views of the object aren't all placed on top of each other. But play with the options, try some of the other mapping methods (Left/Right Mapping, perhaps?) and see if you find something you like. If not, well, we're going to have to do something a little more complicated.

Of the two automatic methods we've looked at, Flatten Mapping is probably the most promising. But if you have a complicated object, or need more carefully placed UVW coordinates, there are lots of options left.

Manual Mapping Techniques

To begin, I'm going to reapply "Flatten Mapping" with the settings as shown at the right. This is as good a starting point as any, since I only have to clean up the mapping coordinates I don't like. (Most of the larger chunks should be usable.)

One of the first problem areas on my object is the cockpit - it's curvature is too great for Flatten Mapping to place all of its polygons in the same UVW mapping clump. So what I'm going to do is select all the faces of the cockpit in the perspective viewport, then in the Unwrap UVW modifier rollout, click on "Planar Map".

The result isn't quite ideal - the new mapping coordinates take up almost as much space as all the old ones combined, but it can be easily rotated and scaled back down to something reasonable. I put the scaled coordinates off to the side for now - we'll rearrange everything later.

I've been at it some more, planar mapping continuous chunks of polygons. But now I've reached a point where I've got a lot of polygons surrounding the main body of the ship that planar mapping just isn't ideal for. A cylindrical map would be best. (Obviously this may not apply to your mesh, but I just want to show you the technique.)

I applied a "Mesh Select" modifier, and selected all of the faces that I thought would work well with cylindrical mapping. (Selecting the faces in the Unwrap UVW modifier, unfortunately, doesn't work.)

When I finished selecting faces, I added a "UVW Mapping" modifier. I changed the mapping to "Cylindrical" and hit "Fit". This gave me the results I wanted. I then added another "Mesh Select" modifier, but didn't select any faces. MAX keeps track of which faces you have selected, and we want to be able to work with the entire mesh when we get back into our next Unwrap UVW modifier, not just the ones we cylindrically mapped. That done, I applied another Unwrap UVW modifier.

Once again, the mapping coordinates aren't quite ideal, so I need to scale and move them so that they don't overlap. It would also be nice to break this large chunk up a bit. To do this, I selected the faces that I wanted to become a separate element, then clicked on Tools->Break (Ctrl-B). Now I can move those faces off to the side without also stretching the adjacent faces.

I found a couple situations where some faces could be joined easily without overlapping, even though planar mapping wouldn't work quite right. When you apply Flatten Mapping, these usually end up as chunks of one or two polygons just sitting on their own.

You can join these polygons together pretty easily by going into edge mode (make sure "Select Element" isn't checked), then select the common edge on one of the two elements you want to join. Note that the common edge on the other element turns purple.

Clicking on tools->Stitch Selected will connect the elements together (click "ok" on the stitch tool dialog - the default settings are fine.)

I stitched together a few more elements, but there are a few overlapping polygons. A simple solution here is to just weld the vertices together to make one continuous piece. It'll cause a little stretching, but if it's on a small polygon, you'll never notice. To do a target weld, click on Tools->Target Weld, then click and drag a source vertex onto its destination. Much better!

You can see I was able to connect together a nice run of polygons using the stitch tool and target welding.

Using the above methods, I've managed to clump most of my polygons together into nice UVW groupings, and get rid of most of the clusters of only one or two polygons. Now all that's left to do is fit all the mapping clusters back into normal texture space (denoted by the blue square.) Fortunately, Max provides a tool to do this too.

Click on Tools->Pack UVs, and fill in the options as shown. Hit OK! You should get a nice, even distribution of polygons. Of course, you can do it manually by rotating and scaling chunks. This will usually give you better results, but it's much more time consuming. You can also put matched segments on top of each other to conserve texture space.

And that's it! You've seen most of new mapping tools, you've seen how to do a quick job of mapping your object, and you've seen how to do it all manually if you need to. I reccomend using a utility like Texporter to export the mapping coordinates to an image, which you can use as a basis for your texture map.

Just one section left in this tutorial, and that's a bit about a handy utility called Deep Paint 3D. But first I'd like to mention two other useful improvements in Max 5.

First, Max 5 supports nearly all Max 4 plugins. This has its obvious benefits. Second, Max 5 added support for Photoshop's .PSD format, up through Photoshop 7. It also detects when a texture file has changed, and automatically updates the viewport. This makes texture mapping an object a breeze - just load the .PSD file in the material editor, and whenever you change the texture in Photoshop (and save), Max will load it automatically. Now, on to Deep Paint 3D.

' '

Deep Paint 3D

Deep Paint 3D can be an incredibly useful tool to aid in texture mapping your object. (They have a free trial period, too. You can download the program here: http://www.righthemisphere.com/products/dp3d/index.htm) Most people I know use Photoshop for painting texture maps, but it can get difficult detailing every little surface of an object, especially if it's chopped up into a puzzle like my space ship. :)

As far as I'm concerned, that's where Deep Paint is most useful. It allows you to paint directly onto the surface of the object. Or more precisely, it can render out a still shot of the object from any view, which you can import into Photoshop. There you can paint on top of the rendering, and when you're done, send that back to Deep Paint, which translates your changes back onto the texture map. When you're all done, you can send the texture back into Max. This means you don't have to be nearly as precise when setting up mapping coordinates - a simple "Flatten Mapping" will almost always suffice.

I'll walk you through the procedure of exporting to and from photoshop, since Deep Paint has a lot of other features that can make this less than straightforward. First, in Max, I'll apply a new material with a rough-looking texture map to the ship, just as a starting point. (We're not going to do a real detailed texture here, I'm just going through the motions.)

If you've installed Deep Paint correctly, you'll find a "Right Hemisphere" listing under your Utilities tab - click "More" to find it. Double-click on it, then click on the button labeled "Paint Selection" - that'll load up Deep Paint, and send the object and materials over to it. You'll see a "Material Import" dialog - hit OK.

Your object should be loaded, texture and everything. Deep Paint 3d is a fully functional paint program, but personally, I like photoshop a lot better. So there are only a very few tools I actually use in deep paint. In the toolbar is a Rotate tool. This is essential, but pretty self-explanatory. The zoom tool is handy too if you're going to be doing any detail work. So rotate and zoom your object around until you find an angle you like, and I'll show you how to get it into Photoshop.

Click on the brush tool. (it's just an odd effect of the interface that you can't export unless you have a painting tool selected.) Next, up at the top of the screen, click on the "Toggle Projection Mode" button - this lets the program know you want to paint directly on the mesh. Then just to the left of that, click on the "Export Material to Photoshop" button. If it's not already running, Photoshop will load up, and your texture will appear. (Depending on your operating system, you may get a "Server Busy" error message hidden under the photoshop window - just click on "Switch To" to continue.)

Once the texture is loaded, you're pretty much ready to paint on it. If you look at your layers palette you'll notice a lot of layers. The top one shows the geometry of the object - hide and unhide that as you need it. Under that is a layer labeled "Paint layer: Color". Do all of your painting there. When you switch back to Deep Paint, it'll take whatever's in that layer and apply it to the mesh. To be honest, I haven't experimented much with the other layers (bump, glow, etc) but they shouldn't be too hard to figure out, if you need them.

One other useful note, if you want to rubber stamp something from the reference layer to the paint layer, check "Use All Layers" in the stamp tool's properties - this will keep you from having to change layers every time you want to set a different clone source.

Once you're done adding details, switch back to deep paint, and click on "Fetch the Material from Photoshop". (Click "Yes" when it warns you that the operation will not be undoable.) If you switch back to the rotate tool, you'll be able to see your new details applied to the object.

Go back and forth as often as you need to, rotating the object and drawing more details. When you're all done, you'll want to send the material back to Max (this saves the texture map back out to the original texture file - so be careful, if your file was a psd, it'll overwrite all your layers!) To get the material back into Max, get out of projection mode by clicking the same button as before, then click on the "Send Materials to 3D application" button. Back in Max, your texture should load automatically.

Conclusion

I hope this tutorial was helpful. With any luck, you've learned how to navigate the Unwrap UVW interface, how to apply automatic mapping coordinates, and how to map an object manually when you need to. Keep experimenting, though. By no means did I cover every detail and every feature of the Unwrap UVW tool, just the ones I felt are most useful for my work. You may find you prefer other tools over the ones I showed you. If you have any questions, feel free to e-mail me. Until next time!

- Waylon Brinck