|Blender Documentation Volume I - User Guide: Last modified July 08 2004 S68|
|Prev||Chapter 11. Textures||Next|
Relevant to Blender 2.33
UV mapping is a way to map 2D image textures to 3D models. It can be used to apply textures to arbitrary and complex shapes, like human heads or animals. Often these textures are painted images, created in applications like The Gimp, Photoshop, or your favorite painting app.
Procedurals as seen in the previous chapters are a nice way to texture a model. What is really nice about them is that they will always "fit". 2D images will not always fit on 3D shapes. Creating procedural textures is relatively easy, and they provide a quick way to get good results.
However, there are cases when this kind of textures is not good enough. For instance, the skin on a human head will never look quite right when procedurally generated. Wrinkles on a human head, or scratches on car do not occur in random places, but depend on the shape of the model and its usage. Manually painted images give the artist full control over the final result. Instead of playing with some numerical sliders, artists will be able to control every pixel on the surface. This means more work, but will lead to better images in the end.
A UV map is used to assign a part of an image to a polygon in the model. Each polygon's vertex gets assigned to 2D coordinates that define which part of the image gets mapped. These 2D coordinates are called UVs (compare this to the XYZ coordinates in 3D). The operation of generating this UV maps is also called "unwrap", since it is as if the mesh were unfolded onto a 2D plane.
UV mapping is also essential in the Blender game engine, or any other game. It is the de facto standard for applying textures to models; almost any model you find in a game is UV mapped.
UV Mapping is done in Blender within the UV Editor window and a special mode in the 3D Window called the Face Select Mode. The UV-Editor allows you to map textures directly onto the faces of meshes.
Each face can have individual texture coordinates and an individual image assigned to it, and can be combined with vertex colors to make the texture brighter or darker or to give it a color.
By using the UV-Editor each face of the Mesh is assigned two extra features:
Four UV Coordinates - These coordinates define the way an image or a texture is mapped onto the face. These are 2D coordinates, which is why they're called UV, to distinguish them from XYZ coordinates. These coordinates can be used for rendering or for realtime OpenGL display.
A link to an Image - Every face in Blender can have a link to a different image. The UV Coordinates define how this image is mapped onto the face. This image then can be rendered or displayed in realtime.
A 3D window has to be in Face Select mode to be able to assign Images or change UV Coordinates of the active Mesh Object.
First add a Mesh Object to your Scene, then enter the FaceSelect choosing the UV Face Select entry in the Mode menu (Figure 11-38).
Your Mesh will now be drawn Z-buffered. If you enter the Textured draw mode (ALT-Z, also called "potato mode") you will see your Mesh drawn in white, which indicates that there is currently no Image assigned to these faces. You can control the way the faces are drawn using the Draw Edges and Draw Faces buttons in the UV Calculation Panel. If Draw Edges is activated all faces will be drawn outlined. With Draw Faces activated, all selected faces will be shown in a light pink tone.
Press AKEY and all of the faces of the Mesh will be selected and highlighted by dotted lines. You can select faces with RMB, or BorderSelect (BKEY) in the 3D window. If you have problems with selecting the desired faces, you can also enter EditMode and select the vertices you want. After leaving EditMode the faces defined by the selected vertices should be selected as well.
Only one face is active. Or in other words: the Image Window only displays the image of the active face. As usual within Blender, only the last selected face is active and selection is done with RMB.
Change one window into the UV Editor/Image Window with SHIFT-F10. Here you can load or browse an image with the Load button. Images have to be multiples of 64 pixels (64x64, 128x128 etc.) to be able to drawn in realtime (note: most 3D cards don't support images larger than 256x256 pixels). However, Blender can render all assigned images regardless of size when creating stills or animations.
Loading an image in FaceSelect automatically assigns the image to the selected faces. You can immediately see this in the 3D window (when in Textured view mode).
In the 3D window, you can press UKEY in FaceSelect mode to get a menu to calculate UV Coordinates for the selected faces (Figure 11-40). This operation is called "unwrap", since it is as if the mesh were unfolded onto a 2D plane. You can also perform an unwrapping using the UV Calculation Panel in Edit Buttons. This panel also provides better control over the unwrapping process.
The available UV mapping algorithms are:
Cube - This determines cubical mapping.
Cylinder, Sphere - Cylindrical/spherical mapping, calculated from the center of the selected faces.
Bounds to 1/8, 1/4, 1/2, 1/1 - UV Coordinates are calculated using the projection as displayed in the 3D window, then scaled to the given fraction of the image texture.
Standard 1/8, 1/4, 1/2, 1/1 - Each face gets a set of default square UV Coordinates which are then scaled to the requested fraction of the image texture.
From Window - UV Coordinates are calculated using the projection as displayed in the 3D window.
LSCM - UV Coordinates are calculated using the Least Square Conforming Maps algorithm. Use it together with the marked seams.
In the UV mapping panel, you can tweak the way the mapping is done and how it is shown in the 3D window when the model is in Face Select Mode.
With 'View Aligns Face' enabled, Cylindrical and Spherical unwrapping is affected by the view. The view is supposed to be in front of the Cylinder/Sphere, with the caps at the top and bottom of the view. The Cylinder/Sphere is 'cut' at the opposite side of the view.
Size and Radius define the scaling of the map when using Cube or Spherical/Cylindrical mapping respectively.
With 'VA Top' (View Aligns Top) enabled, the view must look through the Cylinder/Sphere. It is cut at the top of the view.
If 'Al Obj' is enabled, the Cylinder/Sphere is rotated based on the Object's rotation.
With 'VA Top' enabled, 'Polar ZX' and 'Polar ZY' define how the view is rotated in respect to the poles.
Draw Edges and Draw Faces in the panel activate visualization of edges and faces in the 3D Window while in Face Select Mode. Selected faces in this mode will be drawn in a transparent purple (or the theme color), similar to Edit Mode. Drawing of Seams in Edit Mode and Face Select Mode can be toggled with Draw Seams. The colors of seams can also be changed in the Themes options.
In the UV Editor you will see a representation of your selected faces as yellow or purple vertices connected with dotted lines. You can use the same techniques here as in the Mesh EditMode to select, move, rotate, scale, and so on. With the Lock button pressed you will also see realtime feedback in 3D of what you are doing. Scaling and Translating of vertices can be done in the local X or Y axis of the map if needed. Just press XKEY or YKEY after entering the scale command (SKEY). Proportional Editing Tool is also available and it works the same way as in Edit Mode for meshes. Vertices in the UV Editor can be hidden or shown using the HKEY and ALT-H respectively, the same way as in Edit Mode.
There are several selection modes available in the UV Editor. Since a vertex is drawn in the Editor for each face it belongs to, sometimes is hard to tell if we are selecting the same vertex or not.
With Stick UVs to Mesh Vertex enabled, a RMB click will not only select one UV vertex, but also all the UV vertices that belong to the same mesh vertex. You can use this mode even if it is not activated in the menu, by keeping CTRL pressed when selecting a vertex.
Stick Local UVs to Mesh Vertex works in the same way, but only selects the UVs that are 'connected', meaning they are within a 5 pixel range of the first selected UV. You can also use this mode even if it is not set as default, by keeping SHIFT pressed when selecting a vertex.
These options are toggled on/off by respectively pressing CTRL-C and SHIFT-C.
With 'Active Face Select' enabled, a RMB click will select a face, and make it the active face. This can be toggled on/off by pressing CKEY.
For all three of these options a special icon is displayed in the bottom left of the UV Editor. Note that 'Active Face Select' and 'Stick UVs to Mesh Vertex' can also be combined.
'Unlink Selection' will, based on the current selection, only leave those UVs selected, of which the faces are fully selected. As the name implies, this is particularly useful to unlink faces and move them elsewhere. The hotkey is ALT-L.
'Select Linked UVs' works similarly to 'Select Linked' in the 3D View. It will select all UVs that are 'connected' to currently selected UVs. The difference with the 3D view is that in the UV Editor, UVs are connected 'implicitly'. Two UVs are considered selected if the distance between them is no more than 5 pixels. The hotkey is LKEY.
You can activate Face Selection Mode in the UV Editor by pressing CKEY or using the Active Face Select option in the UV Editor menu. A small icon will show up in the lower left side of the Editor indicating this mode.
Different parts of a UV map can be stitched if the border UV vertices correspond to the same mesh vertices by using the Stitch command (VKEY). The Stitch command works joining irregular outlines, just select the vertices at the border line using the Stick UVs to Mesh Vertex mode, or alternatively keeping CTRL pressed while selecting so their homologous vertices get selected too.
You can merge UVs that do not correspond to the same mesh vertex by using the Weld command (WKEY). You can use the Weld command to align in X or Y several vertices. After pressing WKEY press XKEY or YKEY to choose which axis you want to align to.
In the ImageWindow Toolbar (Figure 11-41) the first button keeps your UV polygons square while editing them, the second clips your UV polys to the size of the Image.
Press RKEY in the 3D window to get a menu that allows rotation of the UV Coordinates.
Sometimes it is necessary to move image files to a new location on your harddisk. Press NKEY in the ImageWindow to get a Replace Image name menu. You can fill in the old directory name, and the new one. Pressing OK changes the paths of all images used in Blender using the old directory. (Note: use as new directory the code "//" to indicate the directory where the Blender file is).
You can also use FaceSelect and VertexPaint (VKEY) simultaneously. Vertex painting then only works on the selected faces. This feature is especially useful to paint faces as if they don't share vertices. Note that the vertex colors are used to modulate the brightness or color of the applied image texture.
LSCM means Least Square Conformal Map. This is an advanced mathematical method to automatically create a UV-mapping while keeping texture stretch and deformations to a minimum. It works by preserving local angles. Just as any other existing UV unwrapping mode, it will unwrap the selected faces in UV Face Select Mode. It is available by either pressing UKEY, and then choosing LSCM, or by choosing LSCM Unwrap from the UV Calculation panel.
To be able to correctly unwrap a mesh with LSCM, you must make sure your mesh can be flattened without too many deformations (in mathematical term, it should be equivalent to a disc). This is done by defining seams, i.e. places where the mesh will be cut. You don't need to add seams if the mesh can be unwrapped directly in a plane.
In EditMode, selected edges can be marked or cleared as seams using CTRL-E.
Often a mesh cannot be unwrapped as only one group of faces, but must be cut up into multiple groups. If seams divide the selected faces into multiple face groups, then LSCM unwrapping will unwrap them separately, and position them in the UV Editor so the face groups don't overlap. To ease selection of face groups, Select Linked in UV Face Select Mode (press LKEY) will select all linked faces, if no seam divides them. This way, you can select a face group by selecting one face of the group, and executing Select Linked.
To further tweak the result, UVs in the UV Editor can be pinned to a fixed position. If LSCM is executed, these UVs will stay in place, and the resulting UV map will adapt to the pinned UVs. In the UV Editor, selected UVs will be pinned or unpinned by pressing PKEY or ALT-P. Pressing EKEY in the UV Editor will launch LSCM unwrapping on the faces visible in the UV Editor. Pinned UVs are marked in red.
Even without an Image assigned to faces, you can render textures utilizing the UV Coordinates. For this, use the green UV button in the MaterialButtons (F5) menu.
If you want to render the assigned Image texture as well, you will have to press the TexFace button in the MaterialButtons. Combine this with the VertexCol option to use vertex colors as well.