Blender 3D: Noob to Pro/UV Map Basics

From Wikibooks, open books for an open world
Jump to navigation Jump to search

UV mapping is a technique used to "wrap" a 2D image texture onto a 3D mesh. "U" and "V" are the names of the axes of a plane, since "X", "Y" and "Z" are used for the coordinates in the 3D space. For example: increasing your "V" on a sphere might move you along a longitude line (north or south), while increasing your "U" might move you along a line of latitude (east or west).

Another explanation can be gleaned from the Blender manual. Imagine a paper 3D model of an object, e.g. a sphere, that is to be laid flat on a table. Each of the 3D coordinates of the sphere can be mapped to the 2D coordinate on the flat piece of paper. Blender provides another view of the vertices (coordinates) in the UV/Image Editor. You can select and edit these 2D vertices just like in the 3D Editor window. The purpose of this unwrapping of the coordinates is just to map these coordinates to images/pictures so that the 3D image can have a realistic looking surface with textures derived from these images.

The Basics of UV Mapping[edit | edit source]

Add a sphere[edit | edit source]

We'll use a sphere for this demonstration. Delete the initial cube ( A  + X ). Then, create a new model, a sphere ( Shift + A  → Add → Mesh → UV Sphere). Leave the settings at default for now.

Mark a UV seam[edit | edit source]

In edit mode, select a ring of vertices around the widest part of the sphere (the equator, if you will). This can be done easily by holding down  Shift + Alt  and left-clicking on the 'equator'.

Press  Ctrl + E  and select Mark Seam, or select MeshEdgesMark Seam. This tells the UV unwrapper to cut the mesh along these edges.

Unwrap the mesh[edit | edit source]

Next, create a window for the UV mapping: click and drag left the small lined area in the top right corner of the 3D window, a new window will be created. Set its window type to "UV/Image Editor" with the drop down box at the bottom left corner of the new window or with  Shift + F10 .

In the 3D View window, select all your vertices by pressing  A , and press  U Unwrap. In the UV/Image editor you should see all the vertices/faces/edges of the model represented, or 'mapped', in 2D space.

If you don't see anything, you need to select UV Editing from the Screen Layout dropdown in the UV/Image editor window.

Apply an image[edit | edit source]

Now we're going to actually use this UV map. Save the following image (click to view in full high resolution (4,096 × 2,048 pixels)):

Load it in the UV/Image Editor window by clicking ImageOpen Image or by pressing  Alt+O . Then with the grab, rotate and scale tools, adjust the UV islands (the UV groups that aren't connected to each other) so that it fits nicely on top of the image as shown. To select a UV island, hover the mouse over the island and press a vertex and  L .

Note: Since the aspect ratio of the image will warp the UV's, it may be easier to simply re-unwrap the mesh exactly the same way you did before. You can then adjust the UV's as needed.

If you have issues fitting to the image use X and Y letters after pressing S. This will adjust the shape to fit the image.

[S]cale, [R]otate, [G]rab, [B]order selection, [A] Select/Deselect all

Admire your new creation[edit | edit source]

Back in the 3D View window, go into Object mode. The next drop-down menu to the right of the mode menu is the Viewport Shading (Draw Type) menu; use it to set the Viewport Shading to Texture. Note that parts of the model will be shadowed and other parts illuminated based on the location of the lights in your scene. Try adding more lights and moving them around so you see the model more clearly, and try to use this lighting preview to 'Rough' your lights. (you can add more lights Shift-A-Lamp and right click lamp to move to where light is needed)

To make the texture visible in renderings, you also need to add the texture to the sphere as a new material. In the Properties window, switch to the Material context by clicking the small shaded-sphere button. Create a new material by pressing the New button, leave the settings as they are for now; then switch to the Texture context. Create a new texture and select the type to be 'Image or Movie'. Select the globe texture from the dropdown menu.


























Then go to the mapping menu and set the Coordinates to 'UV' and the 'Map' to 'UVMap', leave the projection at 'Flat'. This will make use of the UV's we unwrapped earlier. To make the globe a bit smoother, switch to the Modifier context in the Properties window and add a subsurf modifier; set the number of subdivisions to 2. Then press  T , if you had no Tool-shelf, in the 3D viewport and select 'Smooth' under the shading options. This will make the globe far smoother and more realistic.

Now, simply press  F12  to render your scene!

Note that in the above render I've changed the lighting and the camera position to make the image more interesting. I also added a star background, you can find the settings for this in the World context (a pretty relevant coincidence) in the Properties window and the texture settings for the World.

Go to the World properties and check both Blend Sky and Real Sky, set all 3 colours (Horizon, Zenith, Ambient) to black. Go to Texture settings and if you weren't already there, click on the World texture settings (upper left globe icon) and set the type to Voronoi. Scroll down to Colors panel and check Ramp and give Color Stop 0 a white color and an alpha of 1 and Color Stop 1 a black color and alpha of 0. Now some will happen magic: set Distance Metric to Minkowski 1/2, in Noise section set size to .002 and set 2 of Feature Weights at around .5. Finally, in Influence panel, check Horizon, Zenith Up and Zenith Down. That will do the trick. In some older versions there was a standard option for this but it has "disappeared".





























































Alternative method[edit | edit source]

If you looked around the textured globe we just made, you would have noticed that around the 'equator' there were lines, or 'seams', where the two UV islands met. This is a common problem with UV mapping and there are a couple of ways to avoid it. In our case, since we're using a sphere, the best way to remove the seams is to use spherical mapping.

First download one of the textures from this link: http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_2002.php. Then use this texture for your globe instead of the one we first downloaded.

Go into edit mode, and select all the vertices of sphere. Press  U Sphere Projection. If you've got the UV/Image editor open you should see a very different UV map, as shown below. Note that only the 'Unwrap' option will use the seams we just made, all of the other options completely ignore it.

You can also try, especially handy when you use a more detailed map in the place of the seam: First unwrap with cube projection and then with sphere projection. It's now a square like UV.

Now lets make the UVs fit more evenly over the texture. In the UV/Image editor, press UVsConstrain to Image Bounds. This will make sure that during editing none of the UVs will go over the bounds of the texture; if they did, it would cause the texture to repeat itself in the area of the UVs outside the bounds.

Now select all the UVs with  A  and scale them up till it is stopped by the image bounds. In my case, there is one vertex in the top-right corner, and a few in the bottom-right corner that are quite distant from the rest of the UVs; to fix this, I simply selected those vertices and moved them closer to the rest of the UVs.

Now simply scale all the UVs by the X axis until the UVs stretch over all of the image. Doing this is exactly the same as scaling in the 3D viewport, press  S  and  X , then drag the mouse.

Now rerender your model, and you will see that there are no seams! You can also use an image with clouds. if you render this you will see seams. you can fake this away a bit by making the diffuse at material sea-blue by using the color picker after rendering the first render (If it looks good it is good).