2d images on 3d objects

So we know a 3d model is a list of vertices floating in a 3d space. And you can probably guess that a texture is

Since they consist of mostly flats surfaces, Cuboids are amongst the easiest shapes to texture map, and allow for a variety of ways to do so. In fact most software packages have functions that will automatically attempt to apply box unfolding to a selected model.

In the image (animation) to the right we can see a box unfolding. Cuboids have no curved or rounded surfaces, so they are among the few objects that can be unfolded without any distortion in the uv map.

A 3d object being "unfolded" to become a 2d plane while retaining the shape of each individual face.

Terminology

There are a few common concepts to establish before the actual workflow of texturing a model can be discussed.

Textures & Materials

A texture is a single image containing color and possible opacity information.

"Textures" and "Materials" might seem to be interchangeable, but have come to denote two specific concepts. A texture is almost synonymous with the image file serving as its source. The word "texture" won't be made up of more than one image and will ony refer to the color and opacity information contained in the file.

A material combines texture channels into one surface that can be mapped onto a 3d model.

The word "material" will refer to either a single or group of textures that also have visual property settings beyond simple color and opacity. So a material *can* be as simple as a single texture without any additional information, but more often then not they will hold one texture for color, another for surface "bumps" and maybe another showing what parts of a model are dull or shiny. And each of these will have settings changing their influence on the final surface.

The individual channel types will be covered in the next chapter, but we needed to establish the difference now since most programs will not let you add a texture without it being part of a material.

Projective texture mapping

A Projection of a texture is the method by which a texture is mapped onto an object not based on camera and/or surface directions.

Projection mapping is the simplest way of getting a texture on to the surface of an object, but this simplicity comes at the cost of adaptability.

Their strength is that they can serve as "one-click" solutions to particular objects you want to apply a texture to. Examples of objects that projection mapping works with are simple boxes and sphere, flat objects like signs or flags, or objects that might always face the camera.

Their weakness shows when you need to texture an object where the texture doesn't easily match the shape of the object.

Below you have four projection types (from left to right); Plane, Cubic, Cylindrical, and Spherical. The top row has the projection type matched with the proper object type. As such that top row shows the least amount of distortion of the checkerboard map applied to each shape.

Every row going down from the top has the same projection applied to each object below it. Some projection styles produce more distortion on some primities than others.

Observe the following.

  • The plane (or "flat") project looks fine from a single orientation but stretches to infinite lengths along the sides of the objects it is projected on. It is not "wrapping" around the object. It is assigning color based on a single direction.
  • The Cube map looks fine from 6 particular sides but distorts at the meeting points of those 6 sides on curved objects like spheres and cylinders.
  • The cylindrical map tries to carry the mapping of the cap down the sides which results in varying degrees of stretching.
  • The spherical map results in curvature of the texture on flat surfaces such as the cylinder or cube.
  • These distortions are the very reason that it will be so rare to use regular projection mapping on any object that does not completely match the projection type.

Because of this you their primary value will be as "starting points" for developing more complex UV Maps. In fact, in the experience of the author, the "planar" map is the only projection that is regularly used, though it is important to realzie how each of them work. The vast majority of the time you're going to be editing your UV map by hand without a quick, one button, fix.

Let's look at what UV maps are and how they work.

UV Maps

A UV Map describes where individual vertices in a 3d space lay on a 2d surface.

To apply a texture to a more complex shape, where we want precise control over which polygons will use what area of a texture, we need to use UV mapping. Unlike projection mapping UV mapping is rarely automated, and will take more time, but with more effecient use of texture space.

Essentially the process will take an "unfolded" version of a model and lay it flat over a chosen texture. A good comparison is the way clothing is made. If you look at your clothes, your shirt and pants, you see seems. This is because your clothing was made by cutting pieces from a large flat cloth before being sewn together. UV mapping is basically the opposite. 3D models are given "seams" where the pieces are seperated at, and then unfolded over a large piece of "cloth", our texture.

Even though you'll hear phrases like "cutting apart" or "seperating at the seams", do not think that UV mapping involves editing the original model. None of the actual geometry needs to change during the UV mapping process.

The key rules of UV mapping...

  • The "U" and "V" in UV mapping don't stand for anything in particular, they refer to the X and Y coordinates that can fall over a square . We use U and V instead of X and Y to prevent confusion between the texture coordinates and world coordinates.
  • Changing the position of a vertex or edge in the 3d world space will not affect the UV coordinate. Likewise changing the UV coordinate of a vertex or edge will not change the position of it in the world space.
  • UV maps are stored in percenatges. So placing a polygon around the center of an iamge doesn't mean you're placing it at "X" and "Y" pixels, you're placing it at about "0.5" and "0.5" for the U and V directions . This also means that if you were using a texture image that was, for example, 512 pixels wide and across, then switching that for an image twice the dimension s will not change the UV map, the UV map will remain constant no matter the size of the assigned image.

Here are some examples of how modifying a UV map of two simple poylgons changes their appearance in the 3D space.

Here we see two single polygons. They have been laid out in the same UV space. Note how the edges of the polygon coorelate to the checkerboard pattern. One polygon matches up with the edges of the pattern while the other has edges that stop in the middle of the checkerboard squares.
Now the UV coordinates of the second polygon have been scaled up. The idea to make note of here is how the scaling up of the second polygon's UV coordinates HAS NOT changed the size of the mesh itself. But it has changed the scale of the teture on the mesh.
Note also that incerasing the UV scale did not make the checkerboard pattern on the second polygon larger but smaller. This is a very important concept. The more UV space a polygon takes up, the more image space will be fitted to the polygon surface.
Finally we also need to establish the concept of UV maps not necessarily sharing the same orientation as their 3d mesh. One of the polygons has now been rotated within UV space. Just as scaling it did not change the size of the original mesh, rotating it has not altered the original mesh either.
What it has done however is change the direction the squares are drawn on the mesh surface.
It's almost as if the 3d polygon is a "window" to the surface of the image.

Now image if we weren't dealing with just a single quad representing a single plane. What if we could divide that quad up into seperate pieces so that we could assign different parts of an image, as a texture, to that surface? That's exactly what we're going to do.

So now we need a term for groups of polygons that are joined together but are not actual distinct meshes. Some programs will use terms like poly groups or surface zones. Generally I find "islands" to be an acceptable phrase.

Islands

Islands are groups of polygons on a UV map completely disconnected from each other.

It's rare that the polygons of a complex model can be unfolded and remain in one continuous piece. Again, take a shirt for instance. Is it possible to lay a shirt down on the ground so that both the back and front face upwards without first cutting it down the side? It is not.

To lay a model out we cut seams, and when seams start to isolate parts of a model instead of cutting just one side, we end up with a set of polygons completely disconnected from others. These disconnected pieces are called islands.

Packing

Packing is the process of fitting together polygons on a UV map to use as much space as possilbe.

To give a model the highest possible texture detail you must always try to use as much of the UV map as possible. It's impossible for a UV map to ever cover 100% of a texture space (except perhaps in the case of a square sign or box side), but artists should also seek to keep wasted space to a minimum.

The tricky part is that we still want to maintain as little distortion as possible at the same time.

The only time you may not want textures packed closely together is if the rendering engine uses some kind of blurring (perhaps mip-mapping a game where the texture quality has been turned down). This might cause the color of one island to bleed into another. In that case you may want more than the usual few pixels between each island.

This idea is especially important in the video game industry for two main reasons.

  1. The number of textures a game can use is limited by the graphics card of the player. If your UV maps are only covering half of the texture, then you will need twice as many texture files on any given object. But if the map takes up the whole texture, then you've freed space for that second texture to be used on more assets for the game.
  2. More tightly packed UV maps means more of the texture making it onto the player's screeen, and so a higher definition for each surface within the game.

That is not to say that it is not also important in pre-rendered projects. Every new texture is a new call for a sampled pixel, and loaded textures are memory resources that must be combed over by the processor to find the required pixel color. It's just not as critical.

Texturing workflow

So what is the best way to go about taking the polygons of any given model and creating a UV map for them? Let's summarize.

  1. Finalize your model
  2. Create the islands of your UV map
    • Select edges/polygons of a model to define islands.
    • Separate and relax Smooth Jazz will help. polygons on the UV map.
  3. Apply a pattern texture to the model.
  4. Move apart and scale the islands according to create a heirarchy of detail.
  5. Assemble the islands within the UV space to fit together as well as possible.

Let's look at each step more in depth. Keep in mind there's really no way to divide this process into smaller sections that can be practiced individually. Texture mapping is just a complex subject that takes time to master. The steps below are written to be detailed, yet applicable to multiple software packages, so don't be afraid to look up specific tutorials to those individual programs.

1. Finalize your model

It is always wise to finalize the geometry of a model before texturing it. Any changes made to the model in the future will affect the UV map. Small tweaks of a point here and there will only cause minor distortion, but removing or adding geometry (beyond edge loops) will require you to redo that part of the UV map as well.

If you delete geometry you then have image space not being used by the UV map. If you add geometry after mapping thne you might not even have space in the UV map for the new polygons.

This will also involve deciding what parts of your model you may wish to make use of symmetry for. Most material types will allow you to overlap UV islands over one another if both of those islands need to make use of the same texture space (for instance the eyes of an animal model might share the image of just one eye on a texture map).

2. Apply a temporary texture pattern

Before sorting the islands we need to apply a continuous texture to help in deciding how much detail each part of the model should have.

It can be as simple applying a checkerboard pattern image to your model. It helps to always keep a personal texture on hand just for this occasion if your program of choice does not have an automatic checkerboard pattern it can apply on its own.

The reason you should use a checkerboard pattern while laying out the islands is so that you can see the concentration of detail, smaller squares in one area mean more detail, and allows you to decide what parts of the model will have more definition before the texture is even applied.

(In Autodesk 3d Studio Max you do not need to make a texture or material for this checkerboard pattern. In the UV Editor simply select "Checkerpattern" twice in the upper right of the UV editor and it will automatically apply a temporary one.)

3. Separate UV islands

This might very well be the most intensive and time consuming part of the process because it will require you to try to visualize what the final product will look like before you've even begun. Essentially this is the step where you will look for individual pieces of your surface to break into "islands" to be arranged in a later step.

It's also a step that will have you repeating the same sub steps many times over. A complex model, such as a human character, may have dozens, if not hundreds of islands of individual polygons sets comprising their final UV map.

All of the major 3d programs will have a set of tools to help in laying out your selected polygons on the UV map. They will not do a perfect job but they offer a starting point. There are two main functions to look for in every software package and one that you might ignore.

  1. "Shape Mapping (Flattening)"
    The most useful form of this function is typically reffered to as "planar mapping". This function will take the currently selected group of polygons, bind them together within the UV map, separate them from the unselected polygons within the UV map, and change the position of it on the map accordingly.
  2. "Relaxing"
    Relaxing is a function that attempts to flatten out the islands you've created and alleviate any distortion in the process.

    This function is immensely useful.
  3. "Auto arrange"
    An auto arrange, sometimes called "layout" or "pack", will attempt to arrange uv islands in a way that will have them take up as much space on the UV map as possible

    It sounds useful but the vast majority of the time you will ignore this function except as a way to easily seperate islands that might be overlapping each other.

Just remember, do not choose a place for a UV island on your UV map interface until you have ALL the islands laid out.

4. Sort the islands by detail

You can arrange the polygons like this because most programs allow you to place the islands outside the main UV area within their editor windows. Keep in mind that when you do this the textures will "wrap" so that any island placed around 150% from the origin will appear to be only about 50% from the origin. This repeating of the texture is normal, and in some cases useful.

The important part is that you move most, if not all, of the islands out of the uv bounds.

5. Pack the islands within the uv bounds

All that is left at this point is the arrange the islands back into the UV bounds. The challenge within this step is to move, scale, and rotate them so that they fit together as well as possible without overlapping.

  • While you can move and rotate the islands as much as needed, avoid scaling if possible, as it will undo the previous step where you chose the resolution density for each island.
  • You typically want a buffer or empty area between each island. When rendered the texture of a model may have blurring applied to it, depending on the renderer, which may cause some islands to "bleed" into others if they are touching. This effect is seen especially in mip-mapped textures.

For instance; follow the column of squares that start at the under belly of the pig, and lead straight up to the back. In the first version you can count about 8 full squares. In the hand optimized version you can count at least 10 full squares. That's an increase of at least 125% more detail in your texture map!

Remember, especially in real time rendering such as in video games, unused texture space is a wasted resource. Whether or not you actualyl show all of a texture map that entire texture file is still loaded into your GPU's memory! So don't take it for granted!

These are the basic steps of creating a UV Map.

A visual walkthrough

Here you can view the same steps discussed above in a visual format. The same general process of creating a "hand made" UV map can be applied to almost any 3d editing program.

As usual though, each program may have its own idiosyncrasies, and you may find it helpful to view a video tutorial concerning your chosen program.

Here we see what your model / UV map will probably look like when you're done with the modeling phase and have just added a UV Map modifier / opened the UV map tool. Everything's a mess, nothing is aligned or even identifiable, all because we've been adding, deleting, and moving points and polygons throughout the modeling process.

Here we've done two things. 1. We've turned on the option for a temporary checkerboard texture on the model (or added a custom texture if the program did not have one) and 2. Moved ALL of the initial UV polygons away from the map area.

In the third step we've manually selected all of the polygon faces that we want to be part of our first UV map island. There is no easy way to instruct someone which faces to choose as this will change from model to model. Here, since we're only doing half of a pig, we have chosen all the parts of the head that can be "comfortably unfolded". In other words the face without the inner mouth, nose, or ears.

Now in the above image you see the result you'll get in most programs when invoking the "planar tool" function. Some programs, like 3DS Max, will have "Quick Planar" tools / buttons that you can press once to complete the operation instantly. Notice how the polygons have automatically been broken away from the mess of the initial UV map and moved to the main UV area for us.

The second automated feature we can take advantage of is the Relax function. Some programs may also have a "Quick Peel" function that does something similar. It may appear to just make the UV island larger but what it is actually doing is trying to make it so that each polygon is about the same size shape in the UV map area as it is in the 3D space.

Move the newly finished island out of the main UV area and into any empty space around the work window.

Step 7 is just going to be a repeat of what was done before. Again we select areas that can lay flat (here we select the parts of the pig's torso that face outward but NOT the inside of the leg).

...and apply the "Planar Map" function.

Now here is an IMPORTANT part of the process that illustrates why we use the tools that we do. Look at the stomach of the pig (the blue arrow). Do you see how the checkerboard pattern is being greatly distorted on te two polygons that make up the underside of the stomach? That's the kind of distortion that texture artists always look to avoid. It's one of the qualities that completely destroys the impression of a model being an actual "object" an not just a mesh with a texture on top of it.

This happens because the proportions of the polygons in the UV map are very different from their counterparts in the 3D space.

In this step we have again applied the "Relax" command to our selected island. Here there is not much difference in the main shape of the island but the two polygons that make up the bottom of the stomach have changed very much (see the green arrow). Those two particular polygons are now much larger in the UV map, indicating that they were much too thin before, and are now closer to the size and shape of their 3D space counterparts.

This can also be achieved by manually adjusting the vertices in the UV map by hand but most of the time the problem should be remedied via the relax tool.

After we have separated all of our pieces, moving each new piece outside of the UV map area, the UV editor window should look something like this.

Many programs will have automatic "Packing" algorithms that can attempt to arrange the islands you've created into the UV map area all at once. As you can see above however, many of these algorithms are not great at the job, and will leave an undesirable amount of empty space around each island.

By packing the islands by hand you can almost always assure better use of the UV map space then many current technologies. There is no easy approach, it only involves, scaling, moving, scaling and moving again, and occasionally rotating pieces until they fit well. Here you can notice that the artist has rotated some pieces (an inner leg and the inner mouth) to fit between the legs of the main body island.

If you look at the previous step you can identify about 8 checker squares that wrap vertically around the mid section of the pig from the back to the stomach. In the newer version where the map has been arranged by hand there are around 10 squares. This is an increase of 125%. That's 125% more detail that can now be used on the model to make the image quality even better (and is 20% less texture memory wasted on pixels that will never be shown).

There are some programs that can do a decent job of packing your island automatically, but as of this writing many of them are used in particular situations, or are not cost effective for beginners. Even when they do become more ubiquitous it will be beneficial for students to attempt this process on their own so that they can understand, and remember, the importance of a well made texture map.