A simple production-orientated Hair System

August 16, 2017

In this article we will shed some light on a simple production oriented Hair system built with Fabric Engine 2.6.0.

When one of our customers started the research for an upcoming production we recognized it was a good sample candidate to showcase some of the new features in Fabric Engine. The focus was not to create a perfect hair simulation system but to design a solution that would fit the needs of this particular production.

The system is designed as a new geometry type containing hair guides, which are used to interactively style the hair. From the guides, NURBS curves and polygon meshes can be generated for rendering.

The results of this project are available as part of the Fabric Engine 2.6 release – including the KL code, Canvas nodes and samples for Canvas and Maya.

Let’s cover the requirements, development process and artistic results in detail:

Requirements

Our friends at TomSporer.de recently were involved in a commercial for a company selling hair and cosmetic products. The requirements for the project included:

  • Styling of semi-realistic long and curvy hair
  • Generation of cylinders / tubes with UVs for each hair strand (volume required for subsurface scattering)
  • The ability to tweak each resulting hair – not only the guides
  • Integration inside Maya
  • Still images – no animation or simulation
  • Very short turnaround time (5 days)

Tom and his team looked into off-the-shelf solutions like Maya. One of the initially considered approaches was rigging up a single hair strand with all of the required geometric controls and then duplicating it accordingly. However, given the short turnaround time and the large amount (>5000) of strands required, the team started to look for a custom procedural solution.  Fabric Engine was the selected system for the job.

Design and implementation in Fabric Engine

First of all, we decided on the nomenclature and wording. We introduced the concept of a HairGuide – a simple linear curve which is used to drive the shape of the hair. The guide is limited to 5 points for performance reasons – while the implementation allows more points we didn’t need more for the shapes desired for the project. A guide also stores an index called the layer. Most hair systems only have one layer of guides – we wanted to allow users to define multiple layers of proceduralism when working with hair. We introduced a new data structure for the guide (HairGuide) as well as the high level data structure to manage all of the guides, called the HairSystem. To avoid name clashes with existing solutions we used the PS (ProductionSamples) namespace for all data structures in the project.

We then added additional high level nodes utilizing the Fabric Engine Blocks feature. With blocks, users can implement logic without having to think about the complex high level data structures – in this case we added several nodes to allow users to add more guides procedurally. In the image below you can see two guides being placed manually (yellow) and a second layer being placed procedurally using a block (orange). We also added nodes to create guides from curves (for example coming from Maya) to more easily integrate with existing production workflows.

Once the generation of guides was under control we added nodes for deformation. For this we used two approaches: Per vertex deformation and per segment deformation. Vertex deformation is useful if you want to shape the strand overall and don’t care about certain properties such as length and placement. The image below shows a simple sinus curve acting as a deformer.

The second approach involved taking apart the guide into its segments (the vectors connecting one point to the next), then allowing the user to specify the deformation for each segment (for example rotating it) and finally putting the guide back together. This allows the artists to quickly design good looking deformers for the hair guides without having to worry about the structure of the guide. For this we utilized the Blocks feature in Fabric as well. The image below uses a profile along the strand of each hair to twist and turn the guide slightly.

After creating nodes to define guides both manually and procedurally, and deforming them per vertex or segment, we created additional nodes to clone the guides. This enables users to create complex structures out of single guides. The combination of the clone nodes with the deformers empower users to create hair clumps as seen below. The yellow guides (layer 0) are the original guides – while the green guides (layer 1) are the clones with an additional deformer.

As a next step we added a node (KL function) to generate curves out of the guides. The generated NURBS curves are smooth and can be resampled later for higher point counts – the main focus here however was to be able to generate a smooth curve for later generating a mesh. The curves can additionally be deformed using the same approaches already deployed for deforming guides.

The mesh generator can use the AnimX-based animation curves in Fabric Engine for defining profiles in the UI. This provides fine-grained control to artists when driving the resulting shape. The image below shows the generated curves on the left and the resulting meshes on the right. Each mesh supports vertex colors as well as procedural texture coordinates.

A typical limitation associated with procedural solutions is directability – the art director might want to specify the look and shape of individual hairs. Tom has lots of experience when working with commercial agencies – and he drove the requirement for being able to edit anything. Most systems allow you to style the guides only – while relying on pure proceduralism for the hair strands. We added a custom tool using the new Manipulation framework in Fabric Engine 2.6 to allow artists to tweak each resulting hair and provide maximum control. The custom tool allows users to tweak each control point of each hair guide as needed. Since the tool integrates into the graph as a node, users can have multiple tools at multiple levels in the graph – or even store multiple styles as multiple nodes and switch between them.

Conclusion

The resulting hair system is, by no means, competing with vertical products in the market. However, It served the project well and can be used for a large range or visual effects (as you can see from the resulting imagery). Features such as the Animation Curve Editor, Custom Manipulators and Blocks in Fabric Engine were key aspects for turning around the project in time and providing sufficient flexibility to the artists.

  • Implemented in 1.5 days
  • Art direction time 2.5 days

Tom Sporer said, “Fabric Engine gave us a highly customizable and flexible setup.  We were able to meet the client needs with the ability to style the overall shape of the hairs, group the strands, and still edit the shape of every single hair too!”

Thanks to Tom Sporer and Dominic Werner for providing the system and the beautiful imagery!