Blender Basics: UVW unwrapping
Previously in this series of hands-on tutorials about the basics of using Blender we learnt about the application itself, basic keyboard and mouse control; building a model using commonly used tools and applying materials to objects.
To get fully working models that can be used in games and 3D media projects we now need to turn our attention to UVW maps so objects display on their surfaces the images associated with materials.
UVW unwrapping ^
Once the material, texture and image data is set up and sorted out the next step is to UVW 'map' the object so that texture image/s can be seen on the mesh.
So what is a UVW 'map'?
Essentially it's a set of co-ordinates or information needed by both Blender and other 3D rendering (game) engines that tell them how an image is supposed to appear over the surfaces of a mesh, whether our chair looks like it's made of wood, metal, stone, and so on, this is called a 'map', or 'mapping'.
The process of adding a (UVW) 'map' to a mesh is called or referred to as "unwrapping", and is usually straightforward to do, especially since Blender has some handy and useful tools to make 'solid' (as in, 'good') UVW maps.
We'll work through this below.
First a reminder of progress so far. This should be the base chair mesh with a Material assigned (with or without a Diffuse colour change from the default light grey). A Texture should be associated with the Material and a texture Image (bitmap) assigned to that - although this won't be visible at present.
Starting point of the next phase. The modeled chair has a material with a texture slot that has an image associated with it waiting to be shown on the model once a UVW map is in place
Changing Blender layout - splitting screens ^
To make this process a little easier to do, we're going to split the work zone into two sections; one for the mesh object, the other for the texture image and UVW map display. RMB click on the boarder between each zone (marked in 'red' below) and select "Split Area", a dividing line will appear that can be moved up or down indicating which screen is to be divided; go ahead and divide the upper work area of the layout so it approximates the image shown below.
Design note: the border can be moved once the divider has been placed by LMB click-dragging it left/right - the direction the border can be dragged is dependant on the orientation of the divider itself ; 'vertical' splits only allow left/right movement, where-as 'horizontal' splits will only allow up/down movement.
RMB click on any 'border' dividing line to open up the 'split/join' layout tool
Two views resulting from dividing the screen by splitting it.
Changing "Window Type" view ^
One of the new views now needs to be changed to a 'type' that will allow us to see the texture image and UVW map as we work. So in the bottom left corner of the right hand view, click the button that's currently got a 'grid' like icon displayed on it. In the list that pops up, select "UV/Image Editor". The screen will change to that shown below.
Click the "Window Type" button in the corner of any toolbar header to change it to another 'type' of view - "UV/Image Editor", "Action Editor", "Audio Window" etc.
Showing the "UV/Image Editor" alongside the 3D view, where the texture and UVW maps will display, after changing "Window Type"
Adding a UVW map to the chair ^
Now that the layout has been set up we can turn to adding the UVW map to the chair. To do this enter EDIT mode (TAB) and select all faces using the "A" keyboard shortcut we used previously when making the chair (it doesn't matter at this point if other faces are already selected as we need to select them all).
Once done, press the "U" key to open the "UV Calculation" pop-up. From the list that appears, select "Unwrap", you should see a pink shaded square appear in the UV/Image Editor view on the right (as shown below); that's the UVW map created, more work is needed but that will come later. Next we need to assign the texture to the UVW map so we need to move across to the UV/Image editor view.
Edit mode, select all and then "U" to create a UVW map of the chair
UVW map applied to the chair mesh
Assigning a texture to a UVW map ^
To add the texture image to the UVW map, in the UV/Image editor window click the double-headed arrow to the left of "IM:[name]" (where "name" is either no entry or the name of the image added to the texture slot of the material) and select from the pop-up list the image you added to the texture slot of the material - in the example below that's called "generic4.tga". This has now assigned the image to the UVW map covering the mesh.
Adding the image to the UVW map in the UV/Image editor window
However, the texture image can't be seen yet because we're in the wrong "Draw Type" mode, we're in "Solid" instead of "Textured" view. To switch modes click the "Viewport Shading" button as shown in the image below, or press "Alt+Z" to toggle between "Solid" and "Textured" modes (be careful not to press "Ctrl+Z" as that's the Undo shortcut).
Switching to "Textured" view so the images is displayed on the mesh
As soon as the mode changes the 3D view will automatically update to reflect the new draw mode, displaying the wood texture image associated with the UVW map applied to the chair, as shown below.
Zooming in on the chair object (MMB scroll), the image can be seen displayed on the mesh using the initial UVW map made for it.
"UV" or "Orco" Map Input ^
If on switching to Textured mode the chair doesn't look right or looks more distorted than expected that may be because the object is using the wrong "Map Input" mode - what this does is instruct Blender to display textures using different types of co-ordinates relative to the object itself, so if this is left on the wrong setting the image may appear wonky despite being applied to the mesh correctly (as will be done further down the tutorial).
To change "Map Input" mode, press "F6" to open the "Texture Buttons" and find the "Map Input" panel (as shown below), then click on the button titled "UV"; you may or may not notice a change on the mesh itself but you should see a change occur to the material preview window panel to the far left side of the Texture Buttons window, this indicates that we're using the correct 'map' type.Once done, we can then move on.
Blender defaults to "Orco" Map Input mode when working, this needs to be changed when making content that uses UVW maps
Switching 'Map Input' mode to "UV" so any textures applied to meshes appear 'mapped' to the object correctly.
Editing the UVW map and using "Edge Seams" ^
Although technically the initial UVW map could be used 'as-is', it really needs to be re-worked so the texture sits over the surface of the mesh more naturally and correctly - right now each face of the mesh has been mapped to fit the entire texture on it which is no good for what we need - we need to break the UVW map into more manageable sections by using "Edge Seams".
We need to change "Select Mode" again so press Ctrl+TAB to open the pop-up menu and this time select "Edges"; you may not notice any change to the appearance of the mesh this time, however, if you RMB click to select somewhere on the mesh, it'll select an 'edge' instead of a 'face' (Ctrl+TAB back to 'face mode' to see the difference).
Ctrl+TAB to switch to 'Edge' Select Mode
What needs to be done now is to select a series of edges in such a way that they create 'isolated islands' representing different areas of the mesh; in other words the mesh will be 'marked' so the chairs corrected UVW map consists of four legs, a seat, and a back area. Aside from doing this basic structure we'll also find out how we can use Edge Seams to help create a much better UVW map layout relative to the texture. Before going further, and to make this process easier, change the "Viewport Shading" to "Wire frame" by either press the "Z" key, or by pressing the Viewport Shading button as shown below;
Press "Z" of use the "Viewport Shading" button to select "Wire frame" mode so selecting edges is easier to do
To make this easier to do change to Hold Shift+RMB and go around the legs so you have selections similar to the following;
Selecting a collection of edges to create an isolated area in the UVW of the chair
Design note: Blender 'remembers' your selection when doing work like this, allowing you to release the Shift key and use MMB click-hold to rotate the scene around to better select other edges/faces. Remember to press-hold the Shift key again before continuing selections else you'll loose previously selected items.
Next those selected edges need to be 'marked' so Blender knows that a 'split' in the UVW map needs to placed there. This can be done by using "Mesh >> Edges >> Mark Seam" from the menu or by using the shortcut key combination of "Ctrl+E" - although they both open up slightly different menus the actual function they carry out is the same.
Selecting a collection of edges to create an isolated area in the UVW of the chair
Marking edges using "Ctrl+E" shortcut pop-up menu options
After the edges are marked they should appear as series of thicker orange-yellow coloured lines.
Basic unwrapping principles ^
At this point, go ahead and select all ("A") and press "U" to unwrap again, watch what happens; you should see something similar to the image below appear in the UV/Image editor. The unwrap process has changed to suit the way the map has been spilt, but as can be seen it's still not really making that much sense as a UV' d object. This needs to be changed using the following principle of 'cutting' the mesh so the UVW maps layout becomes cleaner, flatter and more logical relative to the object.
Rebuilding the UVW map after creating edge splits in the mesh, not idea, so further editing is needed to correct the distortions
The principle involved here is the same as if you were to cut a cardboard box down one side, laying the resulting top, bottom and sides flat on the ground so all the parts of it were spread out. A mesh is treated much the same way where-ever possible, edges are placed around a mesh to facilitate a similar end result. For example, lets look at one leg and show this principle in use.
In the images below the highlighted numbers 1-6 represent different edges marked as a split, their colours correspond, so a blue line marked on the mesh in the 3D view is the same colour - and edge - in the UV editor on the right. So;
1) Orange - is the initial seam to isolate the leg.
2) Red - is a seam marked down the inside back of the leg, out of view from the user.
3-5) Green, yellow and blue - seams around the base to 'flatten' the underside of the leg.
6) White - edge left UN-marked so the base of the leg stays attached to the main leg element.
The image above shows the layout of edges marked as splits and the resulting UVW map layout once unwrap is carried out again on the edited mesh
'Clean' version of the above so it's possible to see the actual marked edges
If this principle is applied to the other legs we get the following;
Seams placed on the other legs of the chair
The resulting UVW map unwrapped after seams placement
Again, each leg is isolated and the main seam is placed down the inside back of each leg to hide any visible joints resulting from texture placement. UVW unwrapping in this way, of breaking the map itself into sections (or "islands" as they are properly called), pays off in the end because the texture is more likely to be uniformly mapped to the object with minimal amounts of the stretching, warping or generally poor texture application.
UVW unwrapping the back of the chair ^
Now that we've learnt an essential principle of UVW unwrapping, we can carry on editing the rest of the model using the same process of breaking the UVW map into islands. As the legs have been marked with seams we can "hide" those by selecting them and pressing the "H" key.
Design note: use Ctrl+TAB to toggle into 'face select' mode to make selecting faces easier to do, remember to use Shift+RMB to individually select faces or, use "B" and border select (press it twice to use the 'brush' select tool). Toggle back to edge select once done.
Coloured lines representing different edges marked as seams for the UVW map
A clean version of the above image showing the edges marked as seams
Note the pale blue lines in the above image, they indicate a possible alternative seam marker. What this means is that using those we could have the back of the chair appear to be attached to the top of the seat as opposed to what we have now, it being connected to the back of the seat.
Edges marked as seams and unwrapped on the back of the chair showing corresponding colours on the mesh and the UVW map
Clean version of the above showing the edges and UVW map of the chairs back
UVW mapping the seat section of the chair ^
As with the legs, we can temporarily hide the chair back using "H" to hide it. Once done go around the lower outer edge and marked seams as indicated in the images below. Again the position of these seam markers is so that when the seat is unwrapped the join lines won't be as obvious to the viewer.
UVW unwrapping the seat of the chair and marking seams
Clean version of the above showing the seams marked on the seat
It's worth pointing out here that the green line (shown above) that cuts across the front edge of the mesh doesn't necessarily need to be placed, but, because we need to create a separate island for the underside of the chair we can use it - the underside of the chair is an area that's rarely seen, as a result it can use a smaller area of texture, to do that it needs to be a separate UVW island.
Showing corresponding edges marked in the UVW map of the seat area
Clean version of the above image showing the UVW mapped seat area and seam placement when given a default 'unwrap'
UVW unwrapping an entire mesh ^
Now that each part of the chair mesh is unwrapped so the texture displays on it correctly, it's time to lay out each island segment - legs, back and seat - so that together they're a 'best fit' within the space available on the texture itself - in effect the entire map has to fit within the bounds of the image, keeping unused and empty areas to a minimum.
Un hide all the hidden elements with "Alt+H" or "menu: Mesh >> Show/Hide Vertices >> Show Hidden", you should see something similar to the image below where all the elements are laid out higgle-de-piggle-de;
Using "Alt+H" to un hide the previously hidden parts of the mesh so the entire chair can be re-mapped to the texture
This can be fixed out by selecting all ("A") and then pressing the "U" key to re-map the entire chair. The result will be similar to the image below;
Re-mapping the chairs UVW map results in a much neater and optimised layout
"Angle Based" and "Conformal" Unwrap Methods ^
Now for an object that's quite 'angular' like the example chair happens to be, we can do something else that should provide a slightly cleaner UVW map and that's to change the "Unwrap Method" used to calculate the layout - Blender provides two;
The image in the previous section above is the result of using "Angle Based" unwrapping, the image below on the other hand, is the result of "Conformal" unwrapping and tends to result in much cleaner and more 'linear' unwraps on 'regular' objects, where edges and vertices are aligned to the gird as much as possible.
Using "Conformal" to lay out the UVW map
To use this feature press "F9" to show the EDIT buttons window and click on the "UV Calculation" panel to reveal the "Unwrap Method" drop down, click the double headed arrow and select "Conformal". Press "U" to rebuild the UVW using the new calculation selection.
Switching 'Unwrap Method' from "Angle Based" to "Conformal" to re-calculate a cleaner UVW map for the entire chair
Texture space and UVW layout ^
In the images above you may have noticed that Blender doesn't simply make the UVW map elements as big as it can within the space it's got. Instead, the process tends to keep the size of all the objects relative to each other - the size and proportion of the chair legs for example, relate to their actual size when compared to other parts of the mesh - with the overall size of everything dictated by, and relative to, the largest section of the UVW map, in this case the back of the chair which has been unwrapped to occupy the entire left hand side of the maps space.
This principle is often referenced in relation to something commonly called "texture density" or "pixel density", whereby the 'detail' of a texture (how good it looks close up) is directly linked to the size of the UVW map - the 'larger' the map, the more space it uses with the result that textures appear 'smaller' because it then has to 'tile' across the now larger area. In the images below, a grid has been added to the wood texture to make this principle clearer. Right now the UVW map sits within the bounds of the textures space (within the borders of the texture). If this is then altered, we can see what difference it makes.
Design note: to change the texture, simply save over the top of the old one, Blender should then automatically update itself showing the new image.
Adding a grid to the image to make the "texture density" clearer. This is the chair as seen using the default unwrap and that maps level of density
Make sure the mouse cursor is over the UV/Image Editor window, then select all vertices of the UVW map by pressing "A" (may need to be done twice to make sure all verts' are selected), use "Ctrl+S" to resize the map whilst remaining snapped to the grid. Make the map twice the original size (watch the numeric counter bottom left of the UV/Image editor window, LMB click when it reads "2.000") and watch what happens to the texture as this is done, it appears to 'shrink' relative to the new UVW map size. Doing this has 'increased' the "texture density".
Increasing the texture density by changing the UVW map size
The reason for this being mentioned here is because the UVW map does need some editing and this principle forms a 'warning', of sorts, on issues that arise from changing the size of UVW maps elements without paying attention to what you're doing. So as mentioned above, although UVW maps should use up as much space as possible, that has to be countered by keeping all sizes relative to each other and so too, texture density; alter the UVW map and you also alter relative texture sizes, meaning you may have a chair leg looking more detailed than the chair back, which is a much larger object.
Resize the UVW map back to its original state with Ctrl+S , or press "E" to re-map the object again (make sure the mouse cursor is over the UV/Image editor window when using that key to unwrap). Use "A" to deselect everything. We're going to edit the UVW map slightly to allow some 'bleed' around each element, this gives a little leeway with regards to preventing "pixel bleeding" - where the resolution and physical size of the image causes areas to 'bleed' or 'leach' into other areas.
So, making sure the mouse cursor is over the UV/Image editor window, press "B" to "Border Select" (use either the 'area' or 'brush' selection tool) the vertices of everything except the back of the chair - which is down the left side of the image - and then use "G" to "Grab/Move" the selected elements to the right.
Press "B" to bring up the "Border Select" tool, press it once to use the "Area Select" tool, although the paint brush can be used as well, to select vertices of the UVW map in the UV editor - this is how sections of UVW maps are selected
Remember that you can MMB scroll to zoom in/out, MMB hold in the editor to move the view up/down, left/right. You can also "RMB" to select individual vertices, "Shift+RMB" multi-selects - make sure to hold "Shift" when doing this to add the new selections to a previous group.
Some parts of the map will need to be rotated to they face along the 'grain' of the texture so press "R" to do this, use "Ctrl+R" to rotate whilst snapped to the grid (will rotate selections in fixed increments) - this needs to be done because we're using 'wood' with which to texture the mesh so the direction the UVW map elements face is important; another consideration when unwrapping an object. Once this is done, you should end up with something similar to the image below.
Almost there, just a few more tweaks and the UVW map is done
Depending on what type of texture you're applying to the mesh, parts of it may also need flipping upside down or left to right. To do this select a section of the UVW map and press the "M" key or "menu: UV's >> Mirror" to open up the "Mirror" pop-up, select "X Axis" to flip left to right, or "Y Axis" to flip top to bottom - this may need to be done in both directions depending on the texture being used. Re-adjust the layout of other parts of the map where needed after doing this as you may find overlaps occur where they weren't originally.
Press "M" to flip the texture and mirror the selected UVW maps in the UV Editor
You should finally end up with something similar to the image shown below, the final UVW map of a chair.
The completed UVW map of the chair model