When utilizing HairWorks, there are a number of things that can affect the asset’s performance. This guide will serve as an exploration into some of those factors and discuss some options based on the needs of the project.
The Asset’s Attributes
Before designing and authoring your HairWorks asset, a few questions should be explored:
For the purposes of this guide, we’ll say the budget for a character’s HairWorks effects, at medium gameplay distance, is roughly 3-5ms*. 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.
FX budgets can vary per game engine, per game, per asset.
Performance Impacting Considerations
Listed is a brief set of authoring considerations for artists that should result in more efficient HairWorks assets, which will be discussed further below:
Possibly the biggest consideration when developing your asset is knowing at what distance from the camera the character/object will be. 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 tesselation twice.
HairWorks utilizes two types of tessellation to help create smooth strands that provide good coverage on the character.
The first type of tesselation adds vertices in-between the control points on each strand, making the stands 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, unlifelike strands.
The second type of tesselation 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. Maxwell series GPUs are very good at this type of tesselation and it 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 tesselation, 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.