XCOM® 2 Guide

HATS! From zero to hero, Part 4 - The Low Poly for XCOM 2

HATS! From zero to hero, Part 4 – The Low Poly

Overview

Part 4 in my series of creating a Hat from scratch.In this guide we will create the low poly that will ultimately get imported.This part is similar to the high poly with a few differences and additional points to consider.First we create the Low pooly version and bake the textures for it.Then we prepare the low poly and its textures for import in the next tutorial. This part includes weight painting.

Introductions

Obligatory statement to save my bacon.
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, so we left of the last tutorial with a textured High poly mesh.
You could, in theory, add this to the game and it would work. Problem is, it has way to many polygons and will use up all your performance.So we need to make a separate version of the mohawk that is less of a performance hog but still looks good.

This low poly version will also use its own textures that are different to the high poly.
Due to the subdivision modifier our mohawk looks good, but it will also have some 100k+ polygon.
We need to bring that down to something closer to 10k and less. That mean we WILL have to make compromises, but that’s the name of the game.

1.1 Creating he low poly

To make the low poly we need to make a completeley separate mesh. It has nothing to do with the high poly as such. We won’t be retexturing from scratch though, we can use the textures we made for the high poly, but we’ll need to adapt them to our new topology.

Likewise, you don’t have to start from zero to make the mesh, although that is one possible workflow and is actually more appropriate for stuff that isn’t hard surfaces like this.
For our purposes we can make a copy of the high poly and cut that down to size instead. With the caveat that the low poly will be ever so slightly bigger for reasons of baking the normals, more on that later.


Go to Object mode and duplicate the high poly. Rename it.

Now check out at the very top bar the number of triangles(tris) compared between the applied subdivision and the “low poly” cage of the subdivision (it’s actually counting all the scene but our high poly is pretty much all there is in it). That’s a ginourmous difference. The subdivided mesh is the one you see when you hit “Z”, so you can see that per face of our cage, there are tens of faces for the subdivided mesh.

Polygons can actually be many things but in gaming terms you can consider them to be flat triangles. In fact, any mesh you import into the game will be dividided into triangles. There will be no square faces left. This is something we need to keep in mind and in some places we should divide faces into triangles ourselves as it can affect the final look. Plus it means you can import it into any other engine and know that it will stay coherent between games.

Let’s start our low poly by removing the subdivision modifier, we won’t need it. Just click on the “X”.
Next, we won’t be needing any edge creases either so select all the faces and set the edge crease to 0. That’s not to say it can’t help to keep an edge nicely defined, but in our case we won’t need it.
Any of the edge we want will be kept via additional edges as opposed to an edge crease.

Technically we could pretty much run with this mesh as it only has 2000 triangles/polygons. 10k should be the upper limit of what is acceptable, but you should always try to optimize as best you can. Players will have more mods than just your own, so every little bit helps. So with that in mind, the biggest savings can be made on the sides of the mohawk, the grooves.

Those can reasonably be replaced with a normal map without loosing much in terms of visual fidelity, but we’re going to save a lot of tringles. So let’s straight up remove these grooves.

We still have our materials, so select the spikes material and switch to wireframe mode “Z” to deselect every face that is not part of a groove via “C”. Delete “X” them. We didn’t add the outer ring of the grooves to the spikes so you’ll have to select those manually and remove those too.
Also delete the faces surrounding those grooves, just don’t remove the edges we added to retain the edges of the mohawk. Those will still be useful.

Now we need to fill these holes again. Select the edge loop for the hole “ALT+LEFT MOUSE” and fill it with a face “F”. This gives us an n-gon, a polygon with more than 3 edges. Not generally an issue, but should be avoided, you’ll soon see why. So we need to connect the vertices by selecting two vertices that cut across and joining them with “J”. Doing just this almost halved the amounts of vertices.

The other big improvement would be to remove that middle line that runs across the sides of the mohawk. It serves no purpose but doubles the amount of faces we have in that area. Select the Edgeloop and “dissolve edges”.

The rest of the mesh is pretty much ok. You need to keep a certain amount of detail or we loose the general shape. We could reduce the number of squares on our sides but I feel like we would loose too much detail and we only have a bit more than a thousand polygons so we can just keep it as is. The bolts that connect the mohawk to the skull on the other hand will not do at all. They’re not following the circular shape close enough and that will be immediately noticable.

1.2 Creating the Low Poly

We’re going to have to add some detail here, so add some edge lopps “CTRL + R”. But first we can remove the grooves here too. For this part I highly recommend a certain add-on: “Loop tools”. It’s actually pre installed but you need to enable it via the user preferences and search for loop tools in the addon tab. You can access it via “W”. With that it’s pretty easy to make our bolts rounder, just select an edge loop of vertices and select Looptools -> circle.

The idea is to follow the high poly as closely as possible while being a tiny bit bigger as we’re going to be casting rays inside until they hit something and the further apart your low poly is the more distortion there will be. It’s normal if the high poly sticks through your low poly in some spots. That will happen along any curves and can’t be avoided, but the closer we can align the two, the less noticable it will be.

There’s no trick here, just keep going around your mesh until it somewhat resembles the high poly. The edges we added to sharpen the subdivided edges come in handy here. You should be able to look at the low poly and get the impression that is roundish from a distance. I also noticed I wasn’t quite centered so I moved both the high and low poly over a little bit. The norlmal map will help make it look rounder than things are.

There may be areas like this where you can see triangles in the shading. These aren’t very noticable and you can probably get away with it. We’ll need to add another set of edge loops here to fix that. This has to do with which direction the normals are facing. This is too much to explain here, but this waviness tutorial[polycount.com]
and also this polycount tutorial[wiki.polycount.com] have a lot of good information. Long story short, you want the untextured mesh to reflect light as closely as possible to what the final thing would look like.

There are also cases like this where can control the way the mesh is shaded by manually controlling where the triagles go. We have a square so you can have two different diagonals and both will look different. We’ll need to do the same for the spikes. Here I decided to emhasize the curve of the mohawk on the left side by joinging “J” from the centre up to the left and for comparison also from the centre downwards to see how much of an impact it has.

While you’re adding an edge here, you’re not actually increasing the amount of polygons. It was a square before and so would have two triangles no matter what, but by adding them manually you can be sure the game doesn’t decide to place that diagonal in the wrong direction.

For the flat top of the mowhawk that has the spikes, the best way to add an edge is to select all the faces on top and performing an inset “I”. This will create a loop around the outer edge and around each spike.Take care to remove any extranaous seams this may create. You’ll go back up in polygons but the result will look quite clean.

I feel comfortable enough to do a test run. We only want one material in the game so remove all the materials we have and add a new one. Otherwise they will share properties as they are the same exact materials, not materials that have the same name. Baking for the low poly is a bit different. We need to select the texture we want as a diffuse on the high poly and bake that onto the low polys different layout.

Our mesh is different so we should create a new set of UVs. Although I will be using the same seams as before and so won’t be dramatically changing anything. That said, in retrospect I would have completly redone the base mesh by using mirroring and maybe even making the top a seaparate thing. That would have given us a much higher resolution, but there’s not much point in doing that for the low poly now as we’re not going to get a higher resolution than the high poly currently has.


You know the drill by now. Load up a checkerboard and go about unwrapping.

For baking, the most important texture here will be the normal map, so let’s start there and get that right. Baking the low poly shouldn’t take long per map, so you don’t have to get the UVs perfect from the start. Fix where you think there will be issues and bake the normal map, and then come back if the the next steps show more issues and spot fix, including the actual low poly mesh.
You can select the normal option for baking as usual, but we need to take a few more things into consideration.

You need to select the high poly in the scene manager AND the low poly (last, that’s important) and now select “selected to active” in the bake options.
For this the high poly needs to be visible, ie enable the eye in the scene manager. The setup in the node editor is the same as before, an unconnected image texture node. The two also need to overlap, but that should already be the case from creating the low poly mesh.

I left the ray distance as zero deliberately to show what it looks lik when it’s either too low or to high. Too low and it doesn’t capture the details, too high and it might pierce the mesh and hit another part of the mesh and cause errors. Another option would be to bake from a cage, wich is a third mesh from which to cast the rays from.

Sometimes it’s also necessary to “explode” a mesh in order not to interfere with different parts. There is no good way of doing that in belnder other than moving parts manullay by snapping to the grid and making that an animation so you can return to the original state. With a relateively smooth mesh as this we should be fine to bake directly.

I’m not seeing any glaring errors. It looks a bit funky in the back under the ridge of the mohawk, but nobody is ever going to see that, so I’m simply going to ignore that part. The next step then is to bake the remaining textures, incuding the high poly normal map since it uses a normal map of it’s own and the bake we just did only baked the shape information of the high poly onto our low poly.

So for this part be sure to select the the texture you want to bake as a diffuse shader on the high poly. We’re really just taking our prinicpal inputs nodes and converting them to match our low poly UVs. We want to bake the maps as they are down onto the low poly.

In the high poly, select the Diffuse colour image node and attach it to a diffuse shader with a material output. Do this for every material on the the high poly. Verify it looks right in texture mode, you shouldn’t need to be in material or render preview as everything is a base texture.

Then bake with the diffuse option and only colour (same settings and process as for the normal).

Then go back to the low poly and select the unconnected image node (with a new texture to bake to) and bake.

This needs to be done for ALL maps, including the Ambient occlusion at the very beginning ( I lost mine so I just remade it). Also, be sure the are in colour mode and not as non-colour data, since the game will later interpret itself how to read these maps. For the normal map, don’t include the mapping node, just use the texture node on its own.

2. Weight Painting

You should end up with 7 Maps with the previous step.

  • Diffuse
  • Metal
  • Roughness
  • 2 normal maps, one converting the High poly one, the other baking the shapes.
  • Ambient Occlusion.
  • And finally, also a tint map ( except I forgot about that in the last tutorial so we’ll do it this tutorial towards the end.

Now there’s one more step to do before we can export. For animations to work, you don’t animate every single vertex. Instead you make a representation of the various moving parts and you let the vertices move with those parts. So instead of a head, you only have a single object and you tell the vertices to move in a 1 to 1 relation to that. The more complex your animations, the more such control objects you need. That’s where the skeleton from the first tutorial comes in.

The skeleton is made up of bones and we assign each vertex to a bone. The various animations then control those bones. The skeleton is needed to connect them. So that when you move the bone for the forearm, you also move the bones of the hand, which then can still move on their own.
To determine how closely a vertex follows a bone is called weight painting. So called, because it’s not just about assigning a vertex, but also about how strongly that binding is. And also because that’s how you assign this vertex-bone relation, you literally paint it in. Setting up the skeleton itself is called rigging.

For our hat, we will weight all our vertices completely to the head bone, so it moves 1:1. For other parts such as the elbow, there is no singular bone. For such parts the vertices are partly weighted to the forearm and also to the upper arm, as both bones should affect how the vertices of the elbow move. Guns on the other hand have several independently moving parts, so different parts are 100% weighted to different bones of the gun, all of which then move with the left hand of the soldier for example.

So for us, this means that we need to assign/create some bones and then weight paint all our vertices to the head bone. Naming is important here, as the game animations assume certain bone names. That’s why we need to import an existing skeleton to have the correct relations. Technically it’s possible to add your own bones and name them whatever you want, but then that also means you need to make new animations.

When painting the weights for these bones, red means it is 100% dependant on that bone, dark blue means it isn’t at all. There is also a pink, but that means it does not have any weight assigned at all. As in, there is information missing, not having a weight is different than specifically assigning no weight. Indeed, the game will not let you import an object that has no weights assigned.

You can add your own bones, but let’s re-use the skeleton we imported. For this, I like to make a copy of my low poly, just in case. The next step will resize our mohawk, right now it is perfectly overlapped as we need it and I’d rather not have to move it into place again later if something goes wrong. We can also still use the original for any baking that might be required if the textures don’t turn out to our liking.

Set the parent of our mesh as root.001. This is the name of the armature of the headband we imported intially, it may be named differently for you. It is NOT the skeleton itself. The armature is just the name for the all the animation controls, like the skeleton and bones and what have you.

Doing this will change the scale of the mohawk to be tiny. We need to scale it back up again. It helps a lot to have the reference head back up for this, but it’s a little finnicky even then. Then next thing is to assign the actual skeleton to the mesh, assigning the armature is not enough. For this we need to add an “Armature” modifer and assign the armature we just parented. Now we can use the skeleton that is assigned to this armature.

If you check with the headband mesh, you’ll also notice here that it has a vertex group called head.
The vertex group is exactly that, a group of vertices, however, we need to assign every vertex to some vertex group or another and these groups need to match the bone names, or the import into the game will fail.

For us, as with the headband, we want to assign everything to the “Head” bone so select all “A” and assign the vertices to the “Head” group (upper/lower case matters). You can either make the group first or the armature, order doesn’t matter, but you can’t create the vertex group from the armature modifier directly.

Now, given how all our vertices are assigned to a the “Head” vertex group and our armature modifier applies to that vertex group, we are already done. When you switch to weight paint preview, you’ll notice it is all red already. You’ll often have different groups of vertices though, so it won’t be quite as straight forward. I’ll cover how to manually weight paint too.

This is straight forward enough but Blender is really awkward about selecting the correct bone.
Select the armature in the scene manager, go into pose mode then select the mesh in the scene manager and go into weight paint mode. You should then be able to select different bones by right-clicking. From there you literally paint like we did with the manual masking. Except here you “paint” in more or less weight.

With that done we are almost at Captn bubs tutorial. The export works as he explains, but our textures are STILL NOT good. We are however done with blender for now. So let’s export the mesh.

Select both the root armature and the mesh you want to export.
Then go to File -> export -> FBX

You’ll want to name your file properly at the latest here. That way it gets the name right when you import. Base yourself on existing stuff like the headband: SM_Hat_G_NecroMohawk_M
SM for skeletal mesh, Hat to describe what you’re dealing with, G for the hair model it is based on and then a name along with the gender.

Check “Selected objects only” then Switch tabs to Geometry and change the modifiers render setting to “Face”. Normal works too but you get an extra error that can be ignored.
Finally go to Armatures and de-select “add leaf bone”, blender will still add an extra bone but this is one less useless bone.

3. Preparing for import

You can close blender at this point. The textures we have right now are ok and coudd indeed be used as is, but the game optimizes a bit further. It will combine certain textures into one to save space, but we need to do the combining by hand.

This is where channels rear their head again. A normal texture has a Red, Green and Blue channel to encode the various colour values. These are then combined to form a complete picture. Our diffuse for example is made up from these three basic colours, the RGB values. When you open this texture up in photoshop, you will indeed see one layer for each. There could also be an alpha channel which is used to make parts of a texture/picture transparant.

That doesn’t mean you can’t use channels for other stuff. For example, our metal is black or white and as such doesn’t need 3 different channels to encode that. One channel is enough, likewise for the Ambient occlusion and roughness maps. The metal map in the game takes advantage of this by combining the Metal and Ambient Occlusion into a single picture.The metal map will be in the Red channel, while the AO sits in the green channel. The blue channel is simply ignored by the game (but needs to be present none-the-less for technical reasons).

This will result in a weird looking combined picture, but the game doesn’t care about that. It will only look for metal in the Red channel and it expects an ambient occlusion map in the green channel. For this to work we need to tell the game to treat the texture in a certain way and of course create this mixed texture. We’re not actually creating a new texture per se, we’re just using the different channels as neatly organized packages so to speak.I haven’t found a complete map of how the game expects its textures for different types of objects, but I did find this handy chart (or rather Σ3245 sent it my way 🙂 )

Don’ worry too much about the details yet. This one is particular for clothes/armour, but the same idea applies for weapons with some exceptions. Keep it close, it will be handy for the next tutoriat. That said, you can see for example that the MSK (multi mask, a remnant from the vanilla game) is a two channel texture containing the Metal and AO map. The Diffuse is a normal texture with an added alpha channel to house the roughness map, while tint and normal maps are separate. There are some additional maps but they’re a little more advanced and I haven’t used them myself yet.

So what we need to import into the game is actually only three to four textures instead of the 7 we just baked. One diffuse that combines the diffuse and roughness, one MSK combining metal and AO and a normal map. Optionally also a Tint map which combines two different tints. Weapons only have one colour for a Tint, but armour has two so we can give the part with the grooves and the top different colours, but technically that is two different tint maps.

Open both the diffuse and roughness in photoshop (or whatever) and add an alpha channel. I find with Photoshop I need to save it first as a targa before adding the roughness map in the alpha channel or it won’t be saved. Then copy the Roughness map into the alpha channel and you’re done.

Then open the metal map and the AO map and copy the AO into the green channel of the metal map. Save it as a targa. Name it something that ends in MSK. Again the game takes these names to import so it’s less of a hassle to get them right from the start.

The Normal map is combined in the same way as before, only it’s much simpler. We don’t need any masks and only need two copies of the high poly normal map. Top layer set to “overlay” and without blue, middle layer to “Multiply” and without Red and Green. (bottom layer being the high poly to low poly topology bake, the one with the grooves)

And since I missed to add a tint map earlier, I’ll do it now. There are a lot of way to do this, but I based myself on the metal map and removed parts of it (made them black). As per the chart, in the red channel, make everything black that isn’t the side of the mohawk and then in the green channel keep only the top half, we don’t care about the blue channel. You can get more fancy of course, but the idea is that whatever is white in the Red channel will be changed to the Primary Armour colour and everything white in the green channel will be changed to the secondary armour colour.

I tested it but there still was some still blue showing through so I ended up re-doing the tint in Blender (still from the metal map but with harsher contrasts), you’ll be able to check what it looks like yourself in the next tutorial, which is going to be fairly short. You want everything that is not metal or rust to be white, but there might be some issues due to the low resolution in some areas. In my case I covered the metal a little bit on order to compensate.

That’s all we need to import. Next tutorial we will import it all and get it running.

SteamSolo.com