Você está na página 1de 23

Understanding UV Mapping: The Basics

By Spaik, 1 February 2006

Understanding UV Mapping: The Basics


Introduction This is a beginner tutorial that will explain you what is UV map and how to choose the best mapping for your 3D mesh. It is thought for object creation, but the same hints and considerations can be applied to clothes too. I will focus on why you have to do something, instead of do this to achieve this, since in this subject is extremely important to understand what you are doing, so that you will be able to apply the basic techniques to every mesh that you create, no matter how complex it is. The tutorial doesnt cover cloning an item in Simpe, creating the 3D mesh or making the texture with a graphic program. We will only focus on mapping. Disclaimer: English is not my mother tongue, so please be patient with me . Credits: A great thanks goes to Delphi, Numenor and all the guys of Mod The Sims 2 for the information and support given to everyone who begins creating custom content for The Sims 2. Index What you will need .....................................................................2 Getting ready..............................................................................2 What is UV Mapping? ................................................................2 First step ....................................................................................3 Box mapping ..............................................................................4 Planar mapping ..........................................................................8 Cylindrical mapping ....................................................................9 Spherical mapping ...................................................................11 Ready for the Classic version...................................................12 Mapping a (little) more complex object.....................................16 Conclusions..............................................................................22

Page - 1 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

What you will need:

Any program for UV mapping would be good, but for explanation purposes I will use UVMapper Classic and the demo version of UVMapper Professional (since they are free and everyone can get them); you can download both versions at http://www.uvmapper.com/ A program for 3D objects creation (if youve arrived here, I guess you already have it and are able to use it). I will use Wings 3D, which is free and you can get it at http://www.wings3d.com, but any other 3D program will do.

Getting ready Have you got the programs needed? All right, we shall begin. First of all double click on UVMapper Pro and follow the installation procedure. This is a full copy of the program, but with the saving features disabled: we will use it to understand what we are doing and then we will make the real mapping in UVMapper Classic. If you find it useful, you can register and use the full version. UVMapper Classic is a simple executable, it doesnt need installation; so put the file where its easy to find for you, maybe the desktop. Remember that theres only a simple undo function in the Classic version, so you will have to be careful when mapping your meshes, or youll have to start the mapping again, if you mess up something. What is UV Mapping UV mapping is a process of making a 2D map representing a 3D model. This map is associated with an image known as a texture. In contrast to "X", "Y" and "Z", which are the coordinates for the original 3D object in the modelling space, "U" and "V" are the coordinates of this transformed map of the surface. Then the image is back-transformed ("wrapped") onto the surface of the 3D object. (From Wikipedia, the free encyclopedia) In poor words, imagine that your 3D mesh is a colourless present for a friend and the texture is the colourful wrapping paper. The UV mapping is the process of wrapping the paper around the present. The UV coordinates hold the information on how to wrap the texture around the mesh, that is which part of the texture goes on every part of the 3D object. An important thing to keep in mind is that the texture image is the main thing that makes a big package in The Sims 2, thus using (and often wasting) a lot of resources. For example, a PNG image that is of 512x512 size is about 280 KB, while the same image of 256x256 size is only 90 KB.

Page - 2 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

What is UV Mapping Cont. So when you map your object you need to keep in mind that the map has to make the best usage of the space; here are some hints: 1. leave the least possible unused space in the texture image; 2. enlarge the parts of the image that need more details and lessen the others; 3. if your object has hidden faces, dont waste space in the texture for those: you can either make them very little or make them overlap some other parts of the object; 4. if a 256x256 image gives enough details to your object, dont use a 512x512 one. We will see later on how to make this in practical examples. Step 1. Before starting the practical part, you should make in your preferred 3D program four simple shapes: a cube, a cylinder, a sphere and a parallelepiped resembling the ones in Figure 01 below. The size and proportions dont matter. Save every shape in a different file, in .obj format, so that you can try yourself the different mapping options.

Page - 3 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Step 1. Cont. I will also use the two patterned textures in Figure 02, created to highlight how the texture is wrapped around the 3D object. If you dont want to make your own, you can use a ready one included in UVMapper Pro (Ill tell you later how to do it).

Page - 4 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Box Mapping Lets go! Open UVMapper Pro, and take a moment to pass with the mouse on the toolbar and to read the labels of the various tools, so that you will know what they are when youll need them. Click on File Open Model and in the window that pops up, browse for the obj file where you saved the cube, select it and click on Open. Now your window should be divided in two parts: the Texture panel, on the left, has a square blank sheet, while the Perspective panel, on the right, shows the 3D object. If the object is too big, scroll back a little or use the Zoom Tool: click on the Zoom Tool in the toolbar or hit z on the keyboard to select it and then drag with the mouse to and fro. Select the Rotate Tool (you can also hit r on the keyboard) and fiddle a little with the mouse to get a better view of the cube. Now your window should look like the one in Figure 03 (apart from the background colour). HINT: If you want your cube to have a better look (with sharp edges looking sharp), click on Tools Normals Smooth, leave everything as is and click OK. Since we cant save, we arent wasting time on fine-tuning this, but remember that every 3D program has smoothing functions to give sharp and rounded edges the proper look. Now click on Map menu and select Box (or click on the Box Mapping tool) and in the pop up window select only the Split front-back option. When you click OK, UVMapper creates the projection of the cube in the texture on the right panel (see Figure 04).

Page - 5 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Box Mapping Cont. I highlighted in figure 04 the parts of the texture that arent used in this mapping; well take care of that later on. Now lets put some colours on our cube, to see how it looks. If you have your own texture that you want to use, click on Texture Load and in the window that opens, select your image file: supported formats include JPG, BMP and PNG, so you shouldnt have problems in finding a suitable one. If you dont have a suitable image, click on Texture use the built-in color texture map. Checker Color; this way you will

In Figure 05, you can see how the texture is wrapped around the cube. If you rotate your cube, youll see that facet number 6 is opposite to number 5, facet number 3 is opposite to number 1 and facet number 4 is opposite to number 2.

In this picture you can also notice that the texture appears stretched on the cube; this happens because the facets of the cube are rectangles in the map, instead of squares. Well need to adjust them manually (and well do that once in UVMapper Classic). HINT: If you select the Gaps in Map option, which is present in all types of mapping, UVMapper will insert a blank border between the various sections of the map. This is really useful for two reasons:

Page - 6 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Box Mapping Cont. 1. Since different 3D programs handle UV coordinates slightly differently, you can fill up with your texture a few pixels outside the edges; in this way youll be sure that there wont be any unpleasant white line across your object. 2. When you have to drag or resize some parts of your map in UVMapper Classic, it will be easier to select them, without touching the unwanted sections. Lets make a different mapping of the cube, using this option. Click on Map menu and select Box; in the pop up window select only the Gaps in Map option (the window should look like that in Figure 06). If you dont tick Split front/back, opposite facets of the 3D model are mapped in the same section of the texture.

In this case the facets look squared in the texture and so the textures doesnt get stretched on the cube. As you can see, when you select a new type of mapping, the old one is discarded; in a more complex model, if you select a part of it (that might be a different group or a different material), the new mapping will be applied only to that part, thus allowing you to choose the most suitable mapping for every part of your object.

Page - 7 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Box Mapping Cont. Now that we got the basics, we shall move a little quicker through the other types of mapping. I strongly encourage you to fiddle a bit with the various options, so that you can get in touch with them. Planar mapping Click on Map menu and select Planar; in the pop up window select Dont split, leave the rest as is and click OK. As you can see in Figure 07, this is NOT the right mapping type for a cube (unless you can think of some creative use for it). The planar mapping maps correctly the facets facing the direction set in Alignment box (in our case the Z-axis), but it uses the upper edge of the texture to map the entire upper facet, the left edge of the texture for the left facet, and so on.

We should try this on a different model. So click on File Open model select the parallelepiped you previously made and click Open. Adjust the view of the 3D model as explained before.

Page - 8 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Planar mapping Cont. The texture keeps showing, but it doesnt appear yet on the model because we havent mapped it yet. If you want to clear the background texture, or load a different image, use the commands in the Texture menu. Now click on Map menu and select Planar; in the Split box of the window that opens, select By Orientation and leave everything else as is. It seems that Planar mapping works best on models that have two predominant dimensions, while the third one is almost inexistent: the best example I can think of are glasses, or maybe some modern slim table-tops and similar surfaces. As we have seen before, splitting the mapping lets you paint in different colours the two sides of the object, while choosing the Dont Split option makes both surfaces look the same.

Page - 9 -

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Cylindrical mapping To try this one, you need a suitable model. So open the cylinder that you have made in your 3D program. As usual, click on Map menu and select Cylindrical; in the pop-up window deselect everything, as showed in Figure 09, and click OK. Since the caps of the cylinder are mapped along the Y axis and thus consist of a single line, this mapping is perfect if you dont need to paint the caps (for example because they are hidden or submerged in another part of your object); it might be suitable also if youre planning to paint the caps in a solid colour.

Lets try different mapping options for the cylinder: in the Cylindrical Mapping Window, select Separate caps and Dont include gaps in map.

Page - 10

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Cylindrical mapping Cont. With these options, the mapping looks better and you can easily paint every part of the texture; the only thing that you need to adjust, if your texture doesnt tile seamlessly on the model, is the point where the seam will be.

Reopen the mapping window and in the Seam Rotation box put 90 or 180, while leaving all the other options unchanged. Click OK. You will notice that the texture looks exactly the same (remember this when well go to UVMapper Classic), while the 3D model changes aspect, as if it was rotated; and indeed it happened something similar, since we wrapped the texture around it starting from a different point. Whenever youll need to use a texture that its not seamless, remember to adjust that number to put the seam in the most hidden point of the cylinder.

Page - 11

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Spherical mapping This is the last type of UV mapping we consider, since the Polar Mapping function isnt available in UVMapper Classic. Click on File click on Map Open Model, select the file where you saved your sphere and click OK. Then Spherical and in the mapping window select only the option Gaps in map.

Page - 12

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Spherical mapping Cont. As you can see in Figure 11, the result is poor, because there is a strange vortex effect at the poles. To avoid this youll need to select Spread facets at poles: with this option ticked (which is the best in most cases) the sphere is correctly mapped.

The rotation box can be used, as in the cylinder, to put the seam in a different point of the sphere.

Now that were familiar with the various mapping possibilities, were ready to make our first mapping with UVMapper Classic. Close UVMapper Professional and go on.

Page - 13

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Ready for the Classic version Double click on UVMapper Classic. Youll see a small window like Figure 13. In this version you cannot see the 3D model, so youll have to use your imagination : the only available part of the previous window is the white square of the texture panel. Since the texture map is usually squared, enlarge the window so that the working area is as similar to a square as possible. I suggest you to use all the monitor height. Click on File Load Model and open the file with the cube with whom we worked earlier. Now click on Edit New UV Map Box. In the pop up window insert 512 as Map size, and select only Split front/back. Now you should recognize the sections of the map we saw before, when we mapped the cube. If you dont remember, go back to page 5 and take a look at the picture . As I told you earlier, this mapping doesnt make a good use of space and there are many portions of the texture that are useless. So we need to manually adjust this, by moving and/or regrouping the sections of the map. Select the lowest rectangle, by dragging the mouse from A to B, as showed in Figure 14a: notice that when you drag enough to select at least one vertex of your object, all the related facet gets selected.

Page - 14

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Ready for the Classic version Cont. Now if you point the mouse inside the selection area, it changes shape and lets you move the selected facet where you want. Put it in the free area in the upper-left corner. Since the mouse doesnt let you put the rectangle exactly where you want, you can use the arrow keys of the keyboard instead: nudge selection up; nudge selection down; nudge selection right; nudge selection left; shift + moves selection up; shift + moves selection down; shift + moves selection right; shift + moves selection left.

HINT: If you click on Help Hotkeys, youll see a pop up window that summarizes all the available Hotkeys. They will help you to take the best advantages from the program.

Now select the rightmost facet and move it as shown in Figure 15b. You can rearrange every part of your model at will; if some facets of your object need to have the same texture, you can simply place one upon the other, thus saving space in the texture. If you make something wrong, press ESC key to undo the latest thing you have done: the undo function doesnt work for all the actions (i.e.: if you have remapped some parts of your model, you cannot undo).

Page - 15

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Ready for the Classic version Cont. Now that the facets of the cube are placed conveniently, we need to resize them to make a better use of the texture area. To achieve this click on Edit Select All (be careful that in the Edit menu there is a Select by and a Select command; you need the second one), then click on the right-lower corner of the selection and drag toward the right lower corner of the window, as indicated in Figure 16a. Since were mapping a cube, the facets need to be squared; otherwise the texture will look stretched on the object. HINT: When you resize the various sections of your object, try always to keep the proportions between the height and width of the 3D model in the 2D texture, since UVMapper, in most cases, isnt doing it for you.

When were done with the mapping, we can save our work: To save the mapped object, click on File Save Model, in the Options windows click on OK e then select an existing file or enter the name of a new one where saving the model. To save the texture map, click on File Save Texture map, in the Options window select 512 pixels for both width and height and click OK, then choose a name for the texture and click Save.

Page - 16

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Ready for the Classic version Cont. Now you can go to your preferred graphic program, open the texture map (which is a simple BMP file) and create the texture for the cube: before doing anything else, youll need to convert it to RGB color 24 bit, since the map is a black/white image. Just to check what you have done, open again UVMapper Pro, load the cube (File Open Model) and then load your new texture (Texture Load). In this way you can check how the texture wraps around the cube and make any needed correction on the fly. Remember that its always better lo leave some gaps between the different sections of the mapping and paint a little outside the borders of each section, so that there wont be any white lines in the object, when in game. And the final result is in Figure 17 (Im sure you can do much better than this! )

HINT: The game can only render (and thus display) the triangulated faces of the objects. Its more convenient to do the triangulation after the mapping: in this way there are less lines running across the texture map and its easier to understand which part of the model youre working with.

Page - 17

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Mappting a (little) more complex object Now that we know the basics, we can try to map a slightly more complex object, something that could even go in game. For this purpose Ive made a bedside-table: dont worry, Im not going to submit it, at least until Ive done a deep make-up on it . You can make one similar to Figure 18 in your 3D program (its made from only 3 cubes and 4 cylinders put together), or try mapping your own original object. The explanations Im going to give from here on, are general hints and can apply to every kind of object. Rule 1: If you want to make a good and easy mapping, make a good object: for example think of how youre going to map every part of the model and keep those parts as separate groups, until you have mapped them. As you can see on Figure 18, Ive made a simple bedside table, in which the different parts are still divided in different groups. You can call them what you want, but give explicative names, so that you can recognize them, because once you go to UVMapper Classic, you cant see how the 3D model looks like.

Page - 18

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Mappting a (little) more complex object Cont. Lets go quickly through the first steps of mapping the bedside table. 1. Open UVMapper Classic and resize the window to make it look like a square. 2. Load the object youre going to map: click on File Load Model. 3. Make a first map of the whole object: click on Edit New UV Map Box; tick the options Split front/back and Gaps in map, then click OK. The result is shown in Figure 19 below. Rule 2: Think carefully of what the final aspect of your object should be, before even beginning the mapping. Here are some hints: Do you have some glass or metal parts? Then map them separately and keep them in a separate part of the texture map. They will probably need a different Material Definition; so youd better keep them as a different group in the final 3D model too. Are there any parts that need less details in texture? For example a solid colour? If so, resize them to use the least possible part of the texture. You wont notice any big difference. Are you going to allow other people to recolor your object? Then make the mapping as easy to recolor as possible. Maybe theyll want to insert an elaborate decoration on your plain shutter. Make the main surfaces big enough for this.

Page - 19

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Mappting a (little) more complex object Cont. If we left the model mapped like Figure 19, wed have a lot of difficulties in painting it, because the different parts overlap in many points. Now we need to free the window so that we can work better on the single parts of the model that we have to remap. 4. Select all the model: click on Edit Select All. 5. Resize it to make it a lot smaller: hit / key on the keypad twice (in this way you can maintain the proportions of the object, while doing the resizing manually doesnt grant it). 6. Put it on the upper left corner, where is out of the way: hit home key. If you want to recall the hot keys, click on Help Hot keys: theyre really useful, since there arent menu commands for all the available features. Go on and remap the first leg of the bedside table; since it is a cylinder, we need the cylindrical mapping: 7. Select the first leg and put it in the center of the window: click on Edit Select by Group, then drag the selection with the mouse in the center. 8. Remap the leg: click on Edit New UV Map Cylindrical; in the pop up window, select Gaps in map and Spread Facets at poles then click OK. 9. Enlarge it by hitting * on the keypad once (now the window should look like Figure 20) and move it on a free corner of the window.

Page - 20

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Mappting a (little) more complex object Cont. Repeat steps from 7 to 9 for the other legs of the bedside table: remap each one of them, resize and put them one over the other, trying to make them all the same size. HINT: In UVMapper Classic, to map separately the caps of a cylinder you have to choose the Cylindrical Cap mapping option. In this case we dont need them, since the top and bottom of the legs are never seen. Now we can remap the handles, one at a time, in the same way. Since they are small and they dont need detailed texture, we can use the Box mapping, without the Split front/back option. At last, we shall rearrange the main part of the bedside table (see Figure 21). We dont need to remap it; but considering that we will probably make a more complex pattern on the front face, we can leave it alone and regroup the other facets.

Rule 3: The texture map is similar to a jigsaw puzzle, where one part fits in the other. Remember to leave enough space between different sections to be able to easily select each part in your graphic program. You can see the final result of the mapping work in Figure 22 (Ive added some colours and labels to help recognize the different parts). Now you only need to save the mapped model and save the texture map.

Page - 21

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Mappting a (little) more complex object Cont. Rule 4: The size of the final texture is somewhat independent from the size of the mapping, as long as it is a square. You can use the following sizes: 64x64 (rather too little and useful only for very small objects), 128x128, 256x256, 512x512, 1024x1024 (try and avoid this one with all yours strength, since it results in a huge package file). If your object doesnt need very detailed textures, use a smaller texture size. HINT: If you need to make a recolor of your object with more details, you can enlarge the image just for that recolor and apply it to the same 3D mesh. On the contrary, if youre going to make a plain recolor, you can use a smaller image to make a lighter package. Just remember that the sizes need to be powers of 2 (128x128, 256x256, 512x512, 1024x1024). Back to your 3D program, you can regroup the parts of your model conveniently, save it and import it in Simpe. Then in your graphic program, you can paint the texture and give colours to your object. You can see an example of the final texture in Figure 23 and the resulting 3D model in Figure 24.

Page - 22

Understanding UV Mapping: The Basics


By Spaik, 1 February 2006

Conclusions

There are many different ways to map the same object, and youll need to develop your own style, trying different solutions. Besides, UVMapper (in both versions) deals only with square texture maps; there are some ways to get round this, but they are a bit more advanced and dont fit well here. And moreover, square UV maps can do in most cases. This is just a beginner tutorial, but if youve found it useful, and you want more, just let me know and Ill do my best to make a sequel .

Page - 23

Você também pode gostar