CS22 F19 Loeb
Cool new tools in MAYA 2018 and a good workflow for UV Texture Editing
You guys are lucky. Maya 2018 has made it much easier to work with UV's and UV Editing. There are some cool 3d tools that help you map between the object and the UV Editor. Let's play around with it.
(This tutorial is based on a tutorial from Game Dev Academy plus other sources)
The Basic UV Process:
In the UV Texture mapping process, you are basically creating a bridge and relationship between modeling and texture painting. In other words, you are taking a 3D shape, flattening it to a 2D UV map, placing this map on the texture and then applying that texture onto the 3D surface.
be compared to the pattern layout in preparation for sewing: You create a pattern that is placed onto fabric and then sewn together to create a garment. The fabric, in our example, is the texture. The pattern is the UV map.
In 3D modeling, we break the model into parts that can be easily flattened (like an arm), lay out the arm onto the texture and then sew the texture together. Just like when you sew clothes, there is a seam that gets hidden on the model.
The goal of the UV Texture mapping process in computer modeling is to create detailed, beautiful, natural looking textures with a minimum of distortion and as few seams as possible. It is an optimization problem: Less distortion vs. more seams.
What are UV Textures?
UV's are a coordinate system that exists only on the surface of a 3D object. It is a 2D system to map /define a 3D shape. It allows you to basically, flatten a 3D object so you can assign a 2D texture to it.
It is similar to the Mercator projection of the 3D earth to a 2D map. The area around the equator is at the same scale while the areas at the poles look larger in the projection to account for the 3D shape.
Most models are more complex than the simple primitive and require a more complex mapping. We do that using projections onto the model surface. This can be a painstaking process but it allows for precise and detailed texturing without distortion.
Let's make a toy block.
In your Practice Project, Save the Scene as ToyBlock
- Download the UV Mapping Folder from Files to Download for Class.
- Open the folder.
- You will find two scene files and a Folder of UV Mapping Textures.
- Put the Scene files in your scenes folder for your practice project.
- Drag all the textures into your Source Images Folder in your current project (Practice)
NOTE: This is where it becomes critical that you are working in the correct project, that the project is not on your desktop, but rather in the proper folder (Users/imac/Documents/maya/projects/ and have your textures in the Source Images folder for THAT project.
If that is not the case for you, set that up NOW.
- Now, in the Hypershade Textures tab, LMB drag the textures to the tab
- MMB drag the T_Blocks_D.tga file to the Color on the M_Block
If you don't see your texture, hit the 6 key.
The texture doesn't map correctly from the flat, square texture file onto the cube.
Setting up your UI
You can quickly get a good layout for UV Editing by changing the workspace in the dropdown as shown below:
Your UI changes to include the persp view, the UV Editor and some UV Tools. You can change the window sizes by dragging,
and as with any view panel in Maya, you can navigate around the space using ALT + the right or middle mouse buttons. You cannot tumble in the UV Editor.
Let's get to it
Create a cube (CTRL + shift + u)
In the Hypershade Window, create a new Lambert. Lamberts are flat shaders, they have no specular highlights. The default shader in Maya is a Lambert.
NOTE: Never change Lambert 1. You must create a new Lambert to work on it.
- Rename the Lambert to M_Block
- Select the cube in the Viewport
- Right click on the M_Block (new lambert material) and choose Assign Material to Viewport Selection
Select the cube and you will see the block texture in the UV Editor and a white outline of the block, laid out flat, like an upside down T
To see the cube shape a bit easier, click on the blue shaded icon on the upper left of the UV Editor
If any UV's were overlapping the shading would be darker, but because this is a simple primitive, it unwraps to the 2D shape quite nicely.
It is just that the UV's for the cube and the texture are not lining up as we'd like. Let's fix it.
Right click on the UV's of the cube in the UV Editor and Choose UV Shell.
using the Move Tool, move the UV's of the cube on the texture so that the red letters are down the long part of the UV map as shown.
You will notice that the cube now has red letters around it with one yellow M and a green M--exactly what you would expect from the way the UV map of the cube lays on the texture in the UV Editor.
But a block has multiple colors around it. Right now, if you move the shell, the texture stays with it but it isn't doing what we want.
In order to map the texture as you want, you need to separate out the sides of the cube's UV's and place them on the texture where you want the letters to show up.
Let's do a simple automatic projection to fix this.
- In object mode, select the cube
- In the UV Toolkit
- Open the Create Tab
- And SHIFT + click on Automatic to open the Options Box for Automatic Mapping
- Since there are six sides to a cube, the default setting of 6 projections is perfect. The automatic mapping uses the shape of the object to determine how it will divide up an object.
- Hit Project
- YOu sill see six blue rectangles in the viewport and six in the UV Editor
The square UV's aren't in the right places and aren't the right size to make the blocks look right. To fix it.
- In UV Shell Mode (right click on the UV's in the UV Editor)
- Marquee select all the UV squares
- Use the Move tool (w) to move the UV squares so that one of them is lined up with one of the block faces
- Use the scale tool (r)
- And LMB drag on the yellow square to scale uniformly until you get the square uv shell to line up with the texture you are trying to match.
- Be precise (zoom in in the viewport as needed)
Because you had all the UV shells selected when you scaled, they should all be the same size now.
If they aren't the same size, you can fix that using tools in teh UV Toolkit
I scaled up one of my UV squares to show you what would happen if they weren't the same size, but you wanted them to be.
- Select a UV shell that is the correct size.
- In the UV Toolkit, go to Transform and open the tab
- Scroll down to Texel Density
- With the properly scaled UV shell selected, click GET
- Then select all the UV shells
- Hit Set
- All the UV's are scaled so that the textures should show at the proper size.
Now that they are all scaled the same, you can select each UV shell individually and move it them to different letters as shown.
Because of the way UV Mapping works with a cube, though, one of the letters will be upside down.
In my case, it is the "P"
Find the UV shell that is on the upside down letter and we can rotate it. There are, of course a few ways to rotate the shell, but the easiest, is to
Go to the UV Toolkit and under Transform>Tools Choose the rotate icon and click it until your letter is right side up as shown
You can also use the rotate tool on the UV Shell, but it is very difficult to get the shell exactly right. You can use the rotate tool but hold down the "j" key to snap the rotation in 15 degree increments
Once you've laid out the UV's on an object, you can duplicate the object and the UV mapping goes with it.
It is now easy to change the squares so they aren't identical.
To fix this
- Select the new cube
- In the UV Editor, go to UV Shell mode
- Select all the UV squares
- Use the move tool to move the all the squares down (you could also move them up or over)
- You will notice that even though you went beyond the image of the texture, the texture repeats and your cube looks as it should.
UV Map a Table
Let's start with a scene file you can find on the Files to Download for Class folder on the google drive. This is a table built by someone named Shane Whit. I got it online for this demo.
The table is made up of a bunch of rectangles.
The UV Editor looks just like it did for the last exercise, but in fact, there are a bunch of cube UV's laying on top of each other
- Click on the checkerboard pattern in the UV Editor menu
- This puts a checker pattern onto the object to help see how an actual texture would map.
- You see that the checkerboard is meant to be squares of black and white.
- Notice that the checkerboard on the actual table object has rectangles and how distorted the UV's look around the sides and legs!
We need to fix that!
The letters on the texture are there to help make sure the UV's are lined up so the textures are facing in the right direction.
Create an aiStandardSurface material
- turn up the base color to 1.0
- turn down the specular to 0
- rename it M_Wood
- Drag and drop the T_wood_D texture (T is for texture and D is for diffuse since we are adding the diffuse color, the color that shows when light bounces off it)
Assign this material to the entire table
Even when you hit 6 you don't really see the wood grain. You need to turn off the checkerboard to see it clearly.
Notice that the wood texture looks really bad, as you would expect after seeing the checkerboard.
Let's fix it!
- In face mode, select the top and bottom face of the table top. Notice that the two corresponding UV squares are selected in the UV Editor
Because the table is flat, a planar projection makes sense.
- In the UV Toolkit,
- Go to Create tab
- Shift click on Planar to open the Options Box
- The projection wants to happen from the Y axis, so choose that.
- Make sure the Keep Image width/height ratio is checked ON to alleviate distorion
- Hit Project
Now you have some big rectangles in the UV Editor. Select the UV Shells for the rectangles and move them out of the 01 Quadrant
- Now select the faces of the table top that face the positive and negative x axis as shown
- Shift select the Planar option from the Create Menu
- Choose x-axis this time (all other settings are the same)
- Hit Project
Now you have some long narrow rectangles in the UV Editor.
- Move those out of the way, too
There are just two squares left in the UV Editor. These are the faces of the positive and negative z sides of the table top.
- Select the UV's in the UV Editor (you could also select them on the object, but this is simpler now that they the only UV's left)
- Planar map from the z axis
- The square UV's are now long and thin like the faces on the object.
- Move those UV's out of the 0-1 space, too.
To see how the mapping is looking, turn off the texture view and turn on the checkerboard again as shown
Notice how much better the mapping looks! Nice squares.
It still isn't quite right.
If you click on teh blue shaded squares at the top of the UV Editor, you will see that the shells are purple, this is because there are two shells stacked on top of each other (one for the top face and one for the face underneath the table top) Move them apart from each other and notice that they are different colors (red and blue)
Do the same for the other faces so you have six rectangles in your UV Editor
Blue means that the normals are facing in the correct direction. Select all the red shells and go to transform >flip on the U axis (horizontally)
Now they are all facing as they shoudl be but the size is not right yet Notice that the face that is on the short side of the tabletop is too long.
You can fix it with the Texel Density method from before, or you can use Layout. Try it.
- With all the UV Shells selected
- Go to the Arrange and Layout Tab
- Find Layout and SHIFT click on it to bring up the options box
- Choose Legacy mnode
- And Prescale WORLD
- Hit Layout UV's
Notice that all the uv's are back in the 0-1 quadrant and they are now scaled to each other properly.
If your texture looks ok, you can stop here, but chances are the wood grain is too big or running the wrong way, and is not sitting correctly just yet on the edges of the table top.
Let's fix it.
To fix the way the side edges meet the top, so it looks like real wood and not a cheap laminate you have to stitch it together
When stitching the uv's together, it is just like sewing a garment. There are always seams and you want to make sure they are in hard to see place, such as where the bottom face of the tabletop meets the edges, as opposed to where the top face of the table top meets the edges, if you follow.
OK. Let's do it.
- Select the top face on the object to find the top face uv's
- You can adjust how dark the texture shows up in the UV editor by moving the slider on the top right.
- Go into edge mode
- You see that when you mouse over an edge, it turns red and the corresponding edge on the object and on the other UV's are also red.
This makes it easy to know when edges we are going to stitch together.
- Select a long edge on the top face UV
- The corresponding edge is also selected
- In the UV Toolkit, open the Cut and Sew tab
- Click on Stitch Together
- The face moves over and is connected to the other face.
Keep going all around the top face UV.
Looks at the table in the viewport and you will notice that the sides of the table now connect nicely with the top of the table! Nice.
We still, however, have more seems than needed.
Now stitch the bottom of the table to rest. You may do better to move the top face shell over a bit as shown and then select the edge and stitch
It is all one shell now!
Now the texture wraps around the eges as they should. Well done!
The wood grain should face the long way on the table. Select the UV Shell and go to Transform>Rotate
Finishing the table UV Mapping
We are actually almost there.
Let's start by UV Mapping the base of the table top, the four rectangles that hold the table top up.
- Select longSide1 from the outliner
- Select the face that is outward and the one that is inward. (Much easier to map two directions at once)
- In this case, we can see, when we activate the move tool, that the projection we want is from the x axis.
- In Create, Shift select Planar
- In the options box, be sure x-axis is selected and keep image width...
Move those UV shells out of the way
To get the top and bottom of this rectangle, you will notice they would be hard to select, so you can use the UV Editor as shown.
- Project from y this time
- Move those out of the way.
Finally, you have the ends of each side rectangle. These are hidden away but let's do them since this is a practice and it is good for learning. This time, we project from z
Now repeat what you did on the top faces.
- In UV Shell mode, separate the overlapping shells
- Click the blue shaded icon to see which are facing correctly
- Flip all the red shells so they are all blue.
Now we need to scale them to each other.
- Select all the shells
- Go to Layout
- Make sure the settings are as they were before (Legacy/World
Now you stitch them together as before. I like to separate out the UV shells to make the edges easier to find. Stitch the edges that will show the most.
Make sure the UV's are running the direction you want them to (rotate the uv's as needed), and move this shell out of the way.
- Turn off blue shaded mode
Copying the UV's from one side to the other
Rather than going through this again on the other long side, you can simply copy the UV's from one object to another. This will come in quite handy.
- In Object Mode
- Select the longSide1 object
- Shift Select longSide2
NOTE: It is important to first select the object you are copying from and then the object(s) you are copying to.
- Go to Mesh>Transfer Attributes>Options Box
- Be sure UV Sets is set to All
- Hit Transfer or Apply
- Note: Hitting Apply keeps the options box open, which makes it handy for transfering these UV maps to the short sides.
- Go ahead and apply the UV's from the long side to one of the short sides.
You will notice that the rectangles on the short side are not quite square. We can fix that by scaling the UV Shell until the checker pattern looks like squares.
Now transfer the UV sets from one shortSide to the other as you did above.
Keep going for the legs.
- Select the front and back of a face and choose the proper planar projection
- Repeat for the other four sides as you did before.
- Flip UV's so they are all blue
- Lay them out
- Stitch them together
- Make sure the UV's are in the grain direction you desire (running up and down the table leg)
Move the UV Shell out of the way
Transfer the UV's from one leg to each of the others as before.
The only thing left to do is to put all the UV Shells into the 0-1 coordinate space.
- Shift select all the UV Shells
- Shift Click Layout and make sure Rotate is set to NONE so that the texture stays pointing as we set it up.
The UV"s should all be set up correctly, although the layout is sometimes "quirky" so you may need to move any overlapping UV Shells.
Make sure your viewport is set to Viewport 2.0 and that you have Screen Space Ambient Occlusion and Anti-Aliasing set to ON, as shown below
If you wanted to, you could then save a UV snapshot of and take the layout and go into Photoshop where you can edit your textures or paint them, so they are exactly placed on the table as you'd like. We will spend a small amount of time showing this process in a bit.
But you can make the table look better still, by adding some shine
- Turn up the specular weight
And fixing the scale by increasing the repeat UV in the Place 2d texture node
These were examples of objects that were simple (toy block) or made up of a set of individual simple objects grouped together (table). What if you have a more complex object? Maya 2018 has a cool new unwrap and 3D cut and sew tool.
Download the UVMappingTutorial.ma file (from the Google Drive>CS22 W19>Files to Download for Class>UVEditing).
Make sure the UnWrap Plug In is loaded (Windows>Settings and Preferences>Plug In Manager>Unfold3d.bundle (load and autoload ON)
This is a simple cylindar that I extruded out to create some complexity for UV mapping.
I recommend you turn on Wireframe on Shaded in the ViewPort Shading menu.
There are tons of ways to unwrap a UV for texturing. Here is an easy method.
Click on the object and you will see that despite the complexity of the shape, the UV's still look like a standard cylindar. Turn on the checker view and dim it as shown below:
You want to see the extrusions in the UV Map. In the UV ToolKit, Open the Create Tab
Choose Camera Based.
You may be prompted to choose a face on the object. Go ahead and choose one.
Maya2018 has a new 3D Cut and Sew Tool You can find it under the UV Menu in the Main Menu
The object turns purple.
It is a good idea to add this tool to your custom shelf. (Command + Shift + click on Menu Item)
You can double click on an edge you want to separate to make a "pattern piece" to cut that edge.
You can also hit the Tab key and it will automatically select entire edges so you don't have to double click.
Since I made this cylindar shape with 0 cap subdivisions, the bottom is an n-sided shape. To select that edge, you can't just double click, but you can use the tool and drag around the edge to cut it.
To undo a cut you have made, hit Control and select the edge and it magically heals.
Maya's Viewport helps you visualize the shells you are creating through color (also new).
You will want to have cuts around all the horizontal edges where the shape changes.
Because of the way Maya will unfold some of the other cylindrical shapes (making them donuts instead of rectangles) it is a good idea to create cut along the verical cylinders as shown. Easiest way to select them is to click the edge and hit "x" to cut them.
YOU DO NOT WANT TO CUT THE HORIZONTAL EDGE BETWEEN THE TWO VERTICAL EDGES.
While you are still in the tool, Right click and go to Component>UV Shell.
Select a shell and hit the d key to unwrap in the UV Editor.
Select all and they all unwrap.
From here, you could, as with the table, apply a texure and layout the uv's so the texture is facing as it should. You can stitch together edges where you wouldn't want a seam, or take the entire thing into Photoshop to paint on the UV's and create a custom texture