Skip to content

How to port a hairstyle from the Sims 4

Shalerei edited this page Aug 23, 2021 · 5 revisions

In this tutorial I will explain how to set up Sims 4 hairstyle CC for use in Mass Effect, specifically Mass Effect 1 Legendary Edition. I will be using a custom hairstyle made by Anto. You will need these software:

Blender https://www.blender.org/

PSK export https://github.com/DarklightGames/io_export_psk_psa/releases/tag/1.1.0

PSK import https://github.com/Befzz/blender3d_import_psk_psa

ME3 Tweaks https://me3tweaks.com/

UDK https://www.indiedb.com/engines/unreal-development-kit/downloads/february-2015-unreal-development-kit-udk

Sims4Studio http://sims4studio.com/

An image editor like Photoshop or GIMP, I will be using the latter.

It should also be noted that you will need some knowledge about how to use Blender and that you do not need the Sims 4 itself if you want to port downloaded hairs.

Extracting files from Sims package:

If you have downloaded a hairstyle for The Sims 4 you will get it in a file with a .package file extension. We will use Sims4Studio to extract the relevant files from this .package file. When you open Sims4Studio you want to click My Projects and open the .package file you downloaded. Then you need to extract the mesh and the diffuse texture. The diffuse texture will by default be highlighted for export.

the mesh would be exported from the meshes tab

Export these wherever you'd like, but it is best to keep organized. You are done with Sims4Studio now. You can close.

Extracting templates from Legendary Explorer.

You are going to need to export some things out of the game files itself for use as templates and reference. First we will handle the hair to serve as a template. Open the package editor then open \BioGame\CookedPCConsole\BIOG_HMM_HIR_PRO_R for male hairs or \BioGame\CookedPCConsole\BIOG_HMF_HIR_PRO for female hairs. In it you will have several folders, many of which containing hairstyles, some of which are useful as a template. I will be using Classy.

Now leave the window open as is. You are now going to create a new package you will store your hairdo in. Open another instance of the package editor. Then go to File -> Create new -> Create new empty package and create a new package suitable for the game you want to add the hair to and drop it into the folder created by ME3Tweaks when you generate a DLC Mod Starter kit(in the tools menu). Now arrange this new instance of the package editor and the one with the template you want to copy so that you can drag the contents of the latter into the former. You start with the folder, drag it to the filename at the box to the left. Note it must be on the filename not just the empty box.

This time, for the folder, click 'Add only [foldername]'. Now do the same for the mesh, which would have an M in a square to the left of the name and usually end with a '_MDL' suffix. This time, however, drag it underneath into the folder and click 'Clone All References'. Do the same for the diffuse texture, which would have a blue and grey checker icon to its left and end with a '_Diff' suffix.

Now you may notice there's a third file in the folder, that's the material and come when you cloned the mesh's references. The same process also cloned the texture the mesh would use but into another folder, the global folder. As is the case right now, the material doesn't know the texture we cloned exists. We need to fix that now.

Click on the material. In the 'Properties' tab which should be open by default, expand the 'TextureParameterValues' and the item in it. Then, click on 'ParameterValue' and match the number in there with the texture you cloned as demonstrated in the following image:

Don't forget to click 'Set'.

Now we want to rename our components. This is done but clicking on the item in the tree view, clicking on the 'Metadata' tab on the right pane, and altering the 'Object Name' field — the top most field. When the name is changed as desired, hit Enter, click 'Ok' and click 'Save Changes'. You can do this for the folder, mesh, material, and texture. Make sure the Object Index number for your files are 0. If you wish, you can right click -> 'Trash Entry and Children' the folder containing the texture that came with the mesh cloning, which in my case, is the Global folder. Save but don't close just yet. Right click on the mesh and click 'Open in Mesh Explorer'. Right click on your mesh name on the left again in the Mesh Explorer and click 'Export mesh to PSK with Umodel'. Close Mesh Explorer. Back in the package editor click on your diffuse texture in the left side tree view and then click on the 'Texture' tab on the right side, at the bottom right, click 'Export to File'.

You are going to need a head mesh to fit your hair around, this can be found in the \BioGame\CookedPCConsole\BIOG_HMM_HED_PROMorph.pcc and \BioGame\CookedPCConsole\BIOG_HMF_HED_PROMorph_R.pcc for male and female heads, respectively. The one you would want to use would be in the 'Custom' folder in both cases. The export process works the same as explained above. You will also want a body model, you can find them in \BioGame\CookedPCConsole\BIOG_HMM_ARM_HVY_R.pcc and \BioGame\CookedPCConsole\BIOG_HMM_ARM_HVY_R.pcc, along with many other packages. We are done with the package editor for now. Now it's time to pop in Blender.

Porting in Blender

I am going to be assuming here that you know how to use Blender at least to a basic extent. You will need to know how to navigate, control the camera, basic mesh manipulation. This is not much really, but there isn't much space to include this into the scope of this tutorial and it's much better in video anyway.

So what you will do now is open the mesh that you exported earlier with Sims 4 Studio. We will now start making some tweaks to adapt it for importation into Mass Effect. The first thing you need to do is to remove the meshes that won't be used. Hide all the 's4studio_mesh_#' objects on the tree menu until the head is bald and reopen them one by one. If you see meshes with hair on the side of the head but a clean scalp you can delete those immediately. These are meshes The Sims 4 uses for when a character is equipped with a hat; this isn't relevant in the game we are porting to. If you are left with multiple objects called 's4studio_mesh_#', join them up, but most of the time this wouldn't be the case.

Now we have to remove double sided faces; UDK doesn't like those. Make sure backface culling is on.

Go to edit mode and click on a face or vertex, then press Ctrl+L. This should select a segment of the mesh made up of connected vertices. Hit G to move it out of the way(but do not finalize with a click). Right click to cancel the move operation. If you see colored in grey-orange faces, hit H to hide it. If you see a wireframe with no filling faces, or only see faces at the edge of a twist, delete it. If you see a segment of the mesh that looks like this beneath a piece you have hidden, delete those also. Hit Alt+H if you wish to recover parts of the mesh you have hidden. Do this until the whole mesh is clean of double faces.

Next we will have to fix the UV map. The Sims 4 has their entire characters use the same textures, therefore it has a smaller section of if dedicated to the hair. However, this is pretty straightforward to fix and only takes a couple of steps. Set up a window with the UV editor open and select the entire mesh in Edit mode on another window. Back in the UV editor window, hit N to reveal some option on the right, if they were already up and you just hid them, simply hit N again. Under the View tab in the 2D Cursor section, set the Y field to 1. You will now see the crosshair move the top left of the box in the UV editor window. Then change pivot point to 2D cursor.

Now select all the UVs by hitting A and hit S to scale. Without clicking anywhere, hit X to limit the scaling to the X axis, then hit 2 to scale by a factor of two. The UVs should occupy the majority of the width of the square canvas in the UV editor. Now do the same for the height, but this time scale on the Y axis by a factor of 4. With UVs selected, hit S, Y, and 4 in succession.

With the UVs sorted out, there are still some minor things to tweak before we start scaling and fitting to the head template. In the Object data properties, remove all vertex groups and remove the uv_1 UV map. Rename the 'uv_0' UV map to 'UV0' by doubleclicking it.

Now you will need to size and fit the hair as well as assigning bones. Save and open up a new project(File -> New -> General). Delete all objects in the scene. Import(File -> Import -> Skeleton Mesh(.psk)) the head and armour meshes you exported earlier, but leave the hair mesh for later. Make sure that 'Scale down' is ticked off.

We want to remove a redundant skeleton now. In the tree window select the armature(indicated by an arms-out-legs-out stick figure icon) associated with the head mesh and hit delete, yes even if the mesh is one of its children it will remain. You will see the stick figure changed to an upside down triangle, indicating that is a mesh.

Append(File -> Append) the converted mesh you just saved. When you navigate to it, however, you will notice it will just show a bunch of folders, you want to open the 'Object' folder than open the s4studio_mesh_# object in it. The appended object is tiny in comparison to the other stuff you just imported, hit NUM . to focus on it. Delete the bone shape object that came with the appended mesh, then select the appended mesh in object mode. Rotate it 90 degrees by hitting R, Z, 90, and Enter. Scale it a by a factor of 100 by hitting S then typing 100 and hitting Enter. Now the hair should be close but not quite on the scalp. You will have to tweak it a bit in edit mode for it to fit. Proportional editing helps a lot here.

Once that is done we will start with the weights. First we have to make the hair object recognize the skeleton of the head. Go to the 'Modifier Properities' panel and select the rig of the head mesh.

Now we are going to be transferring weights from the head to the hair. On the tree window while in object mode, hold Ctrl and select the merged head and then select the hair object you just scaled and fitted. go to Weight Paint Mode, click the 'Weights' drop down menu then 'Transfer Weights'.

Now under 'Transfer Mesh Data' set Vertex Mapping to 'Nearest Face Interpolated' and Source Layer Select to 'By Name'. You will now see the vertex groups populated again. You're not going to want the hair to move with facial features like the nose or mouth, so delete vertex groups relating to those. Now let's check if the weights transferred correctly, or at least satisfactory. Go to object mode, then select the armature, then head to pose mode.

Select any of the three segments in the head and rotate them around with R. Look for ugly rip-stretching or excessive clipping while you are rotating the head around. You will know it if you see it. If the hair is short you probably won't have any real issues. If they are long like mine, however, you probably will. You will need to fix that by weight painting manually. Unfortunately I can't help much here, while I get along I myself don't really know exactly what I am doing. You should find tutorials on weight painting on YouTube.

When you have sorted the weights out, save and open a new blank Blender project as before. Now import the .PSK of the hair you exported earlier. Then append the hair you just saved. Delete the full body skeleton. You should end up with the template and the Sims hair clipping into each other like this:

Click on your sim mesh in object mode. Head to the modifier properties and assign the skeleton to it.

Head to Edit Mode, select all vertices/faces, then go to Material Properties, select the material that isn't called 'DiffuseMap'(which comes from Sims) or 'Material'(default Blender material). Then click assign.

We are now going to replace the template mesh with the one we're porting from Sims. Deselect everything in edit mode on the Sims mesh, then head to object mode. Select the template hair, then head to edit mode. Make sure everything is selected. No go to object mode and make sure you have nothing selected. Select the Sims hair then hold either Ctrl or Shift and then select the template hair(Ctrl if you are using the tree window to select, Shift if you are using the 3D view to select). Then hit Ctrl+J to merge. Head to edit mode and you should see the template hair selected with the Sims hair unselected.

Delete the template hair vertices. Now delete the UV_SINGLE UV map. Head to object mode, select the hair mesh or object, make sure nothing else is selected, then head to File -> Export -> Unreal PSK (.psk). You should be done with Blender now.

Importing mesh into package

You now have your mesh set up but you still need to format it in a way that you can import it into the package file. Open up UDK Editor. In the default view once you close the welcome screen, drag your PSK from Windows Explorer to the bottom middle pane, leave the names on default if you so desire, then press ok. Find the mesh you imported, then right click and click 'Save'.

Save it somewhere with a .UDK extension(not a UPK extension as is default).

Open up your package in the package editor, then right click your mesh and open it with Mesh Explorer. Right click it on the left and click 'Replace mesh from UDK' and navigate to your mesh. Select your mesh in the empty drop down box and hit OK. Close the Mesh Explorer but leave the package editor open.

Formatting the diffuse texture for import

So far we've only worked on the mesh, now it is time to sort the texture out. I will be using GIMP. Open the diffuse texture you exported earlier. As said earlier The Sims 4 uses a single texture file for all the character's textures so only a part of it is dedicated to the hair, so we are going to change the canvas size. At the menu dropdowns near the top of the window click Image -> Canvas Size... .Divide the width by 2 and the height by 4 and click.

Click Layer -> Layer to Image Size, then Colors -> Components -> Decompose... . Select the RGBA color model. On the blue channel, now presented as a layer, select all and fill it completely with black. The red and green channels should have a texture on it that is more or less homogenous with the contrast being primarily between the hair strands as opposed to baked in lighting as is often used in The Sims. It is recommended to replace it with your own texture. This texture can fill up the whole layer but make sure that the hair strands in your texture flow the same way as the textures you are replacing are. The red and green channels should have the same texture on it except that the green channel will be quite a bit brighter than the red one.

When it's ready it is time to compose it again. Click Colors -> Components -> Compose... and compose with an RGBA color model. The hair should have a lime green look on it. Export this texture as a PNG.

Open the package editor again head to the texture in the package, then click on the 'Texture' tab, on the bottom right next to the Import from File' button click the dropdown menu and select 'Create new TFC', then click 'Import from File'. Then import your file and leave the TFC name on default. Save your package.

Final steps

For LE1, we will need to take some steps to deal with the TFC. In the same folder the package file resides in, a .tfc file should have generated. Cut that .tfc file, and navigate a few folders up the folder structure until you see a file called moddesc.ini. In the same folder that moddesc.ini resides in, create a new folder called 'TFC' and paste the .tfc file in there. Copy the name of the .tfc file you pasted. Go back and open the moddesc.ini file and add the following lines:

Don't forget the file extensions, and save. You can now apply your mod with ME3Tweaks. You still need to make the hairstyle used by your character. Open up the save editor and open the 'Head Morph' tab. By default the hair mesh field will be expanded. You will need to know what needs to be filled in here. Open the package editor and open your package and select your mesh. Open the 'Metadata' tab. What needs to be filled in is what is listed in the 'Instanced full path' field prefixed with your package file name.

The same process should be done with the texture. The texture should be filled in the save editor under 'Texture Parameters'

Save. You are now ready to launch the game.

Clone this wiki locally