UV-Mapping in ZModeler2


UV-mapping is the process of applying a texture image onto mesh object. This can be considered as "skining", "stratching texture over the mesh", but the most precise description is "mapping", since underlying process involves mapping of the mesh (or parts of the mesh) onto texture, but not visa versa.

Mapping is how you assigning an image texture to a portion of a mesh. Therefore, when we make a texture we MUST map it to the mesh, and do it correctly, so that it looks good. Most of the time, textures are not just untouched photos of whatever it is that you're modeling. Instead, they are distorted, retouched, airbrushed, groups of pictures in one image. The beauty of mapping is that you can assign different parts of an image to different parts of a mesh. For example, you can have side, front, and back views of a car, all in different sections of the same image, and then you can assign, or map, the various parts of the car onto the corresponding parts of that image. In fact, one of the virtues of a good texture is that it makes the most use of the space on the canvas, and fits as many parts of the car on one image as is possible, all at the highest possible resolution.

Internally, when UV-mapping you assign each 3D vertex to a certain location on texture. This location is it's U,V coordinates and they are stored within the mesh vertices. This pair of U,V is a uv channel and in some cases mesh can use (or have to use) more than one uv channel. But one channel is the most common case.

Since UV's are stored on a vertex-basis in the mesh and don't bind to texture they were mapped, texture replacement is widly used by games and appears as variouse "skins" for the same mesh.

Mapping areas on the mesh.

When mapping certain areas of the mesh onto texture there could (and will) be a case when neighbour ares on the mesh are mapped to completely different locations on texture. For example, the line where hood goes along the wings (left or right). In this case the hood is mapped to one area of texture and wings are mapped to another area. But understanding the internal concept (that uv is assigned to the vertices) you will clearly figure out that mesh splitting is required. Been more precise, you need to slice the areas-boundary edge, so each vertex on the boundary duplicated: one for hood and one for wing. To understand what is acutally happens in this case I recommend to apply detach tool to the hood, move it away, uv-map it, uv-map side wings and then move the hood to it's original position. When this areas-boundary issue will be clear to you, detach tool will still be used, but you will not require to detach mesh into stand-alone object and/or move it away.

What is required.

First of all, the mesh is required. It doesn't matter whether this is a single object or several objects (e.g. car body split to parts: hood, doors, roof, windows etc.) I've made this shape quickly just as an example.

Second, you require a texture you are going map to. As an example, I'll take an incomplete texture from Dodge Viper GTS. As you can see, it is loaded into textures browser which you can find in View/Textures Browser.

Finally, you need a material that uses this texture. There could be several materials with the same texture or several materials with variouse textures for single mesh, it doesn matter. In this tutorial, I've created a material and assigned vipergts.bmp texture to it. The have been done in several steps. First of all, I opened Materials Editor in View\Materials Editor. Then, using New Material button (the leftmost under material-preview sphere) created material. Then I renamed it in the list of the right to body skin material. Then, I expanded Textures rollup and clicked on wide ... button. The textures browser appeared where viper gts was selected by me and Ok button was clicked. As a result I see what is on the image: a textured material with required texture on it.

1. Assigning textured material to an object/polygons.

The first step you need to do before UV-Mapping is assign material to an object. If you use only one material/texture per object, you can make it only once before starting uv-mapping. If you use multiple materials in your mesh, assigning (or at least) verifying which material is already assigned to certain polygons) should be made each time before mapping certain areas of the mesh. I'll show you bothe examples here.

Assign material to the whole object is quite simple. As you have noticed, there is a Assign to Selection button in Materials Editor. By pressing this button in materials editor, you force it to assign currently shown material to the geometry you have currently selected. For example, you can select several objects, open materials editor, pick desired material and press this button. The same can be done if you have object switched to polygons level and have certain polygons selected. Material will be assigned to these polygons only.

I personally (for historycal reasons) use another way of assigning materials :). I assign them in attributes or Properties box. Simply switch to objects level, right-click on the object and pick Properties... in pop-up menu.

A Selection Properties dialog box will appear where you can expand Mesh\Polygons and change material propery to desired material. Also notice that I've expanded Mesh\Vertices\Format branch. Here you should ensure that at least one uv-channel is available in mesh vertices. On the image below it shows 2 available uv-channels. The same way you can select polygons and use Properties in context menu to assign material.

After assignin material in my case the whole car turned green: That's because there is no mapping assigned and all vertices uses upper-left texture pixel as a mapping. I always paint a small square (8x8 pixels) in upper-left corner of texture to any bright color, so I can see non-mapped areas of the mesh. The same I recommend to you. Also, if your texture has an alpha channel for transparency, the underlying alpha color should be white in this square, or you will get invisible (fully transparent) mesh after assigning textured material.

2. The first assignment.

I'll show you the basic mapping assignment here. We will uv-map the whole car using single "assignemnt" of mapping. By the world "assignment" I mean that UV-mapping will be generated for the whole car and these generated mapping will be edited as a single area of mapping. I'll map the whole car to car's top texture (which occupies upper area of texture).

Since mapping is vertex-based, I switch object to vertices level and select all vertices with Select\All tool (I used Shft-A hotkey for it). mesh got a dark red tint in the views. To force ZModeler work with selected vertices, SELECTED MODE have to be switched. Press according button in status bar so it turnes red. at the same moment vertices normals will appear on the mesh. Now you we are ready to the main UV-assignment step.

2. The Surface\Mapping\Edit UV tool.

This tool can be applied to selected vertices and allows to generate, restore or remove UV-mapping for vertices. Generate means that it creates new mapping and allows editing of it. Restore means that it uses current mapping and allows editing of it. Remove measn what is supposed to mean: it removices mapping by resetting all UV to 0,0 (initial state).

You can either pick this tool in commands bar, or use it from context menu. I will use it from context menu by right-clicking in Top view. An options box will appear for Edit UV tool. Here it is: All default options fit our needs in this case, but to make things more clear I'll explaing which options here your should pay attention to. They are:

  • Create/Edit UV means that you are generating/editing UV
  • New mapping creation mode: From Viewport XY means that mesh layout in current viewport will be used to generate mapping. I've clicked in top view when applying the tool and expect mapping to be generated the way the mesh lays in the top view.
  • Already mapped vertices behaviour: Keep Old Mapping means that vertices that were previously mapped will keep their mapping and new mapping will not be generated for them. I rarely use this option, and prefer Generate New instead of this one, but in our case (the first mapping of the mesh) it doesn't matter.

    You can click OK button to see a noticeable changes in 3D view. Deselect all vertices (Shift-D hotkey), switch to objects level and switch selected mode OFF by pushing the button. Of cause this generated mapping is not what we need and it requires editing. Edit UV has done it's job already and the next step is to open UVMapper.

    3. The UVMapper view.

    The UVMapper is a specific kind of view where you can edit UVMapping for the mesh. This viewport works with the mesh which was generated by Edit UV tool. This mesh is a Mapping-object and it is bind to original mesh mapping. When you edit this mapping object, an UV-mapping on original object changes.

    Change any viewport (right for example) to UVMapper (by clicking on a viewport label and selecting desired viewport in context menu):

    Guess what? There is nothing in UVMapper viewport. This is quite normal and you have to choose what you are going to modify in this viewport before anything will appear. First of all you need to select which material/texture mapping you are about to modify. Click on a Material button and select desired material in a pop-up list:

    From this moment texture should appear in UVMapper. In most of cases the mesh will appear too, but if it doesn't, click on an Objects button and place a checkmark near desired object(s). Then press Esc to hide the list:

    On the image below two viewports are shown: UVMapper and a Top view. Notice that mesh in UVMapper looks the same way it looks in Top view (where I've applied the Edit UV tool). You can pick a Modify\Move tool and move the mesh in UVMapper. At the same time you can look into 3D view to see what's changes when you move mapping-object. Don't be afraid to scale/rotate this mesh - it will no way distort your original mesh, only uv-mapping is affected.

    To achieve what's on the image above I've rotated the mesh, scaled it , then switched it to vertices level, selected half of vertices and mirrored them. Finally, I adjusted certain vertices positions, using Modify\Move tool in Selected mode and moving groups of vertices that I selected with Quadr tool. Using hotkeys for these tools will improve your mapping performace.

    You can change UVMapper back to original view when you've done mapping. Note that when you hide/close the last UVMapper viewport, a mapping-object is removed. If you wish to return to UVMapping again, you can use Edit UV tool to Restore mapping.

    "Split and uv-map" aproach. "Area" mapping.

    As it was stated before, you will need to map car parts to certain ares on texture. In my case I'll show how to map front of the car to front texture. First of all, you should remember the vertex-mapping concept: some vertices (those that near the hood and some other) are already mapped and this mapping should not be distorted, but other vertices in front part need new mapping to be generated.

    Switch to polygons level and select the polygons you want to map. I selected those that will be mapped to a front-view texture. I temporary switched texture off, to show which polygons are in a question:

    You need to separate these polygons from the rest of the mesh, so they use their own vertices and don't share these vertices (and their mapping). This can be done with a single apply of Modify\Submesh\Detach tool. Locate it in commands bar and expand it's options box: Set the options like one the image. They are:

  • To New Object: OFF. We don't need to detach to a new object.
  • Keep Original: OFF. This will not leave original polygons. Otherwise, you'll get a duplicate polygons.
  • Enable Drag: OFF. We don't need to drag/move detached polygons, they need to stay where they are.

    Make sure SELECTED MODE is ON and click once in the view. Nothing (visually) will happen, but these polygons are now separated from the rest of the body. Keep selected mode ON and switch from polygons to vertices level (by pressing '1' hotkey). You should see vertices selected and these vertices shows that the area you've detached is now separate from the result of object: Once vertices are separated, you can apply Edit UV tool in Front view to selected vertices, but make sure to select Generate New option in Edit UV options box:

    Then, exactly like you did with the whole body, the front area is mapped:


    As a conclusion, I'll quote here some mapping tips from Ryan's Ravisol tutorial.

    To a point, the mechanics of mapping a mesh can be taught. However, the art of clever, precise mapping is something that comes with time. Some practices can help you speed this learning process up.

  • Base to Pivot Using pivot helper, dragging it here and there and using it as a point of Scale\Rotate will allows you to scale any group of verts down to a specific area of the texture. So, you start by lining up the texture around the area you want to map it to, then you find a good reference point to scale it to, like one corner of the area, or perhaps the center, if you can find that. Then, using Scale, you can scale the object down into the area.
  • Map at High Zoom Another good technique to use is to zoom way in when mapping. This allows you to control down to the pixel where your verts are mapped. You must use high zoom in mapping to ensure accuracy. If you don't, you may wind up with little lines around the edges of your mapped areas where they overlap to the next area.
  • Understand Stretching/Compressing A big part of mapping is actually stretching or compressing the texture into the mesh. Because you probably distorted the shading contours of the texture when you made it, you need to counteract that effect in order to get good shading on the car. Basically put, when a small area of texture is mapped to a large area of the mesh, it's stretched, and when a large area of texture is mapped to a small area of mesh, it's compressed. Common sense tells us that compression looks better than stretching, and this is true. Stretched textures tend to look pixelated, and should be avoided. However, a combination of both techniques is essential. I think that one misconception that a lot of modelers have is that your mapping object has to look exactly like the actual object. This is not true, because changes made to the mapping object do not affect the shape of the real object. So, if you have to disproportionately scale your mapping object to fit your texture, don't be afraid to do so.
  • Tile Textures When working with track textures, tiling should be your friend. Instead of using 2048x2048 textures to represent grass in a track or scene, you can use one 256x256 texture and tile it. If a texture can be repeated as a pattern with little or no obvious lines or repetition, then it can be tiled. Tiling is easy in Z-Modeler. You just have to scale it larger and larger until you have tiled it as much as you like it. However, a word of caution. This only works when the texture is the only one in the image! You cannot use this technique with an image that contains more than one texture.
  • Mirror/Rotate You can use the Mirror and Rotate commands in Z-Modeler's mapping window to move the verts as well, so make good use of them. If you see that some text is mirrored, don't flip the texture, mirror the mapping object. However, a word of caution, make sure you line it back up well, and mind the modification axes you have active when you mirror. You don't want it to end up upside down as well. Rotation is another good way to move verts around. Often the orientation of the texture is different from the mesh. Therefore you have to rotate it to make it fit.
  • Avoid Messy Mapping Finally, avoid messy mapping. Try and keep the mapping objects lined up with each other whenever they are adjacent. Try to also avoid mapping a whole mass of polys to a certain area with no regard for their shape, because this can cause shading difficulties. It will also make it easier when you go to tweak the mapping later.