Hair. It’s probably one of the most difficult things for me to 3D model. Whether I’m trying to go for more chunky, anime look for my hair or planar hair, it’s a challenge. To try and remedy this, I created a tool a few months ago — maybe even over a year — that I called HairKit. This post is about this tool, a brief overview, and where it is now.
The following diagram demonstrates how the different components of HairKit come together.
Hair Kit Main is the main component that creates the Unity3D mesh. This is made up of a set of Hair Kit Lines which require a Hair Kit Shape and a set of Hair Kit Line Points. Finally, there is an optional component, HairKit Smoothed Line Helper, which can create a set of Hair Kit Line Points with smooth interpolation and spacing.
The HairKitMain component is pretty straightforward. When adding it to an object, it’ll automatically add a MeshFilter and a MeshRenderer component to the GameObject. It will also create a new mesh named <GameObject’s Name> mesh. Before lines can be rendered, a HairKitShape and HairKitLine needs to be set up.
HairKitShape defines the shape that will be used when making lines. It uses the children of this GameObject to define the shape. The Gradient is used by the gizmo system to draw the shape. The UV Percentages, which will be used for the UV layout of the different meshes are based on the distance between points. You can automate this based on the by having Automate UV Percentages checked; if you uncheck it, it’ll force the UV Percentage array to the correct number but you can set the values as you wish.
You can rename the children of this game object more cleanly by pressing the Renamed Children Button.
You can also create an enclosed, circular shape by Pressing “Create Shape.” The resulting shape will have the number of points specified by Count, minus one, and a radius of that specified. You cannot set count lower than 3. So, to create a line, use 3 points, a triangle 4, etc.
The previous image showcases some examples of shapes created by different HairKitShape configurations.
One you have a satisfactory shape, it’s time to start creating the line.
HairKitLine is a pretty full component. For the quickest approach, assign a HairKitShape and then press “Add Child.” This will create a HairKintLinePoint.
Each point can then add a child or a sibling, which will be added to the line itself.
Locking a point allows the parent to be moved around without disrupting the position of the point.
The following .gif demonstrates adding a set of points:
Once you have a line you are happy with, you can add it to the Hair Kit Main see the shape itself.
HairKitLine has the most fields to edit, but for now, this covers the basics of the HairKit system. The HairKitLineSmoother
Saving the Mesh
Once you are happy with the mesh, you can save out the mesh using the context menu of the Hair Kit Main component.
You can either Clone and Save the mesh or Skin the mesh.
Clone and Save will create a new GameObject except this game object will not have a HairKitMain component and the Mesh Filter will now refer to a newly created asset.
Skin is a bit more difficult. The bones have to be set up in a specific way, cascading child-by-child for this to work properly.
Either way, the mesh should be saved out because the update methods used by the HairKit components are not the most efficient and should not be included in a final game.
Was It Useful?
In the end, I essentially recreated 3D Max’s loft tool; I realize now that this tool should probably be renamed LoftKitTool, but the original intent was for hair. Recently, however, I discovered I can use it for creating trails in my current game rather quickly. The following are some .gif of it being used.
Anyway, I wanted to share about this as I may release this one day as a Unity Package or maybe even in the Unity Asset store. Anything you’d like to see in the tool, if you would pay for said tool or how much, or any comments will be greatly appreciated.