HairWorks Authoring Considerations
Simulated hair and fur is quickly becoming an amazing feature to add increased visual fidelity to games these days. It’s been a standard feature in offline visual effects for years and has continued to become more impressive. Films such as Mighty Joe Young, King Kong, Avatar, and Rise of the Planet of the Apes have all used hair and fur technologies on entirely computer-generated characters to sell a more complete immersion into the story being told. A less obvious use of this technology in film has been for CG stunt doubles. Now the time has come where hair and fur has made its way into the gaming arena with real-time, dynamically simulated hair and fur.
HairWorks has a bit tighter budget than its offline siblings. In a film, a frame can take anywhere from a few minutes to a few hours to render. In a game, HairWorks has to render the frame in a few milliseconds. This takes an incredible amount of raw GPU horsepower. A GTX 970 or better would typically do this effect justice.
Before designing and authoring your HairWorks asset, a few questions should be explored.
- What is the budget for this character effect?
- Artistically, is the hair/fur going to be high-resolution/realistic or stylized?
What is the usual distance from the camera to the character?
- Are there close ups?
What are some key attributes of the hair/fur?
- Is it wavy, clumpy, free-flowing, or really stiff?
- Is it very dense with good coverage or is it loose and sparse?
- Is it dry, wet, shiny, or dull?
- If the asset is to have hair, does it need to collide with other body parts on the character?
For the purposes of this article, we’ll say the budget for a character’s HairWorks effects, at medium gameplay distance, is roughly 3-5ms (FX budget can vary per game engine/per game, per asset). This budget will rise and fall depending on the character’s distance from camera and how many characters are intended to be onscreen at once.
Listed is a brief set of authoring considerations for artists that should result in more efficient HairWorks assets, which will be discussed further below:
- Using continuous distance and detail LOD helps keep assets as efficient as possible at various camera distances.
Tessellation based attributes
- Number of CVs (control vertices) along an authored guide curve
- Usage of Spline Multiplier attribute
- Density usage for desired coverage should balance between performance budget and art aesthetic.
- Shadow quality should be chosen based on performance budget versus art quality.
- Only use attributes when needed for a specific style or behavior. Set to 0 otherwise.
- Collision Shapes versus Backstop
Possibly the biggest consideration when developing your asset is knowing how far your character will be from the camera. You will need to design the asset to be efficient at this distance. If your character is always going to be far from the camera, there is no reason to make thousands of life size hairs on it. That’s wasteful. If your character is always going to be close to the camera, then the hairs need to be thinner and denser to achieve a more lifelike effect. Sometimes, the asset will need both of these to succeed.
In these storyboard images, the character is at various distances from the camera: close up, medium, and far. All of these require a different level of asset tuning for maximum efficiency. For example, an asset that is generally far from the camera can use thicker strands with fewer CVs, set at a lower density. A character that is close to the camera must have thinner hairs, meaning the hair should be more dense, with more CVs per strand. Also keep in mind that thinner hairs require better anti-aliasing to keep them looking nice and smooth.
After the hairstyle has been groomed and exported to a series of guide curves, the artist chooses how many CVs to sample the guide curves at. This is a very important decision as it impacts the fidelity and performance of the asset. An artist should sample at the fewest number of CVs needed for a hairstyle. More CVs mean longer, more complex curves can be achieved. However, these CVs can potentially be multiplied using tessellation twice.
HairWorks utilizes two types of tessellation to help create smooth strands that provide good coverage on the character.
The first type of tessellation adds vertices in-between the control points on each strand, making the strands more smooth. This helps with style attributes, such as clumping and waviness. The number of additional points is determined by the Spline Multiplier attribute on an asset. A value of 1 uses the same CVs as on the authored guide curves. A value of 4 multiplies the original set of CVs by 4 and spaces them evenly, resulting in smoother, more stylistically flexible strands. Essentially, this is used as strand smoothing to keep from having faceted, un-life like strands.
The second type of tessellation adds additional interpolated strands between the artist’s groomed guide strands. This is controlled through the density attribute on a hair asset. The density can be multiplied with a texture map to more effectively and efficiently utilize dense areas of interpolation. Tessellation is used to help create efficient hair assets with small memory foot prints.
There are also some secondary authoring benefits to this workflow. Style attributes, such as waviness and clumping, can be tweaked live with a handful of spinners without having to go back and edit guide curves. Also, by using efficient tessellation, the artist needs only to groom the least number of guide hairs necessary for a particular hairstyle, with a reduced number of CVs per strand. This means that the artist has to manage fewer strands to achieve many hairstyles.
Using the HairWorks LOD system allows an asset to blend smoothly between all distance-defined settings dynamically. Special attention should be given to the hair asset at the camera distance that the character will be at the majority of the time. Additionally, the distances that the various LODs take effect should be chosen wisely.
Shadow quality is another factor that should be considered when authoring HairWorks assets. As with any other shadow element, a larger shadow map is more accurate, but also more expensive. The appearance and characteristics of shadows are quite specific to each game engine, rather than to the HairWorks viewer, therefore this element will look and perform differently with each one.
Usage of the material attributes in HairWorks should be limited to only when it is necessary. While many of these attributes are rather inexpensive, there is an optimization pass that removes unused attributes for a particular asset. When fractions of a millisecond count, every optimization could end up being meaningful.
For short hair and fur, an automated collision, referred to as backstop, is more efficient than collision shapes. Although, HairWorks collision shapes, much like GameWorks Clothing shapes, are very efficient to begin with.
The quality and expense of anti-aliasing changes based on a few factors. Anti-aliasing is more expensive when hairs are thinner or take up more screen space. When hairs are thicker or the game’s resolution is higher, such as 4k, less anti-aliasing is needed.