UV coordinates in Blender
This page is intended for a crash course in UV coordinates in Blender.
Links to good tutorials are welcome, as are tips from veterans, but the plan is to make a solid run-through for an absolute beginner, so if you're dealing with advanced topics likely to confuse a beginner please either leave them at the end, or perhaps consider a different page.
Tested on Blender 2.65
Release notes on stitching, among other things: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.62/UV_Tools
A basic video tutorial, good hints on seams: http://cgcookie.com/blender/2011/01/21/intro_uvmapping/
Another which isn't particularly directly applicable to spacecraft, but gives you a sense of what we're aiming for: http://www.youtube.com/watch?v=1nwEcWGkWOM&t=3m30s
Potsmoke's Texture & UV Tutorial: https://spacesimcentral.com/community/pioneer-mods/potsmokes-texture-uv-tutorial/ (outdated)
Some more comprehensive guides:
Essential Blender: well written, but on the old UI: http://wiki.blender.org/index.php/Doc:2.4/Books/Essential_Blender/10.1.UV_Unwrapping_and_Painting:_Hands_on http://wiki.blender.org/index.php/Doc:2.4/Books/Essential_Blender/10.2.UV_Unwrapping_and_Painting:_Tools
Making a simple character in Blender: http://www.katsbits.com/tutorials/blender/character-4-uvw-maps-unwrapping.php
What is UV unwrapping?
Basically we're mapping a 2D texture onto a 3D mesh. Think of a world map's projection (like unpeeling an orange), or unfolding a cube to make a 2D surface.
Every XYZ point on the surface of our mesh must be mapped to a UV point on our texture. Fortunately we don't have to do it point by point - the vertices in XYZ space have corresponding vertices in UV space, and Blender / Pioneer interpolate the surface in between for us.
Even easier, Blender has methods for 'unwrapping' a mesh or part of a mesh, by projecting groups of faces onto the map algorithmically. By repeated selective unwrappings, the computer does most of the work, and we just fine tune it afterwards.
The main things you are trying to balance when unwrapping:
- Maximise use of texture space: You want to make your texture files as small as possible to avoid straining the game engine. Pack polygons into the map as tightly as you can, using space efficiently. A single part of the texture can be mapped to multiple polygons, and any faces internal to the model (which should be avoided where possible to prevent z-buffer issues) can be shrunk to a point.
- Optimise detail: Parts of the mesh probably need more detail than others. The parts that should be highly detailed need more texture space, so should be made larger when unwrapped.
- Control distortion: You can distort polygons on the UV map for effect, or just to pack them in tighter, but assume to begin with that you want to minimise distortion. If your polygon is a square on the mesh, it should be square on the UV map.
- Alignment / orientation: Where texture detail crosses contiguous faces, it makes it much easier to line it up correctly if the faces are contiguous on the UV map too. For textures with 'grain' you may need to rotate parts of the map for it to look right.
Set up Blender
- Select 'UV Editing' screen layout using the widget in the top left which probably says 'Default'
The screen is divided in two, the 3D view on the right, the UV map on the left.
- Select 'New' in the widget below the UV map. Choose your texture's size, see Textures for notes. For 'Generated type' it can be helpful to select 'UV Grid' - this creates a 'fake' texture for you, so you can see how it maps to the mesh in the 3D window. Hit OK.
- Switch the 3D view's 'Viewport Shading' mode to 'Texture'. Your mesh will turn white, because we haven't mapped anything to it yet...
First we're going to unwrap everything and place it off to the side of the texture, so we can see which faces we are yet to unwrap properly.
- Select your mesh in the 3D view. Tab to edit mode. Ctrl-tab to face select mode. Hit 'a' key until all faces are selected.
- Hit 'u' key and choose 'Unwrap'. All faces will be mapped to the UV space - if you're on 'Texture' viewport shading mode in the 3D view you'll see your mesh covered in the grid texture.
- Hit 'a' key in the UV view on the left which selects all the polygons. Hit 'g' and move all the polygons to one side, so they're a decent way away from the grid. This gives us our pool of 'not done yet' faces (n.b. the mesh will still display the grid texture on it in the 3D view because the texture actually repeats itself. Don't worry about that - we're just clearing the faces out of the way in the UV view)
Now we selectively unwrap and pack sections of the model. Choose a group of faces that are logically connected. Either they are going to look identical (perhaps windows, or engine outlet surfaces), or you're going to want them joined to each other in the UV map because they share edges, and will have a precisely aligned texture running over these common edges.
- Select all the faces you want to unwrap together in the 3D view (shift right click works, as do 'b' for box, 'c' for circle or ctrl-left mouse for freehand select) - it might help to turn 'Clipped with depth buffer' on. Hit 'u', then choose an unwrapping method - you'll have to experiment to work out which one works best for the geometry you're dealing with.
- Move the polygons around in the UV map with 'g', 's' and 'r' until they're roughly where you want them. Switch to face or vertex mode to pack them together as tightly as possible, superimposing them if you want them to share texture. If you have multiple vertices you want at the same spot, select them, hit 'w' twice to weld them together, then shift-s and select snap to pixel.
Make sure 'Keep UV and edit mode mesh selection in sync' is on, then box select the 'not done yet' faces we moved aside earlier in the UV view, to highlight all the parts you still have to do in the 3D view. Keep picking groups of logically connected faces, unwrapping and packing them until you've done the important parts of your mesh.
You may have a few 'loose' faces left over, which don't really belong to any of the groups, or don't need a texture at all because they'll never be visible. Unwrap them and squeeze them in wherever you can, or shrink them to a point in vertex mode with 'w'.
Using seams and pins
Seams and pins can simplify the process. Seams give Blender hints as to where the unwrapping algorithm should create separate islands, or where to allow contiguous faces on an island to split apart on the UV map, relaxing distortion. If you visualise cutting your model up with a pair of scissors, and perhaps having to put a couple of extra slits in it to stop it stretching or 'bunching up', you'll probably get a sense of where the seams should be.
Select a series of edges (alt-right click for 'Loop select' can be helpful here), then hit Ctrl-'e' and choose 'Mark seam' from the menu. 'Clear seam' to remove.
Select a vertex and hit 'p' to pin it in place, to prevent it being unwrapped again. Alt-'p' to unpin.
Seams and pins are only respected by 'Unwrap' it appears, and pin only seems to work erratically for me.
To stitch two islands together, select a vertex and hit 'v'. Other instances of the same vertex (i.e. different 2D aspects of the same 3D vertex) will be highlighted in green. Shift right click to deselect any you don't want to include, and hit return.
If you want several instances of the same object, use alt-'d' to create linked duplicates. They'll share their faces, so you only need to unwrap one.
For meshes which you don't want linked, select the mesh you want to apply UVs to in object mode, then chain select the identical source mesh and choose 'Join as UVs' in the Ctrl-'l' menu.
There is also a copy / paste UV script linked at the bottom of the page, though I haven't had much luck with it.
- If you've thoroughly stuffed it up and want to start again, switch to 'Default' screen layout, select your mesh, and switch the panel on the right to 'Object Data'. Hit the minus sign next to UVMap to delete the map entirely
- If you select one vertex and shared vertices from other faces are being selected too, look for 'Sticky selection mode' on the bottom toolbar - only available with 'sync' off
- If you want to get the finished parts out of the way in the 3D view, select them (easiest to box select on the UV map with sync on), then hit 'h' to make them invisible (alt-h brings them back)
- If you've got lots of polys that you need to place on top of each other, rather than lining them up one by one with snap, it can be easier to turn 'sync' on, select them all, hit 'u' in the 3D window then choose 'Reset'. They'll all default back to covering the whole texture
- Use Ctrl-'l' to select other parts linked to the currently selected vertex
Exporting the UV map and importing the texture
Export to Gimp
In the 'UVs' menu in the bottom left, choose 'Export UV layout'. Load the file in Gimp and draw your texture, using the UV map as a stencil.
Import to Blender
Switch back to Blender's 'Default' screen layout, select your mesh. Switch to Material on the right hand panel and hit 'Add' (the mesh needs a material for things like lighting characteristics in order to render a texture).
Switch the panel to Texture, hit 'New', set Type to 'Image or Movie' and open your file under Image. Under Mapping, set Coordinates to 'UV'.
Switch back to 'UV Editing' screen layout. Select your mesh, tab to edit mode, and 'a' for select all. In the file selector widget below the UV map, you can now select your texture.
Import to Pioneer
See Model system for guidance on making a .model file.