XCOM 2
Not enough ratings
HATS! From zero to hero, Part 2 - UV mapping
By Roknar and 2 collaborators
Part 2 in my series of creating a Hat from scratch.

In this guide we will create the UV map for our high poly created in Part 1.
The first part is an introduction to UVs in general and then we go on to map the mohawk.
UVs are a pain but need to be done.
   
Award
Favorite
Favorited
Unfavorite
Introduction
First things first.
I need to remind everybody that I am basing this mesh on this artwork from Necromunda.
This work is entirely unofficial and all rights belong to Games Workshop.





OK for this part we are going to Texture our Mohawk.
Also, while a bit late, let's rename our high poly if you haven't already. Go to the scene manager and name it something more unique than "Cube".
How about "HIGH_SM_Hat_NecroMohawk_M". There is automatically a Vertex group assigned to this mesh, that's the Cube.001. You can leave that as it is or change it, we don't need it.

To texture, we need a UV map. So what's a UV map you say?
It's what lets the game engine or renderer know where and how to draw on your mesh.
You can think of it like a painting canvas that you stretch over your object.
Or one of those cardboard cutout figures, assuming you would build that up around the orginal shape again. And then you paint the cardbaord, not the orignal.

Now assume that instead of cardboard it's a screen. You could could move the painting around at will and even zoom in/out.
It's kind of like that.

It's called a map because that's what it is, really. You pick a shape, usually a square, and assign each face an area on that square.
The trick is that the shape of these faces is independant from the actual model.
So a square face could be squished and made into a triangle on the UV-map even while the actual face stays a square.
It will mean that whatever picture is under that triangle is going to be distorted as it doesn't match the shape of the actual mesh, but you can do it.
Sometimes you want this though.

The best way to get a basic understanding of UV's is to mess around a little on an example yourself. It will make more sense that way. So let's do just that.
Also heads-up, there is a lot to explain, but it's really not as painful once you're done being overwhelmed.
Setting up the cube in this way and moving the UV map around is a matter of seconds.
Your first venture into UVs will take a LOT longer, so just keep that in mind. It's a lot of words for something that is utimately no big deal.
It's just kind of hard to explain.
Unwrapping.
Let's add a cube to understand UVs a bit better before moving on.


Make sure nothing is selected and make a cube ( "A" to de/select all, "SHIFT + A" to make the cube).


In order to see what we're doing, you're going have to add a texture to our cube.
Aka we need to add a material first just like we did in the beginning.


Go to the material Tab and add a material SLOT first by hitting the plus, then, with that selected, add a new material.




You also want to change the rendereing mode to "Cycles render" at the very top. It changes what options you have when baking later and gives you different nodes.
Technically anything would work for what we need but that's what I will be using.
We don't want plain white though, so go ahead and google for "numbered uv map" to find the map I used in this tutorial or one similar to that.
Or use a picture of your cat, it really doesn't matter, but I thought this makes it clearer.

In Cycles, a material is made up of different nodes that do different things and you can combine them to do...pretty much anything really.
What we want for now is just to show a plain old texture.


Now, change the animation tab to the node editor (bottom left) and in the properties, click on use nodes.
And also change the view in the 3D viewer to texture mode or you're changes won't be visible later.




The controls for the node editor are the same as in 3D, zoom with mousewheel or "COMMA" (on the numpad). You'll see it already added two nodes. Diffuse and Material.

The Material node is what defines what the material will look like. You can have several of these but only the last one selected will be visible.
It's just a way of wrangling different groups of nodes, or previewing parts of a more complex group. We only need the one.

The diffuse node is something like a "fill" in photoshop or paint. So right now, this is telling our material node to show only a white colour.
This node simply adds a colour. You can click on the colour and change it if you want.
Except, nothing happens? It's actually working but we need to be in material view to see it.
Since we're in texture view, but don't have any texture yet, it's showing us a blank material.

This might work if you're just making art, but we are going to need textures/pictures (same thing) so let's push on.
For textures to work, the mesh needs to be UV mapped. Blender needs to know what face of the cube should be assigned what part of the texture.


Change the node editor to the UV/Image editor. Then IN THE 3D VIEW, hit "U". You will get a list of options on how to unwrap your model.




In order to unwrap, you need to select all faces in EDIT MODE first if that's not already the case. You can't unwrap in Object mode.
Remember the cardboard analogy? That's the concept here. We want to unfold the cube in such a way that it's flat. So blender needs to know which faces you want to unfold (in this case all of them). For this example let's use "Smart UV Project". You'll see below in the UV editor how it layed out our cube.





It took each side of the cube and mapped them to an indivudual square (they only look connected). When we talk about UVs, this is what we are referring to.
You can switch to face selection ( again "CTRL + TAB") and click on each face and the respective face will ALSO get selected in the 3D View.
Rememeber that each square in the UV editor corresponds to a square on our mesh, so that makes sense. Again, while closely related, they are not the same thing.

Something to be aware of is that the faces that are visible in the UV editor, are only those that are selected. Go ahead and deselect the faces in the 3D view or just select one of them and you'll see what I mean.
A different option is to synch the UV map and the Mesh, this way you can see all the faces in the UV editor at all times. Both modes are useful for different things, they behave a bit differently.





That said, our cube is still not textured...This is because, while we now have a representation for each face of our mesh, we don't actually have anything to map these to yet.
All we did, was tell blender that we want each face of the cube to be represented by an actual square. We still need to assign these squares to something other than...nothing.
Play time.
This is where the texture you downloaded earlier comes into play. Go ahead and select it as our map.




Now each face in the UV editor has something to work with AND STILL, we see nothing.
Remember our nodes? They are what determines what our material look like and so we need to add a node to tell blender to actually use that texture.
This is just blender being blender. The UV editor and the texture used by the texture node are completely different things.


Go back to the node editor and add an image texture. Connect its "color" output to the diffuse node "color" input.






Finally we have a texuture!
The diffuse node is actually a bit smarter than the simple fill I mentioned earlier. When you plug the texture into the diffuse, it will paint the material in the colours of the texture.
According to the UV layout we created before. It's a combination of the texture itself and the location of the represented faces on said texture.

In actuality we could have skipped the part about adding the texture to the UV editor, it has no bearing on the desired look.
But unless you're psychic you won't see where your represented face is in relation to the texture short of trial and error.
You can even have the UV faces outside of the image and it will still work, except in that case the final image will white on that face as Blender or the game won't know what colour to put there.

Also, you could delete the material and diffuse nodes, the texture node (and UVs) is all that determines the look in texture preview, but we need both the diffuse and the material output to render properly and that render is what counts.
A Render, btw, is simply 3D speak for the final image. Lot's of things won't be fully visible until rendering as it woud kill your machine. We just don't have the raw performance yet to do everything in real-time.

Ok then, now's the time to just generally mess with the UV map to get a feeling for what this all means in practice.


Select any face in the 3D view, for example the one that corresponds to the top left on the UV map:





Try dragging the UV-face around in the UV editor and see how it affects the image on the cube in the 3D editor. Make sure the UV-Face is actually selected and not simply highlighted (ie it's orange)
"G" to move a face. Keep in mind that the UV editor only does lateral and vertical movement so you can just drag it around freely.
You might need to refresh the 3d view by changing from edit mode to object and back "TAB" (twice).

Notice how the other sides of the cube don't change at all? Despite overlapping with the other UV-faces. They are completely independant.
Same effect when rotating "R". Now try to switch to vertex selection "CTRL + TAB" and try moving just one of the verices around.





See how everything in that triangle is still in the top face of the cube, except that the texture has to distort heavily to fit onto a square, when the UV represenation is in the shape of a triangle.
To avoid this distortion you generally want to keep your UV-faces in somewhat the same shape and proportions as your actual Object faces.

Next, try resizing a UV-Face. Go back to face selection "CTRL + TAB" and scale both ways "S" (or select of of the vertices that make up the face, same thing).
Scale it down and you'll notice the texture on that face becomes really blurry, scale it up to encompass the whole UV map and you get the full resolution and picture.
To go even further beyond means even more resolution (it's fake, this just means that the borders of that face on the cube won't have a texture).

You see, your UV map has a certain resolution, let's just say the picture is 1024 by 1024, then that's the maximum resolution your final texture will have.
If you're UV-face uses up the entire map it will be 1024 resolution REGARDLESS of the actual size of the face on the cube.
Likewise the otherway round, make it take up only a fraction of the space and the resolution will go down, as the UV-face only has a fraction of the 1024x1024 to work with.

So you want to make each UV-Face as big as possibel to get the highest reolution. You can totally overlap faces to do this.
In fact you can make all 6 faces take up the entire UV map, the result is a nice looking cube. There's only one problem. Overlapping faces will have the same texture applied.
Meaning if you draw a smiley face in one area, then all the faces that overlap will have the same smiley.

You don't really want this. So you keep them separate from each other, but now the resolution of each individual face will go down.
And if you want each face to have all numbers still, then you need to make 6 smaller checkerboards meaning the resolution just went down another notch.
There is no solution to this. It's a tradeoff you're going to be making over and over.

One way to get more resolution is to use a mirror modifier and only make half the mesh. Then you only need half the UV faces too and you have more space on the map so to speak.
But this also means that you can't have separate textures for each half. You can do the same by overlapping faces.
UV prepping
Enough with the introduction. Let's texture our mohawk.
First, let's remove the cube "X" (or simply hide it if you want something to test on first).

Time to add a material to our Mohawk now. Although unlike the Cube tutorial, try to think about which parts would be different materials in the literal sense.
In this case we're going to need some bare steel but also some parts are going to have a layer of paint. We want to make those a separate material. The spikes I gave another material as those might be extra worn.
It will be easier to work with down the road.

  1. Select the Mohawk and add three new materials like with the cube. Material tab -> add 3 slots -> add new materials.
    Call them Steel, Paint and Spikes. Spikes would also be steel but I reckon they would be more worn than the area around the skull.


  2. Unlike before though, we will take this one step further. Go to Edit Mode and select the faces you want for each material.
    Then assign them to the materials. It's in the same spot as assigning a new material to a slot, only in edit mode.




Steel

For the grooves I would suggest not to select the outer edgeloop. Those kinds of loops have a tendency to bleed out onto the surrounding material if you do.
But there is no hard and fast rule for this. It really is trial and error to get the UV map to behave exactly like you need it to.





Now in order to get an idea how our texture will behave in terms of stretching and such, it helps to use a checkerboard texture before going to the real thing.
Go to the UV editor and add a new image. When doing this you have the option to select a checkerboard.


Make UV grid with dimensions: 2048 x 2048.That should be enough for a pretty decent looking texture even close up.
THEN SAVE IT AS AN IMAGE.
( Click on "Image" for that.)




You need to save this as an image in order to feed it into an image texture node (and to make it reusable).
If you're textures are not showing up (in general), not aligning the image used in the texture node and the UV editor is probably the cause.
We need to do this for all three materials. Don't forget to switch to teexture preview and add/connect the image node.

It won't appear because we haven't unwraped yet. I don't recomment to use the smart uv projection for actual objects. It usually gives bad results.
That said you can try it. I will start with the spikes. They are the easiest.
Right now they would look a bit like butterflies if you squished them flat as is. That works just fine for us.

  1. Deselect everything "A", then go to the material tab and select the Spikes material, now (in edit mode) hit select in the material tab.
    This should now select the spikes


  2. In the 3d view hit "U" and this time "Unwrap", then go back to the UV editor to see how it laid out our faces.







Should look a bit like that. Do a quick flyover that there is no bleeding over into the faces that would be the the paint material.
Seems good to me on that front, but the top of that spike seems a little bit stretched out. We're probably fine but let's try to improve it anyway.
Finetuning the UV map
Go into the UV editor and find the offending UV-Faces. For this, the best is to switch on the synch (middle-ish of UV editor bar) and select ONE of faces that are being stretched in the 3D view.
Why one? Because of our UV layout, each spike is a separate set of UV-Faces that are only linked to the faces of each spike. They are not all connected to each other.

This is what is called a UV island. With face selection enabled, you can select faces or UV-faces by hitting "L". There is just one more step to take for this to work in both 3D view and in the UV editor.

It won't quite work yet because, unlike the UV map, the faces of the spike material are still attached to the rest of the mesh, we first need to add UV-seams around the outer edges of our spikes.
This will tell blender to logically cut off the faces along UV seams. We're not actually separating the mesh, we're simply organizing it for lack of a better word.
You can do this by hand, or better yet, generate them from the UV islands that are already fine.


You need to shift + select each UV island in the UV editor ("L" will work here already) and then "make seams from UV islands". (in the toolbar of the UV editor ("T")
Now we can use L to select the connected faces in the 3D editor too.





So now, when you select that face in 3d view and hit L, the represented UV-island will also be selected in the UV editor.
As mentioned earlier, this UV island should look pretty much like our spike, only folded out.
If you look a bit closer, you'll notice that the UV map is actually pinched compared to our actual spike. The top of the spike should be more rectangular and less like a square.


Let's fix this, by pulling up the vertices that forn the tip of our spike by scaling them in Y. "S" -> "Y".
Be careful NOT to do any changes to the UV-faces with SYNCH-mode enabled.


Because in sync mode you will also move all the vertices that are connected on the actual mesh. So disable it again for this. Be careful with this. I have lost a lot work a few times already because while fixing one UV island I was unwittinly messing up another that happened to share vertices.
You'll need to select the spike faces again to see them in the UV map but you know which ones to change now.

I only slightly changed the UV face of our spike, but you can see that the top of the spike is way less stretched now.
That means two things, more UV area means better details due to having a higher resolution and removing the stretch also make it so it's not longer distorted in that area.
Repeat for the other spikes.





Next up Steel. We can do the same, select the steel faces via the material tab and "U" -> unwrap.
There is an awful lot of unused UV space. Normally we would want to fix this, but we are going to have to make room for all the faces on this map eventually so we know that some of that space is going to be occupied by other UV-faces.
Right now we are only trying to fix any shapes that cause problems and there is one area that is not going to work as is.


STEEL PROBLEM


We can't remove this distortion as to remove it on one side is just going to distort the other. Let's break it down into simpler shapes instead.
This inset part of the mohawk is in fact a ring that goes all around, so it would make more sense to cut this up at one side so we can lay it out as a strip.
You can't really flatten a ring. This is were you use UV-Seams. These Seams will be visible but you can minimize them by putting them in places you don't really see, like in the back.
Also there is no seam along the edges yet, we migth as well do that now so we have our islands in 3D view too.


Select the edges and "CTRL + E" and select "mark Seam". The Edge that isn't already creased will be marked red. I chose the middle edge in teh back here as it's really hard to see that part.


MARK SEAM


The other parts of the mesh seemed fine so let's only select the faces that make up that inset part and "U" unwrap again.


steel fixed.


Much better now. On to the paint, and as these areas are all rings too we will get the same issue, so we need to add UV-seams here to to make strips.
There's no good place to put them here but we don't have a choice. The distortion will look worse than the seams and that spot in the middle won't work here as it is quite prominent even from third person.
Remember that the camera will often be behind them on the battelfield. Instead I'm going to go with the edges, those will be much more harder to detect by comparison.

However, the top part is stil going to be an issue. There will be holes in the UV-island where the spikes are, but we still have faces that go into those holes.
And shrinking those to fit both wittout overlapping is going to cause stretching again. We're going to have to do those separately too. These already form an almost 90 degree angle with the rigde though so shouldn't be too noticable either.


Mark the edges as seams and unwrap. "CRL + E" to mark , "U" to unrwap





See how at the back I did NOT mark an edge? that's because that area is a bit more visible and we can fold our ridge in something like a fork there so that area remains clean.
Here it's best to change our texture from a checkerboard to something closer to the final texture.
It's hard to tell from the checkerboard if a UV seam will be visible or not.

Grab some kind of brushed steel or so from the web and see what it looks like. (go with a high enough resolution so it's not all blurry)
We don't particularly care about quality, we just want to check if the seams are visible. Here you'll notice the seams quite strongly when something gets cut off.





that's something we should avoid when painting, but otherwise, from a distance you can't tell there is a line there. At the back however it is not so good.


Finetuning part 2
That weird circle there is due to how our subdivision flows and our edge loops. You can change the display of our subdivision to reflect the actual cage.
Here you can see where that circle is coming from. In order to fix this, you want to either add more geometry, or try to play with edge creases.
You can increase the weight even on flat surfaces. Turn on the uv cage and turn up the weight on that back edge and the diagonals.
As you increase the weight you can see how it changes the cage and moves that line closer follow our low poly cage. That will fix the back of a slightly sharper edge. It's not like you can tell though.





Do the same on the lower part of the ridge and that will be close enough for now.
Any issues we encouter later (and there are some areas I expect we will) we'll fix as we go along.
After increasing teh weights it should look liek this:





Before we move on to colouring, let's spread out the islands.
Select all the faces in the 3S view and then all the UV islands.
Then select "average islands scale" and "pack Islands". ("T" in the UV edior to get the tool bar in the uv editor)




That's......horrible. So much sapce is unused, we can do better. There's no tool for this unfortunately, you're going to have to lay them out by hand.
The group with all the spikes and such isn't too bad, just put that aside by shift selecting the islands with "L" or drawing a marqusise with "B". We can see to optimizing that later after we get the main shapes about right.




Could still be optimized further but it's much better than the automatic packing.
From here we can start colouring and if there are further issue we can manually tweak those, but we won't need to redo the whole thing.
1 Comments
Conter Striek 17 Apr, 2020 @ 7:32am 
Didn't expect to see an advanced blender 3D tutorial on steam :)