Monday, January 4, 2010

UV Image Editing

Join my Blender 3D forum, where you can network with other Blender friends and get your Blender 3D questions answered.



The purpose of this video is to show how to edit an image in the UV / Image Editor in Blender 2.49b. Editing an image with the UV / Image Editor is important when you're combining (the technical word is "compositing") images and objects into a final render, as well as for creating custom textures. The process involves mapping a 3D surface onto one or many 2D images, a process called UV unwrapping a mesh. The mapping is done on each face. It's possible for each mesh face to have its own image mapped to it. We'll start with the simplest case of UV unwrapping, unwrapping an image onto a plane, which has, of course, only one face. We'll work our way up from there.

1) Erase the default cube (right click on the cube, then press the Delete key, then Enter). Add a plane (Space - Add - Mesh - Plane). Scale it up 3 times (S - 3 - Enter). Split the window horizontally by right clicking on the 3D Window bottom border, choosing Split Area, and positioning the double arrows so that the window is split.

2) We're going to play with a picture of me, in front of one of the 26 palaces of the King of Morocco, in Rabat, Morocco, projected onto a plane. It's good to be the king. Select the plane. Tab into Edit Mode. Press the A key twice to make sure that all the vertices are selected. Press the U key to unwrap the plane. Choose the default Unwrap method. The result: after you unwrap the plane, in the UV / Image Editor you should see a square with 4 vertices - actually, it's a face.

3) The next step is to load my image. From the UV / Image Editor, select Image, then Open. Select the Image. You might need to use the Zoom In and Zoom Out keys (Num+ or Num-) to position the image so that it fills up the square. There's the picture. In the background are soldiers, in their typical position before the Morrocan Changing Of The Guard.

4) The next step is to get my picture to display, both on the plane in the 3D view, and in rendering the image. We want the camera to see the image projected on a flat plane. To do that, from the View menu, press Align View, then Align Active Camera to View, or press Ctrl - Alt - Num0. Press F12 to render. The plane renders right now with the default gray material.

5) To get my picture to render, we need to tell the renderer to use the texture face (TexFace), which is the image from the UV / Image Editor. To do that, go to the Shading buttons (F5), select the default material (Material). Then, turn on the TexFace button. Now Press F12 to render. A bit better, but the image is upside down. We'll fix this shortly.

6) To see my image on the plane, go to View Properties. Turn on the SolidTex button. If the image still doesn't display, make sure the 3D View is in Solid mode. Now you can see me, upside down, as in the render. How can we fix this? In one of two ways...either by rotating the image in the 3D view or rotating the image in the UV / Image Editor. We're not going to change the geometry in the 3D view. We'll fix it in the UV / Image Editor. To do that, with all the vertices selected, press the R key, then rotate it 180 degrees. You can hold the control key down when you're close to 180 (you can see the rotation at the bottom of the UV / Image editor). That way you get exactly 180 degrees.
Press Enter and the image is now correct, both in the 3D view and the UV / Image Editor.

7) The entire image doesn't have to be mapped to the plane. To show that, go to the UV / Image Editor, with all the vertices selected. Press the S key to scale. Reduce the square to a rectangle syhowing only part of the image. I'm scaling the square down to a rectangle which focuses more on me than on the palace. The square is now a tall rectangle. Press F12 to render. Gee, I gained some weight. Moroccan food can be fattening, I guess.

8) The reason for the weird result is that, although the plane starts out mapped to a square area on the image, when I scaled it down, it became wrapped to the rectangle. The rendering stretched my stomach out, to fill in the plane's square area. That is the problem with UV unwrapping. Each face is mapped in its own way to an area of the image. The way that you unwrap a mesh makes a big difference. I'm going to show you how it can get even more weird. Press Ctrl-Z to undo the edit. That's the fastest diet on record.

9) We can do much finer edits, simply by adding more faces to the plane. To do this, position the cursor inside the 3D view. Press the W key to bring up the Specials menu. Select Subdivide Multi. Make the number of cuts 5. Of course, it can be any number you want. This gives us a 6 x 6 grid, with 36 faces in total. Go into Face Select mode by clicking on the triangle icon. Press the A key to deselect everything. Select a face in the 3D view. In the UV / Image editor, you see both the loaded image, and the part of the image that is mapped to that particular face.

10) Let's see what those guards are really doing. Easy enough. Select the faces that map to the part of the image where the guards are. Press the S key to scale them up a bit. Press F12 to render. They have really neat uniforms, don't they?

11) We can also edit from the UV / Image Editor. Position the 3D cursor in the UV / Image Editor. Box Select the area mapped to my shoulder. Press the R key to rotate it a bit. Now I'm bending my body in a strange way. Press F12 to render.

12) To show you why the projection method makes a difference, I'm going to unwrap the plane based on the Sphere from View projection. The result is as if both me and the King's palace were put through a blender which, in a sense they were. Thank God for Ctrl-Z.

You should play with all the different projection methods in Blender. A cube projection of an image actually will work fine. You can unwrap it and then scale the UV squares to fit the image. You can unwrap as many times as you like. Each unwrap undoes the previous one. However, you can have multiple unwraps if you want. The way to do that is to create a new texture map. The default name is UVTex. Click New and unwrap - the default name is UVTex.001, which you can change - and you can experiment with different unwrappings.

I hope this gives you a start in using the UV / Image Editor. Be sure to hit the Youtube Subscribe button so you won't miss any of my tutorials. Happy Blendering.