CS22 W19

Loeb

Create a poly cube. By default, all primitives are assigned a UV Texture Layout. You can see that by selecting the cube and looking in the UV Editor.

Assign a New Material (aiSurfaceShader) to the cube, Click in the checker to the right of the color attribute and Assign a Checker.

Hit the 6 key, to see the texture.

Hit 6 In the UV Editor, and you will see this:

Note that all the UV's are laid out in the upper right quadrant. This is called the 0 to 1 space and is the most important quadrant for doing simple UV Editing. When you get more advanced, you can use more of the space, but for this course, we'll stick with the upper right quadrant. What is happening is shown below.

The texture is mapped to the UV coordinates in the editor and applied back to the 3D model.

It is hard to see the UV map over the bold texture of the checkerboard. The 6 key is a toggle, so you can click the image view on or off by hitting the 6 key.

You can also see the UV's in blue to show any overlapping or reversed UV's or click one over to see UV's that are distorted (stretched shows as red and compressed shows as blue).

Because this lays out so well, all is ok, but for more complex shapes, these two options are a huge visual aid!

Create a spehere. Select it. See how it unwraps in the UV Editor.

Assign the same checkered lambert to the sphere. That the checkers are not square all across the sides of the sphere.

If you look at the sphere, you will see that the faces get compacted along the poles on the model. In the UV Editor, the UV's are laid out perfectly evenly. The even mapping onto a compressed space creates this distortion.

Try a cylinder.

Notice how the caps are laid out separately.

You can apply a checker texture right from the UV Editor.

In the UV Editor, Right click and choose UV Shell. Select one of the caps.

Hit the r key to bring up the scale tool.

If you scale the checkers get smaller and visa versa.

You can also move the UV Shell to another part of the UV Editor using the Move Tool.

The goal is to find a way to lay out the UV's onto the texture so that the texture is the same size (to avoid stretching in some parts) and to make them line up nicely to avoid having a texture seam at a spot that is too obvious in the shot.

As with sewing, there is always a seam, you just want to hide the seam on a shirt by having it under the arm and along the sides, and you want to match any patterns as much as you can and be sure the patterns are all facing in the same direction (if you had a flamingo pattern, you don't want the flamingos upside down in the back, for example).

Below are some more exercises to help you understand UV mapping. They are based on an older version of Maya, but would be good for you to go through to better understand how the UV's relate to the object, but you will find that the tools are not exactly located where they used to be.

Make a torus. Apply the same texture. You will notice that the checker pattern has lost its square-ness. If you had a flower texture, the flowers would be stretched out in the same way the cube squares are stretched.

In the UV editor, Right click and choose UV. Bring up the scale tool and scale in --U (the equivalent of --Y)

The checkers aren't perfect, but they start to square up a bit. If you are too close to the edge of the quadrant, scale the entire thing down a bit and then, if the map goes too close to the edge of the quadrant, scale the entire thing down a tiny bit to fit.

Another good way to scale UV's up or down to fill the 0 to 1 space is to select the object and, in the UV Editor Menu, go to Polygons>Normalize>Options Box and select Preserve Aspect Ratio. This keeps the scaling ratios the same but adjusts the overall size to fit the quadrant.

You could also move all the UV's in the UV Editor, to place the texture differently onto the object

Or rotate the UV's

These icons move the U's 45 degrees in either direction.

And these icons flip the UV's over to a mirror in U or V.

You can also make your UV's fit nicely into the 0 to 1 quadrant by going into the UV Editor Menu and going to Polygons>Layout>Options Box

This arranges your UV shells neatly into the 0 to 1 quadrant. This can be handy when you have a more complex UV layout.

Texture mapping complex shapes is basically the same thing, but you use projections to make the layouts as correct as possible from the beginning.

If you look in the UV Menu (in Modeling Module), Under Create, you will see several options---Automatic, Best Plane, Camera Based, Cylindrical, Planar, Spherical and a new projection type called Contour Stretch.

As a general rule of thumb, you want to use the projection Let's start with a planar projection type that best fits the shape of your object. In most cases, you will break your object in to parts with a similar shape in order to get the best projection method. Most objects require multiple projections.

Many find the Automatic projection mapping to be a happy and easy way to go, but let's start with the basics, first.

Planar Mapping.

Create a cube. Assign the checkerboard lambert texture to it. The checkerboard looks perfect.

But as soon as you get the scale tool and stretch the object, the textures get wonky.

If you are looking at your UV Texture editor, you will see that while the shape has changed, the UV layout has not. They don't sync. That is why the texture is being improperly applied to this simple object.

In this case, you could select the UV's shown:

And then simply scale the UV's to get back the square checkers.

But if you don't have UV"s set yet, or if the shape is even more complex, or there are different textures on each side, you'd want to use a planar mapping.

In the UV Editor, go to Polygons>Delete UV's to erase the current UV mapping.

In UV>Planar>Options

You can project from a variety of axis or from the camera view.

Choose Keep Image with width/height ratio in order to keep the scaling ratio correct.

For the first mapping, let's project from the Z axis to get that front face. Hit Apply.

This is a standard projection manipulator. The blue cubes in the corner change the scale uniformly. The red ones scale out, the green are up and down.

you hit the red T you get a master manipulator that allows you to scale, move and rotate the projection.

Click the blue circle to bring up the other rotate tools. You can flip the direction of the projection, scale and move the center of the projection.

Scale until you get the UV layout looking correct as shown above.

You'll also notice that two sides look good the faces on the top and bottom are incorrect.

You don't just do projection mapping on a whole object, you generally do it on select faces.

Choose the top and bottom faces on the object. Go to UV>Planar>Option Box

This time project from the Y axis. Now four sides look good. You just have to do the ends. Select them. Create a Planar Mapping from the X axis.

If you look in the Channel box, in the polyPlanar Proj1 node, you'll see that the Projections Height and Width should be the same (or close to it). And the Scale of the Object itself, if your mapping is correct, will match. In my case they are all 4.257

polyPlanarProj2 should have the same Projections Width because you didn't adjust it.

If you look at polyPlanarProj3, the Projection Width and Height is 1. If you look at the UV Editor, you can see why this is. The edge faces are filling the entire quadrant!

Scale the projection width and height to the same values as the others.

The edges are now to scale with the sides of the cube and the checker pattern is correctly scaled.

Right click in the quadrant of the UV editor and select Shell. Then hit w to bring in the move tool and move each UV shell to see all six.

This allows you to see all the projection maps you made.

An even better way to see if your texture mapping is correct is to use one of the numbered textures for that purpose. I put two textures you can use in the UV Texture Editing Folder on Canvas.

The advantage to these textures is that you can tell if the textures are flipped or not.

Some sides are good, but the others are flipped, with backwards numbers because when we did the projections they went straight through instead of being mirrored.

This is easy to fix. Select one face with backwards numbers. It also selects the associated UV map. Select the Flip Selected UV's in U direction icon.

You will see that the numbers are now correct. Flip the UV's on any face that is incorrect, ending with all the numbers face up in Y and flipped correctly.

You will remember in the generic cube UV layout, all the edges were connected nicely so they would wrap around the cube with continuity around all the edges.

That isn't happening on our new cube shape.

You will notice in your cube and UV Editor, that everything is actually connected. What I mean is, if you select an edge in the UV Editor and then go to Select>Convert to UV's

You will see that there are actually four UV's for that one edge. You'll also see that there are two vertices selected on the polygon object. Those four UV's map to those two verts.

And if you select a single vertex on the cube, you will see three corresponding UV's in the UV Editor

You will also see that if you select an edge in the UV editor you are actually selecting two edges. You can merge the edges back together again.

UV Texture mapping basically involves taking your shape apart and then putting it back together again. See why it can be tedious?

There are tools to help. The main tools in the UV Toolbox are:

Pinch UV Tool

Cut UV Tool - separates UV's

The Grab UV Tool

Sew UV Tool, to sew edges together

Pin UV Tool, to keep a UV locked in place

Smear UV Tool, to smudge the UV's in the direction of your mouse stroke

But the best way to work is with the keyboard shortcuts (hotkeys). If you select an edge on your object, it selects two edges in the UV editor. Shift Right Click in the UV Editor and Choose Move and Sew.

This moves the UV shells together and combines the edges. Select another edge along the cube, do the same.

Keep going until all the long faces of the cube are connected. Then choose one edge along two caps and do the same.

Now if you right click in the UV Editor and choose Shell (or go to the Menu and Choose Select>Select Shell, get the move tool, and you will see that as you move the UV shell around, you are moving the location of the textures on the object, but they are all connected together and wrapping around the corners as they should be.

Select the shell and go to Polygons>Normalize. Your UV's fit nicely into the quadrant (you may want to Go back to UV mode, marquee select the UV map, and scale it down just a hair to get the edges off the axis.

You can move the map to make the corners of the cube align better to the corners of the pattern.

Now, whatever texture map you apply to this object (a normal map, a reflection map, transparency, or bump), it will line up correctly with the object, without distortion.

Be sure to delete the history. Save. And then Freeze the Transformations.

This is the basic pipeline for doing all UV texture mapping. Next, we'll look at how to do more complex shapes. It is just the same, you'll just use multiple projection types.

First, let's look at Automatic Projection. Open the Option Box.

Automatic Projection mapping creates several planar maps around your object, guessing at the correct orientation for each. You can select the number of planar projections, and optimize for less distortion or fewer pieces to stitch together,

You use 6 projections almost every time. In fact, all the defaluts are pretty good. Hit Apply.

You have a manipulator that allows you to move all the axis at once to line up with the object correctly.

You will also see that the scale is the same as what we had done before.

Then use the Move and Sew Tool to stitch it all together. Be sure to use MOVE and SEW so they keep their proportions.

The flip the UV's using the 45 degree flip tool and set the Normalize to make sure it is fitting correctly, and scale a tiny bit.

Here is a tutorial with tips for UV layout:

http://www.paulhpaulino.com/6-tips-to-improve-your-uv-mapping-workflow/