Texture Mapping Character Meshes in Blender
Texture mapping a mesh with an image you assign on a vertex-by-vertex basis. Blender 2.37a makes this easier by creating seams, a grouping of one or more faces. By assigning an organized number of faces to a seam, we can easily organize the surface of our mesh for UV texture mapping.
Building a Test UV Map
First we need to build a test texture map that allows us to test our mapping coordinates and ensure nothing gets out-of-scale. The easiest way to do this is to create a checkerboard pattern thats is 512x512 pixels. Since this will be a grid of many small squares, we can check our mapping on the fly and make sure we don't stretch our scale our texture incorrectly on our seams.
Creating a test texture in GIMP is easy. Just create a new 512x512 image, then select a new background/foreground color that is contrasting but easy on the eye. Pick something that doesn't shout â€“ more mellow tones are much better; after a while your eyes can strain at striking colors. Select Filter->Render->Pattern->Checkerboard... from your image, then an offset of 0. This will give you a grid, that alternates your foreground and background colors.
First, jump into face select mode for your mesh. Are some of your faces see-through? You didn't switch your normals earlier â€“ go back to â€œFinishing the Meshâ€ in the above section and make sure all your normals are facing outward.
Once your faces are ready, we need to start grouping together faces for texturing. In Blender you can group together faces by using â€œseams,â€ reference lines that don't have any particular meaning to the mesh itself but help the artist divide up the surface of the object.
In the UV/Image Editor window, go to Image->Open and open the UV test texture you just created. In your 3D editor window, switch to face select mode and change the viewport shading (or draw type) to textured. Select all the faces of your mesh, then hit the U key to bring up the UV mapping window. Select Standard 1/1. Now move your cursor over to the UV image window and hit A again to select all the vertexes in the image window. Hit the S key to scale all the vertexes selected, then shrink your square down to about the same size as one of the squares in your grid. Grab it (G key) until it overlaps one solid square color located on your grid. This should give you a single, consistent color across the whole mesh; it will be our panic color. Should we ever accidentally forget to map a face to our UV image, this ensures some (albeit ugly) mapping will still exist. We should also more readily notice when a face doesn't have an assigned section on the UV image.
Now it's time to divide up our vertexes & faces. Switch into edit mode in order to start back with vertex manipulation. It should be a fairly straightforward operation: we select each vertex around our faces, so in the end we've outlined a ring of vertexes that will surround the mesh that compromises the face, including the neck.
After you select this ring of vertexes, hit Ctrl-E to create a seam. You can test it out by jumping back into face select mode, picking one 3D face, then hitting the L key to select all faces bound by this seam. Assuming all went well, you should see all the faces within the seam selected at once.
Continue creating seams around the body in much the same way for the back of the head, front of arms, back of arms, hands, torso, front of legs, back of legs, top of the feet and bottom of the feet. Don't be surprised if you have nearly a dozen or so seams separating your mesh into distinct regions. The way I usually distinguish what parts of the mesh are grouped by a seam is by visualizing what type of texture they might have. The face will have very detailed textures, so it will be its own seam. The back of the head may be more or less uniform, so it gets its own seam. Things that are still cylindrical, such as arms, legs and the torso can be tricky; you may need to divide them into half and texture them likewise. Blender doesn't quite understand us when we attempt to â€œwrapâ€ a seam around in a sort of deformed cylinder, so it's best to divide the top half and bottom half of the arm into to planes for ease in grouping. Same with legs and the torso; it's somewhat easier to divide them into front and back halves by grouping the front or backward facing faces likewise with seams.
There are a couple of good rules of thumb you should follow when creating seams. First, make sure you don't select three adjacent vertexes together... this will case faces to be selected and confuse Blender as to what you actually want to loop together. For example, let's look at the back of the head. It's very easy to select a midline vertex at the base of the occipital region of the skull, one close to the clavicle and then another adjacent vertex close to the temporal region. This selects a face that lies in a region of the neck, and makes Blender think that this polygon is what needs to be encapsulated in a seam.
To make things more plain to Blender, we need to de-select one of the vertexes. You may need to make some trial-and-error as to which of the three vertexes Blender can do without, but you should be able to remove one and still define a more sensible seam. In our example on the back of the head, we would remove the temporal vertex so that the occipital and clavicle vertexes would define the seam.
The second rule is that seams are reflexive â€“ that is you can select everything inside a seam or everything outside a seam. It all depends on which face you select first; if you select a face inside your seam and hit L, you select all face inside the seam's bounds. If you select a face outside the seam, everything outside will be selected. This means you could define seams for everything but the back of your torso, hands and tops of the feet.
Once you have all your seams defined, you should have a series of grouped faces to texture. Now for the difficult part; mapping them to our UV texture in correct proportion. We'll use the checkerboard pattern of our test texture to ensure that we are maintaining a consistent scale between seams and that we aren't warping our texture by making some areas bulge while other areas squish the texture together.
Once again, just to beat this point into the ground, make sure your object has all local coordinates by using Ctrl-A, Alt-G, Alt-R and Alt-S to apply all transformations and clear any transformations/rotations/scaling on your mesh. We don't want to be doing transformations relative to some object origin that doesn't sync with our mesh origin.
We will do our mapping work while in UV Face Select mode in Blender with our viewport shading sent to textured (Alt-Z key). First, let's select the faces on the front of the torso. Our seam should have defined all the faces we want, so we should just be able to jump into face select mode in Blender, select a single face on the front of the torso, then hit the L key to select the rest. Next, hit the U key and select LSCM to map our selected faces to our test texture.
The same least square conformal map method (LSCM) algorithm preserves angles and skews very well but does not preserve the scale; the resulting texture map will fill up our test texture window and probably be rotated the wrong way. Use the R key in the UV/Image Editor window to rotate the selected vertex until they appear oriented upright, in the same alignment as on the mesh. Next, scale your UV selection using the S key in the UV editor so the selection only takes up about 1/8th of the test image. Your end result should have a checkerboard pattern mapped onto your mesh's chest in a horizontal and even pattern.
To the back half of the torso in the same way, and transform the resulting UV map next to the front half of your torso on our test image.
Continue to use the LSCM method for the arms. Once you create the UV mapping for one half of one arm, you should uniformly scale the remaining UV vertexes to be the same size and dimension. Do the same for the legs as well. And while you're at it, find a scratch piece of paper and write down which group of faces (top of left arm, back of right leg, etc.) is at what part of your test image.
You can also use this method for the tops of the feet; but the bottoms of the feet we'll save for a later technique. Use LSCM for the tops of each foot, then scale it to match with the size of the leg's checkerboard pattern.
Hands are a little different. For our purposes we are just going to map our hands with a uniform skin texture, so we don't need to worry terribly about getting the proportions correct for each little finger. Switch into overhead view (7 key), select the faces for one hand, then select From Window from the UV mapping menu (U key). Scale it until it looks correct in proportion to the arm's test texture, then transform it in the UV editor window and place it next to some other UV vertexes you've been mapping out. Perform the same mapping for the other hand, and scale it until it's the same size as the first hand you mapped.
Use the same method for the bottoms of our feet. Rotate your viewport until you're looking directly at the bottom of your mesh, then select the faces at the bottom of one foot. Use the From Window algorithm for UV mapping, then scale accordingly. Repeate for the other foot.
Let's try the face next. The head seams are a bit more difficult since they are already rather angular and deformed. As a result, LSCM can't take us all the way. We'll first need to do the best approximation that we can then neaten up our UV mapping afterward.
First, let's select all the faces inside the seam for the front of our head. Once our faces have been selected, ensure we're looking at a 100% front view of our mesh by hitting the 1 key. From here, hit the U key to select our UV mapping and choose From Window. This should give you a UV mapping that pretty much resembles what you see in your viewport... which is great if you're just looking directly at the front of your mesh. But rotate to either side and you'll notice our UV map is seriously stretched out.
To fix this, we first need to pin the UV vertexes that look correct so they can't change. By using the UV editor's pin feature, we can alter the rest of our UV mappings without altering the ones we like.
In the UV editor, use the border select tool to select the vertexes in the center of the face that look correct. If you notice, mostly the cheeks and temporal regions are out of whack, so we'll largely select the inside area and affix it to our UV mapping. Once you select the appropriate vertexes, hit the P key in the UV editor to pin them to our map.
Now that we've made sure the faces that are correct won't move, let's fix the remainder. In the UV editor window, hit the E key and select good ol' LSCM. The LSCM algorithm should now take the angles of our faces into account and scale our UV mapping accordingly. The faces that were improperly mapped should be expanded into place, and all is right with the world.
You can now unpin your vertexes by mass-selecting them all using the border select tool, then using Alt-P to unpin all of your vertexes and return them back to normal. Zoom out a bit and now take a look at how the checkerboard pattern on your head looks in comparison to the checkerboard pattern on your torso. Chances are pretty good that the squares on the head aren't the same size or scale as the the squares on the torso. Select the vertexes in the UV window that correspond to your head, and use the S key to scale them appropriately. When you're done, the squares on the head should be approximately the same size as the squares on your torso.
Perform a similar mapping for the back of the head. You may need to tweak a few individual vertexes, but the process should remain the same.
You should now be done mapping the test texture to your mesh! Rotate your model around a bit and double-check all your UV mapping. Ensure the checkerboard pattern is uniform and consistent throughout. If not, tweak vertexes as necessary. You should also notice that the little UV mapped square that we created at the beginning of this chapter has now disappeared â€“ we've should have since re-mapped all of the vertexes that were once part of that global pool of UV vertexes. Once you're happy with the results, save a backup of your Blender file if you haven't yet done so.
Creating UV Textures
Now we'll work on replacing the test texture we've been using with a â€œrealâ€ texture that looks vaguely interesting. Before we paint textures onto an image, we need to build a template image that we can fill in. This template should allow us to see the bounds and sizes of our UV map, so when we import it back into Blender our current definitions match up exactly.
First organize your UV vertexes so that they fit into more of a â€œsquareâ€ arrangement. This should shove your mapping into the lower-left corner and have minimal dead space; all of our mappings should be crunched into the smallest square surface area possible.
If Blender and Python is installed correctly, you should be able to move your mouse over to the UV/Image Editor and click on UVs->Save UV Face Layout. Once the dialog for this plugin comes up, we need to select All Faces, Wrap, Wire Size: 1 and change the Size parameter to be 512; equal to the size of our test UV texture. Deselect Ob so that the object name does not become the file name, and type in the full path for the exported image including the filename, such as /home/user/uvmap. Once you're ready, hit EXPORT.
Open the resulting image up in GIMP. Note that each face is distinctly drawn in our UV map... something that we don't necessarily need. Using the select contiguous regions tool (Z key) with a threshold value of 0, select the whitespace surrounding your mesh. Reverse your selection using Select->Invert (Ctrl-I), then grow your selection by one pixel using Select->Grow... - this will give some margin of error on our texture. Use the bucket tool (Shift-B) with the Fill whole selection option to fill your UV maps with something nice and loud, like magenta. Using a fairly obvious color will let us know when a texture hasn't been properly UV mapped.
Next we need to create a skin pattern, as described in the earlier section BuildTxtGimp_Tutorial. You can use a digital photo of your arm if you wish; just select an area that's fairly uniform in tone and texture.
Next you can start filling in arms, hands and head with the skin texture. This will provide a base to start working with on a more detailed level. Create other patterns for clothing, hair, etc. and apply them to the UV map. keep going until all the magenta is completely eclipsed.
Once you have completed your pattern fills, start adding details such as eyes, teeth, more hair, whatever. This is your chance to be as (un)artistic as you wish.
Once you're either satisfied or repulsed by your final work product, save it. Jump back into Blender and open this newly revised image in the UV/Image Editor, then open the new image using Image->Open with the Relative Paths button selected. If all remained right with the world, this should overlap all of your current UV mappings and you should see a newly textured character model, ready for action.