RimWorld
Оценок: 244
[1.3 & 1.4] Creating a Hair Mod for RimWorld
От Rooboid и соавторов
A comprehensive guide for taking your hairy ideas to new heights. This guide goes through the very basics of graphic creation and programming, so start here if it's your first time modding Rimworld.
12
6
8
3
5
2
2
   
Наградить
В избранное
В избранном
Удалить
Introduction
Well done on completing the hardest part of any project; Googling a guide for it and making those first steps into unknown territory. In reading this, you are now bound to making at least one hairstyle for Rimworld- no buts, no take-backs, this guide has become a written contract and it’s time to get stuck in!

This guide will take you through the process of drawing your own hairstyles, implementing them into Rimworld and setting up a Steam Workshop page for your mod.

This guide is aimed at anyone of any ability. So if you don’t think that you can draw or code, that’s great, because I couldn’t when I first started either. Let's get started.

Software
We'll need 2 pieces of software for creating a hair mod. Something to help draw the hairstyles and something to help us implement the hairstyles.

Download here[notepad-plus-plus.org].
We’ll use this to make the mod function.





Download a trial here[www.adobe.com]. We’ll use this to create graphics for our mod. You can use any alternative to Photoshop that supports alpha layers (transparency) such as GIMP and Krita. Or, you know, swashbuckling's always an option...



Download here[drive.google.com]. This ZIP contains all of the graphical templates you'll ever need to create your mod, as well as the files needed to save time setting your mod up from scratch.
Scope
This is a totally optional step, but as someone with terrible organisational skills, I need this step. Consider thinking up ideas and planning your hair mods first. Be that looking for inspiration on the Steam Workshop, Pinterest or in the mirror at your gorgeous self.

Keep in mind that for every hairstyle you create, you’ll need to have:



Once you’ve decided how much work to set yourself, take a look at the [Roo's Hair Tutorial] Template[drive.google.com] folder you downloaded. The layout is:


You can chop and change the #Mod Creation Assets folder as much as you like. This is just where you'll find any graphical templates that I've made for you to use. Rename the [My Mod Name] folder to whatever you'd like to call your hair mod. But don't alter any of the files or folders inside there yet.

Drawing

Every hairstyle has 4 different sprites which follow these naming conventions.

You’ll notice that the head faces the same way for both the east and west hairstyles. The game will automatically flip the graphic in-game, so don’t worry about doing this yourself.

The [Roo's Hair Tutorial] Template[drive.google.com] folder has 3 different versions of hair template.





Sketch

I'd recommend the using 500px one for your first try. However, you can use whichever size template you prefer. Open up the hair_south.png first.

Create a new layer (Shift + Ctrl + N) and roughly sketch out your hairstyle- or if you’re using a photo reference- paste your reference onto the canvas, set the layer to 50% opacity and try to match it to the head of the pawn. This step is just about getting the basic shape established.




Linework
Create a new layer for your linework and trace over your sketch. Your drawing software may have a 'smoothing' setting, which will slow down your brush and make your lines cleaner. This can be found on the top bar when the brush tool is selected in Photoshop.




Colour
Rimworld will automatically apply colour to the pawn's hair in-game, so we only need to use shades of grey when shading our hairstyle. There's 3 shades we'll use to create our hair, which we call our 'swatches'.
Create a new layer beneath the outline and fill in the outline with your midtone. You can do this manually, with the fill tool or with the magic wand tool.

Once you've coloured in your hair, lock the transparent pixels of your layer. Select your layer and hit /. This will stop you from shading outside of the coloured area.

Now it's time to shade- which honestly- can be a bit of a 'take-it-as-it-comes' process. The general rule is to concentrate the shadows at the bottom of the hair, and concentrate the highlights at the top, since the light source is above the pawns. Good tools to experiment with include:

Rimworld seldom uses hard shading on organic objects, like hair or animals. Set your primary and secondary colours to two of your swatches and create gentle fades across the selected area from one swatch to another.


The lasso tool can be used to create irregular shaped selection areas, which you can then use in conjunction with the gradient, burn or dodge tools. This can help to imply a subtle texture to your hair.


A quick-and-fast, short-and-sweet, 2-pump-chump way of shading your hairstyles. The burn and dodge tools act as brushes that darken and lighten the applied areas respectively. Use this if you'd rather not deal with having set swatches.



Polish
Now that your hair looks nice and shaded, it's time to put the finishing touches onto it. Although not necessary, these are two handy steps to ensure that your hair looks vanilla-friendly. If you're opting for a more unique art style, though, feel free to skip this step.

Look at these Rimworld assets. What do you notice?
Check out the difference in width between the outermost outlines and ones within the shapes- such as the fluff of the arctic fox's cheeks or the torso of the skull-pture. Rimworld uses thick, black outlines to emphasise asset silhouettes, but rarely uses thick outlines when it comes to those finer details within the silhouette. In fact, the drape and the bionic part don't even have any black inner lines at all.




Finishing Touch 1 - Variable Outline


Let's try and carry these observations over to our own artwork. The example hairstyle on the left shows a hairstyle with an entirely black outline. It looks good, but it contradicts the vanilla art style.

The hairstyle on the right uses the same outline, but with the inner lines lightened. By selecting your outline layer, locking the transparent pixels by hitting / and applying your shadow swatch to the inner lines, you might find that feeling of 'something-is-wrong-with-this-hairstyle-but-I-don't-know-what' go away.




Finishing Touch 2 - Rimworld is a Thicc Boi

Now, let's apply a stronger outer line to our hairstyle. Merge your outline and colour layers, then double click the newly merged layer in the layers panel. The Layer Style dialogue box will appear. Select the option 'Stroke' and ensure that the opacity of the stroke is 100% and the stroke colour is black. The stroke size will vary depending on which template you used, so just try to match it to the thickness of the pawn's head's outline. This will add a thicker outline to your hair, just like as we saw in the vanilla assets above.

If your software does not support layer styles, you can also do this manually by tracing the outer line of your hairstyle with a thicker brush.




Export
Remove the pawn's head layer so that you're just be left with your hairstyle on the canvas. If you used the 1000px template, go to Image > Image Size and reduce the width and height of your image to either 500px or 128px.


Open up [My Mod Name] and save your image in Textures > Things > Pawn > Humanlike > Hair.

Follow the naming conventions of 'hair_south', replacing 'hair' with a visual identifier. Such as Mullet_south or Mohawk_south.

Note:
● Don't use spaces.
● Don't use any special characters other than _ and -.
● Ensure that the direction is written in lowercase only.
● Your image must be a png.

Once exported, repeat the same process using the north, east and west templates. When all 4 directions have been completed, you should have 4 files in your Hair folder that look something like these:

Programming
The programming side of creating your hair mod can be done before, during or after you've created the visual assets. There are two .xml files we'll be working with.


About
Go into [My Mod Name] > About and right-click 'About.xml'. Open it in Notepad++ and you'll see the mod metadata. Between each set of tags (the bits that say <name> </name> etc.), is where you will input the following.

<name> - The name of your mod that will appear on the mods screen.



<author> - Your username.



<supportedVersions> - The versions of Rimworld that this mod will work with.



<packageID> - A unique ID that the game uses to identify your mod. Two mods cannot have the same packageID, even though they can have the same name. Your packageID should follow the naming pattern of <packageId>AuthorName.ModName.Specific</packageId>

For example:
<packageId>Roo.Example.Hairs</packageId>



<description> - The text that appears when your mod is selected in the mods screen.




Other tags can be added to your About file if you wish, but these are the key few. For information on more tags, click here[rimworldwiki.com].

Here's what a completed About file looks like:

<?xml version="1.0" encoding="utf-8"?> <ModMetaData> <name>Roo's HD Hairstyles</name> <author>Rooboid</author> <supportedVersions> <li>1.0</li> <li>1.1</li> <li>1.2</li> <li>1.3</li> <li>1.4</li> </supportedVersions> <description>Adds 33 male hairstyles and 39 female hairstyles to the game. This pack aims to give a varied distribution of hairstyle types without sticking to one main theme- such as within my other hair mods. If you're looking for something more specific, feel free to check out my other hair mods on the Steam Workshop! </description> </ModMetaData>




HairDefs
Go into [My Mod Name] > Defs > HairDefs and open Hairs_MyModNameDef.xml in Notepad++. This file contains all the details for each hairstyle you make.


<HairDef> - Between these two tags are the details for one hairstyle. Within this file, you'll need to open and close a new set of HairDef tags for each style.



<defName> - The ID of the hairstyle that the game uses. It can't match that of any other hairstyle, so include a unique prefix before the hairstyle name, such as the mod initials or your username. Don't use spaces.

For example:
<defName>RB_Mohawk</defname>



<styleGender> - What gender of pawns this hairstyle will spawn on. Before Rimworld 1.3, this was called <hairGender>. The options are:

Any
Appears on any gendered pawns.
Male
Appears only on males.
MaleUsually
Can appear on any pawns, but mostly male ones.
Female
Appears only on female pawns.
FemaleUsually
Can appear on any pawns, but mostly appears on females.

Note:
● Pawns can still be manually given hairstyles not assigned to their gender by using mods or the Styling Station introduced by the Ideology DLC.



<Category> - What category this hairstyle will be sorted into within the Ideology DLC. This was added in Rimworld 1.3. Your hairstyle may only go into one category. If unassigned a category, it will be auto-sorted into 'Misc'. The options are:

Minimal
Tribal
Cannibal
Punk
Urban
Rural
Royal
Soldier
Moustache
Misc



<texPath> - Where the game will look for the hairstyle textures, and what filename it'll look for. If your hair's graphics are called 'Mohawk_south.png', 'Mohawk_east.png' etc, you'll just need to write 'Mohawk' at the end of the path.

For example:
<texPath>Things/Pawn/Humanlike/Hair/Mohawk</texPath>



<styleTags> - What kind of pawns this hairstyle will spawn on. Before Rimworld 1.3, this was called <hairTags>. You can include as many tags as you like. The options are:

Wild
Appears on wild pawns with certain ideological precepts (e.g Nature Primacy).
Tribal
Appears on pawns that use the Corunan style (e.g tribes).
Rural
Appears on pawns that use the Rustican style(e.g outlander unions).
Urban
Appears on pawns that use the Astropolitan style (e.g the player faction).
Royal
This tag has to be used in conjunction with Urban or Soldier to work. If a hair has both the Royal and Urban tags, it'll appear on noble pawns of the empire faction- such as the Stellarch. If the hair has both the Royal and Soldier tags, it'll appear on fighter pawns from the empire faction.
Punk
Appears on pawns that use the Kriminul style (e.g pirate factions).
Soldier
Appears on fighter pawns across multiple factions.
HairLong
Xenos with the Hair_LongOnlygene.
HairShort
Xenos with the Hair_ShortOnlygene.

Within your Def file, a new set of <HairDef> tags needs to be made for each hairstyle your mod adds. Here's what a completed HairDef file containing two hairstyles looks like:

<?xml version="1.0" encoding="utf-8"?> <Defs> <!-- Angel Wings Hairstyle --> <HairDef> <defName>Roo_HD_Hair_AngelwingsL</defName> <label>RBHDL Angel Wings</label> <styleGender>Female</styleGender> <category>Urban</category> <texPath>Things/Pawn/Humanlike/Hair/LHDHAngelwings</texPath> <styleTags> <li>Urban</li> <li>Rural</li> <li>Royalty</li> </styleTags> </HairDef> <!-- Brave Hairstyle --> <HairDef> <defName>Roo_HD_Hair_BraveL</defName> <label>RBHDL Brave</label> <styleGender>Any</styleGender> <category>Tribal</category> <texPath>Things/Pawn/Humanlike/Hair/LHDHBrave</texPath> <styleTags> <li>Punk</li> <li>Rural</li> <li>Tribal</li> </styleTags> </HairDef> </Defs>
Testing
Автор сообщения: some guy
10% of the work takes 90% of the time. Testing your hairstyle mod takes 150% of the time.

The first part of testing your hair mod is making sure that it works on your end. If you're planning on uploading your mod to the Steam Workshop, it'll save you a lot of post-upload troubleshooting to make sure that it works for others too.



Step 1: Moving Over Your Files to the T E S T I N G Z O N E

To test your mods, you'll need a local copy of it saved into your Rimworld Mods folder. Go into your Steam Library, right click Rimworld, and click 'properties'. You'll then want to click 'Local Files' on the popup, and then 'browse'.

Windows Explorer or Mac-Whatever will have opened your Rimworld folder. Enter the 'mods' folder. Copy your [My Mod Name] (or whatever you've named it) folder into the mods folder.



Step 2: Enable Your Mod and Restart Rimworld
Open Rimworld, and enable dev mode in the options. Next, go into the mods menu. I recommend disabling all other mods other than any official DLC. Your mod should be there somewhere, accompanied by a folder icon to indicate that this mod is indeed a local copy. The preview image should just be a boring old preview with some bald pawns on it for now. Enable your mod, restart Rimworld, and pray.

Step 3: Startup Errors ❌
Upon restart, it's possible that you'll be passive-aggressively greeted by the debug log. If so, check the errors it lists to see if any of them are caused by your hair mod.

Error
Fix
Mod [My Mod Name] is missing packageID in About.xml!
You need to add a Package ID into the About file. Scroll back to the 'Programming' section for help.
Mod My Mod Name <packageId> (UniqueModIdentifier) is not in valid format.
Your packageID should follow the naming pattern of <packageId>AuthorName.ModName.Specific</packageId>. Go into your About file and change your packageId.
Mod [My Mod Name] is missing supported versions list in About.xml!
You need to add the versions of Rimworld that your mod supports into the About file. Scroll back to the 'Programming' section for help.
Could not resolve cross-reference: No RimWorld.StyleItemCategoryDef named X found to give to RimWorld.HairDef Y
The hairstyle (Y) uses a none-existent category (X) within the Defs.
Unknown Parse Failure
The file listed at the end of the file path contains a syntax error. This could be something as simple a tag not being closed.

Note: These are not of the all possible errors, just some very common ones.



Step 3: Gameplay Errors ❌
We've made it past the startup screen. Now it's time to test our mod in-game. Create a new save and use a styling bench (or mod) to check out your hairs in action. Got errors? No problem:

Error
Fix
When my hair is on a pawn, they appear bald.
Discriminating against baldness isn't OK. But this means that Rimworld can't find the textures. Even just one of the sprites of that hair being wrong can make this happen. Check your hairs' file names and that they're consistent with the texture path within your Defs.
Some of the hairs are facing the wrong way.
Check your file names, that they're all named with the correct directions accordingly. Remember, don't flip hair graphics to make the hair_west sprite. The game flips them automatically.
A pawn that had X hairstyle no longer has it when I reload my save.
The hair defName has changed and the game can't find the old defName.
The hairstyle is using a different hairstyles' graphic.
Two of your hairs are sharing the same defName so the game doesn't know which one to load. Make sure defNames are all unique for each hair.
The top/bottom/side of the hair is visibly cut off.
The hair texture has been drawn too close to the edges of the canvas. Shrink it down a little bit and try again.
The hair doesn't fit on the pawn.
All hairs should be designed for the 'average' head shape. Rimworld will automatically scale down hairstyles to fit the 'narrow' head shape. Check that your hair textures fit the template included in the [Roo's Hair Tutorial] Template[drive.google.com].



Step 4: Finishing Off
Once you've finished the preliminary testing, sleep for a while. Yes, good. When you wake up, there are a few other testing tips you can follow to ensure that your mod is as polished as it can be.

● Use dev mode to spawn some raids and make sure your hairs are appearing on the right factions, if at all.
● If your hairstyle textures are 500px, install a HD pawn mod and Camera+ to make sure they're looking top notch during gameplay.
● Use mods such as Character Editor to quickly scroll through your created hairstyles.
● Install your usual mods and use your hairstyles alongside them in gameplay. You might notice further errors or things you'd like to change.
● Test your hairs on pawns of different head and body sizes.
● To ensure that the mod works for others, ask someone else to test your mod and bribe them with thrumbofur.
Packaging and Uploading
Who's Hair Modder(Legendary)? You're Hair Modder(Legendary)! All that's left to do now, is to get your mod ready for upload on the Steam Workshop.

Making A Preview
Remember that crusty, boring preview thumbnail in the mod screen? It's time to replace that with something a little more exciting. Important things to remember about your preview are:

● The mod preview image is stored in the About folder of your mod, alongside About.xml.
● The preview image in this folder will be seen on the mod screen in-game, and as the thumbnail for the mod in the Steam Workshop.
● As long as the ratio of your preview thumbnail is 16:9, there's no right or wrong way to create it.

If you're not sure where to start and you have downloaded the [Roo's Hair Tutorial] Template[drive.google.com], go into #Mod Creation Assets > [Thumbnail Template]. Here you'll find a handy template in both .psd and .png format. PSD's are Photoshop's native file type, but other image editing software can usually open them. If yours can't, don't worry, you can use the .png provided. None of these files require credit at all, so use them to your heart's content.


By changing the background colour, title and adding some of your hairstyles onto the mannequins, you can call this done and export it as a .png.

Once you've exported your file, replace the Preview.png in the About folder with your new thumbnail. Ensure that it's still called Preview.png. Do one last check to make sure your preview appears in the Rimworld mod menu. And BAM. Your mod. Is done.



Uploading Your Mod

When you're in the Rimworld mod menu, select your mod and then 'Upload to Steam Workshop'. Once it's up, it'll be publically hidden until you're ready to properly publish it. This gives you chance to populate your mod description with some key details, such as:

● What the theme of the mod is.
● If it has any mod dependencies or incompatibilities.
● FAQ's.

Tips and Special Thanks
Use your own work as a reference.


When you've completed the first sprite of a hairstyle, you can use it to help you draw the next sprites. Copy over the finished sprite to your next direction's template. Use planning lines to ensure that the features of your hairstyle line up when you draw it again.

You might work best illustrating all of the sprites first, then exporting them. Or you might work best starting with the east sprite, or the north sprite. Whatever works for you.


You don't need a hair_west sprite.


If you do not include a hair_west sprite, the game will automatically use the hair_east sprite and flip it accordingly. The only reason you might want to include a hair_west sprite is if the hairstyle is asymmetrical and thusly different when viewed from each side.







Special Thanks
I posted my first mod to the workshop in 2020 and had no idea what I was doing. A big thanks to those who helped me learn:

Zelan - For helping me test my hair mods, supporting me in writing this guide, and just generally being a huge help with everything.

Chicken Plucker - For writing the OG [1.0] Create a Hair Mod - Chicken run tutorial guide. You beautiful legend.


Комментариев: 32
Anonymous Dragon 7 дек. 2024 г. в 14:10 
Verse.PawnRenderNode:EnsureInitialized (Verse.PawnRenderFlags)
Verse.PawnRenderTree:EnsureInitialized (Verse.PawnRenderFlags)
Verse.PawnRenderer:RenderCache (Verse.Rot4,single,UnityEngine.Vector3,bool,bool,bool,bool,System.Collections.Generic.IReadOnlyDictionary`2<RimWorld.Apparel, UnityEngine.Color>,System.Nullable`1<UnityEngine.Color>,bool)
RimWorld.PawnCacheRenderer:OnPostRender ()
RimWorld.PawnCacheRenderer:RenderPawn (Verse.Pawn,UnityEngine.RenderTexture,UnityEngine.Vector3,single,single,Verse.Rot4,bool,bool,bool,bool,UnityEngine.Vector3,System.Collections.Generic.IReadOnlyDictionary`2<RimWorld.Apparel, UnityEngine.Color>,System.Nullable`1<UnityEngine.Color>,bool)
RimWorld.PortraitsCache/PortraitParams:RenderPortrait (Verse.Pawn,UnityEngine.RenderTexture)
Anonymous Dragon 7 дек. 2024 г. в 14:09 
Failed to find any textures at ../../Textures/Things/Pawn/Humanlike/Hair/CB-LongPlain while constructing Multi(initPath=../../Textures/Things/Pawn/Humanlike/Hair/CB-LongPlain, color=RGBA(0.220, 0.141, 0.071, 1.000), colorTwo=RGBA(1.000, 1.000, 1.000, 1.000))
UnityEngine.StackTraceUtility:ExtractStackTrace ()
Verse.Log:Error (string)
Verse.Graphic_Multi:Init (Verse.GraphicRequest)
Verse.GraphicDatabase:GetInner<Verse.Graphic_Multi> (Verse.GraphicRequest)
Verse.GraphicDatabase:Get<Verse.Graphic_Multi> (string,UnityEngine.Shader,UnityEngine.Vector2,UnityEngine.Color)
RimWorld.HairDef:GraphicFor (Verse.Pawn,UnityEngine.Color)
Verse.PawnRenderNode_Hair:GraphicFor (Verse.Pawn)
Verse.PawnRenderNode/<GraphicsFor>d__67:MoveNext ()
Verse.PawnRenderNode:EnsureMaterialsInitialized ()
Verse.PawnRenderNode:EnsureInitialized (Verse.PawnRenderFlags)
Verse.PawnRenderNode:EnsureInitialized (Verse.PawnRenderFlags)
Anonymous Dragon 7 дек. 2024 г. в 14:09 
Hello, I followed this guide and get no errors upon startup. However, when randomizing a pawn, whenever it selects my hairstyle I get an error (as following)
I am by no means a programmer, so this doesn't make any sense to me. I was wondering if anyone knew what I was doing wrong???
For reference, I have no other mods running, I have the Biotech official DLC enabled, and I am on Linux.
I had to cut off some of the error message due to comment length.
천사 27 окт. 2024 г. в 10:04 
This tutorial perfectly works for 1.5 as well!! Thank you so much! It's genuinely informative!!!
thefrenchgremlin 12 авг. 2024 г. в 21:45 
can some one make a ronin pony tail for 1.5
violue 8 мая. 2024 г. в 4:27 
update: it is!
violue 26 апр. 2024 г. в 12:42 
Is this tutorial relevant for 1.5?
TurtleShroom 1 мар. 2024 г. в 20:55 
I already knew how to do the coding and drawing, but what I really found valuable was your tips on the RW art style, as well as explaining what each Tag actually means! My drawings are just okay , but stand out pretty from RW proper enough to notice. This is truly a Guide above the rest. Thank you for taking the time to write this.
말미잘 6 фев. 2024 г. в 19:26 
The ultimate hair style guide. Thanks to you, it was easy to understand. I appreciate it.
blitz 7 ноя. 2023 г. в 8:09 
Excellent guide. Well written guide to follow. Well done