Hair Simulation
- Snapchat: fully supported
- SPECS: not supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- SnapchatFully supported
- SPECSNot supported
- Camera Kit WebNot supported
- Camera Kit MobileNot supported
You can find this in the home screen of Lens Studio.
The Hair Simulation sample project utilizes the Hair Component to simulate a wide range of beautiful and unique hairstyles with realistic lighting and physics.
Guide
In this guide we’ll cover:
- The Bald ML Component
- Hair Simulation
- Hair Blur Settings
- Optimization Controller and Optimization Tips
The Bald ML Component
The Back Orthographic Camera in the project contains the ML bald model, it is used to block off existing hair from users, creating a smooth look when combined with the hair component.
In the OptimizationController script, the ML Bald Layer can be toggled based on FPS and the ML performance index of the device (when Disable ML on Fallback is checked), check out the section about Optimization below to learn more.
Hair Simulation

Everything related to hair simulation is placed under the Hair Camera with according layer. In here you’ll find the Head object that contains the head collider and neck occluder, the Hair object (under Hair Components) which contains all hairstyles, the Facial Hair object which contains a simulated beard and mustaches, and all the main settings scripts.
Feel free to toggle and explore different hairstyles and beard styles included in this project.
Hair Blur Settings
The HairBlurController script is crucial for simulating smooth looking hairstyles. Most of these hairstyles would not look nearly as good without the HairBlurController script.
The script uses a special render target combined with a second render target on each material to apply a layer of smoothness catered to hair’s direction.
Because of this method of blurring, all other items to be used with the hair simulation project would either need to be placed in a separate camera, or would need to have a second render target with a special color in its material settings (check out the Shader node on all materials labeled xx_MRT). Otherwise the object will be blurred by the HairBlurController script!

Try adjusting the Smoothness parameter to see how blurriness affect the hairstyle.
You can also adjust hair smoothness with the Blur Multiplier parameter on each hair’s material, see detailed explanations under the Hair Materials section below.
Optimization Controller and Optimization Tips
The OptimizationController script sets up optimization levels for different devices.
The OptimizationType variable determines the method of optimization being used.
Setting OptimizationType as MLDeviceIndex would turn on fallback mode on devices whose global.deviceInfoSystem.performanceIndexes.ml value is lower than MLIndexThreshold (and disable bald ML too, if Disable ML on Fallback is checked). A higher value of MLIndexThreshold means more devices have fallback mode turned on when the Lens is pushed to public.
FPSThreshold means the Lens would turn on fallback mode if fps is lower than the FPSThreshold regardless of type of the device.
Setting OptimizationType to Combined means it will use both methods in a way that only when a device has a global.deviceInfoSystem.performanceIndexes.ml value higher than the MLIndexThreshold and also an fps higher than the FPSThreshold value.
Optimization Tips
The hair component can be quite performance heavy, especially for slower devices. To make sure your Lens can run smoothly on most devices, here are some tips on keeping your hairstyle optimized:
Keeping low resolution for all hair textures
Make sure your hair alpha texture has a resolution that displays all the details without being unnecessarily big. Usually a resolution from 256 pixels to 512 pixels would suffice depending on the hairstyle. Feel free to go into the compression setting on the texture and choose Low Size to further optimize the texture.
All textures for hairstyle maps such as Lit Lookup map, Direction map and Intensity map can also have a bare minimum resolution of around 34 × 34 pixels in order to achieve a standard visual result.
Keep the Hair Resolution in a range of 5 to 20
The performance for Lenses with the hair component is heavily influenced by the Hair Resolution number and amount of strands of the original hair model. Higher results of Hair Resolution multiplied by the amount of hair strands can cause lag on some low-end devices.
We recommend keeping the Hair Resolution as low as possible. Depending on the hairstyle, some straight and short hair can keep its authentic look at a low resolution, while some long curly hair might need a higher resolution.
Previewing Your Lens
You’re now ready to preview your Lens! To preview your Lens in Snapchat, follow the Pairing to Snapchat guide.