Hair
The Hair Master Stack enables you to render hair and fur in the High Definition Render Pipeline (HDRP). To create a realistic looking hair effect, it uses layers called hair cards. Each hair card represents a different section of hair. If you use semi-transparent hair cards, you must manually sort them so that they are in back-to-front order from every viewing direction.
Creating a Hair Shader Graph
To create a Hair material in Shader Graph, you can either:
Modify an existing Shader Graph.
- Open the Shader Graph in the Shader Editor.
- In Graph Settings, select the HDRP Target. If there isn't one, go to Active Targets, click the Plus button, and select HDRP.
- In the Material drop-down, select Hair.
Create a new Shader Graph.
- Go to Assets > Create >Shader Graph > HDRP and click Hair Shader Graph.
Hair Material Types
HDRP’s Hair Master Stack has the following Material Type options:
- Approximate: This mode requires you to adjust nodes to suit the lighting in your scene.
- Physical : This mode automatically produces physically correct results.
Considerations for choosing a Material Type
This table explains the conditions under which you might prefer to choose the Physical or Approximate hair Material Types:
Material Type | GPU requirements | Geometry compatibility | Compatible with Path tracing | Hair tones |
---|---|---|---|---|
Approximate | Moderate | Hair cards. | No. For more information, see Path tracing. |
Works with all hair tones. However, it doesn't give light hair a volumetric appearance. |
Physical | High | Hair cards and hair strands. | Yes. However, path tracing is not compatible with ribbons. For more information, see Path tracing. |
Works with all hair tones. Gives lighter hair tones a volumetric appearance when you use multiple scattering |
The Approximate hair Material Type
The Approximate Material Type mimics the characteristics of human hair. It is based on the Kajiya-Kay hair shading model. HDRP computes this model faster than the Physical Material Type because it is less resource intensive.
The Approximate model doesn’t automatically look realistic in every lighting setup. This means you need to adjust the blocks in the Fragment context to suit the lighting environment in your scene.
The Approximate model is best for darker hair tones. For best results with lighter hair tones, use the Physical model.
The Physical Material Type
The Physical Material Type automatically creates physically correct results in any light environment. It accurately accounts for the amount of incident light to scatter within a hair fiber (known as an energy-conserving hair model). This means the Physical model works correctly in any lighting environment.
This model adds the following nodes in the Fragment shader:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Radial Smoothness | Controls the internal scattering of light paths and the amount of light the hair fiber absorbs. | • Material Type set to Physical | 0.7 |
Cuticle Angle | The angle (in degrees) that the scales on a hair fiber tilt from the strand direction. For human hair, this value is usually between 2 to 3 degrees. Use this property to “shift” the highlight. | • Material Type set to Physical | 3 |
Change the Base Color block to define the color of the hair.
The Physical Material Type is based on the Marschner human hair fiber reflectance model.
Multiple Scattering
Multiple scattering creates the appearance of light scattering through thousands of hair strands. This gives lighter hair tones a volumetric appearance. To enable multiple scattering in your scene, select a Scattering Mode option.
To select a Scattering Mode option:
- Open the Graph inspector.
- Set the Material Type to Physical.
- Set the Geometry mode to Strands.
- Open the Advanced Options section.
- Select Scattering Mode.
The Scattering Mode options appear when you select the Physical material type:
Property | Description |
---|---|
Physical | Physically simulates light transport through a volume of hair (multiple scattering). This feature is not available for public use yet. |
Approximate | Estimates the appearance of light transport through a volume of hair (multiple scattering). This mode does not take into account how transmittance affects the way light travels and slows through a volume of hair. It also ignores the effect that a hair's roughness has on the spread of light. |
Geometry Type
You need to select a geometry type in your shader that reflects the geometry you use to represent hair. This allows HDRP to make correct assumptions when it computes the shading model. You can use multiple types of geometry to render hair, but the Hair Master Stack is only compatible with the following geometry types:
- Cards: Hair cards display high-resolution hair textures on individual pieces of simplified geometry. Card geometry is compatible with the Physical and Approximate Material types.
- Strands: Hair strand geometry represents each individual hair fiber in the shape of tube geometry or ribbons. Strand geometry is compatible with the Physical Material Type.
The hair card method is a simple and efficient way to render hair for games, and doesn’t demand a lot of resources from the GPU. We recommend cards where the user experience will not be negatively impacted by it. For example, for secondary characters, and even as a lower level of detail for main characters. Use strands only for main characters.
Select a geometry type
To select the geometry type that your shader uses:
- Open your Hair shader
- In the Graph inspector, open the Advanced Options dropdown
Select a
Geometry Type
option.
Contexts
This Master Stack material type has its own set of Graph Settings. Because of the relationship between settings and Blocks, this has consequences on which Blocks are relevant to the Graph. This section contains information on the Blocks this Master Stack material type adds by default, and which Blocks set properties for this Master Stack material type's Graph Settings.
For more information about the relationship between Graph Settings and Blocks, see Contexts and Blocks.
Vertex Context
Default
When you create a new Hair Master Stack, the Vertex Context contains the following Blocks by default:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Position | The object space vertex position per vertex. | None | CoordinateSpace.Object |
Normal | The object space vertex normal per vertex. | None | CoordinateSpace.Object |
Tangent | The object space vertex tangent per vertex. | None | CoordinateSpace.Object |
Relevant
Depending on the Graph Settings you use, Shader Graph can add the following locks to the Vertex Context:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Tessellation Factor | The number of subdivisions that a triangle can have. If you want more subdivisions, set this to a higher value. More subdivisions increase the strength of the tessellation effect and further smooths the geometry. Note that higher values also increase the resource intensity of the tessellation effect. To maintain good performance on the Xbox One or PlayStation 4, do not use values greater than 15. This is because these platforms cannot consistently handle this many subdivisions. A value of 1.0 mean no tessellation. | • Tessellation enabled | 1 |
Tessellation Displacement | The world space displacement to apply to the world position of mesh vertices after the tessellation process. It is recommended to displace along the world space normal with a displacement map, the displacement map must be sample with a Sample Texture 2D LOD, regular Sample Texture 2D isn't supported. | • Tessellation enabled | CoordinateSpace.World |
This Master Stack material type adds all its Vertex Blocks to the Vertex Context by default and has no extra relevant Blocks.
Fragment Context
Default
When you create a new Hair Master Stack, the Fragment Context contains the following Blocks by default:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Base Color | The base color of the material. | None | Color.grey |
Normal Tangent Space | The normal, in tangent space, for the material. | • Fragment Normal Space set to Tangent | CoordinateSpace.Tangent |
Bent Normal | The bent normal of the fragment. HDRP uses bent normal maps to simulate more accurate ambient occlusion. Bent normals only work with diffuse lighting. | • Material set to Eye, Fabric, Hair, Lit, or StackLit | CoordinateSpace.Tangent |
Hair Strand Direction | The direction that hair flows, from root to tip, when modelling with hair cards. | • Material set to Hair | Vector3(0, -1, 0) |
Transmittance | The fraction of specular lighting that penetrates the hair from behind. This is on a per-color channel basis, so you can use this property to set the color of penetrating light. Set this to (0, 0, 0) to stop any light from penetrating through the hair. Set this to (1, 1, 1) to have a strong effect with a lot of white light transmitting through the hair. | • Material set to Hair | Vector3(0.3, 0.195, 0.09) |
Rim Transmission Intensity | The intensity of back lit hair around the edge of the hair. Set this to 0 to completely remove the transmission effect. | • Material set to Hair | 0.2 |
Smoothness | The material's smoothness. Every light ray that hits a smooth surface bounces off at predictable and consistent angles. For a perfectly smooth surface that reflects light like a mirror, set this to a value of 1. Less smooth surfaces reflect light over a wider range of angles (because the light hits the bumps in the microsurface), so the reflections have less detail and spread across the surface in a more diffused pattern. | None | 0.5 |
Ambient Occlusion | The material's ambient occlusion. This approximates occlusion for a fragment on a GameObject’s surface that has been cast by details present in the Material but not the mesh geometry. A value of 0 means the fragment is completely occluded and appears black. A value of 1 means the fragment is not occluded at all, and the ambient color does not change. | None | 1.0 |
Alpha | The Material's alpha value. This determines how transparent the material is. The expected range is 0 - 1. | None | 1.0 |
Specular Tint | The color of the primary specular highlight. | • Material set to Hair | Color.white |
Specular Shift | The position of the primary specular highlight. | • Material set to Hair | 0.1 |
Secondary Specular Tint | The color of the secondary specular highlight. | • Material set to Hair | Color.grey |
Secondary Specular Shift | The position of the secondary specular highlight. | • Material set to Hair | -0.1 |
Emission | The color of light to emit from this material's surface. Emissive materials appear as a source of light in your scene. | None | Color.black |
Relevant
Depending on the Graph Settings you use, Shader Graph can add the following blocks to the Fragment Context:
Property | Description | Setting Dependency | Default Value |
---|---|---|---|
Alpha Clip Threshold | The alpha value limit that HDRP uses to determine whether to render each pixel. If the alpha value of the pixel is equal to or higher than the limit, HDRP renders the pixel. If the value is lower than the limit, HDRP does not render the pixel. The default value is 0.5. | • Alpha Clipping enabled | 0.5 |
Alpha Clip Threshold Depth Postpass | The alpha value limit that HDRP uses for the transparent depth postpass. If the alpha value of the pixel is equal to or higher than this limit, HDRP renders the pixel. If the value is lower than the limit, HDRP does not render the pixel. The default value is 0.5. | • Alpha Clipping enabled • Transparent Depth Postpass enabled |
0.5 |
Alpha Clip Threshold Depth Prepass | The alpha value limit that HDRP uses for the transparent depth prepass. If the alpha value of the pixel is equal to or higher than this limit, HDRP renders the pixel. If the value is lower than the limit, HDRP does not render the pixel. The default value is 0.5. | • Alpha Clipping enabled • Transparent Depth Prepass enabled |
0.5 |
Alpha Clip Threshold Shadow | The alpha value limit that HDRP uses to determine whether it should render shadows for a pixel. If the alpha value of the pixel is equal to or higher than this limit, HDRP renders the pixel. If the value is lower than the limit, HDRP does not render the pixel. The default value is 0.5. | • Use Shadow Threshold enabled | 0.5 |
Baked Back GI | The global illumination (GI) value to apply to the back face of the Mesh only. This replaces the built-in diffuse GI solution. This port only appears when you enable the Override Baked GI setting. |
• Override Baked GI enabled | 0.0 |
Baked GI | The global illumination (GI) value to apply to the front face of the Mesh only. This replaces the built-in diffuse GI solution. | • Override Baked GI enabled | 0.0 |
Depth Offset | The value that the Shader uses to increase the depth of the fragment by. This Block requires you to input the result of the Parallax Occlusion Mapping Node to produce a realistic result. | • Depth Offset enabled | 0.0 |
Normal Object Space | The normal, in object space, for the material. | • Fragment Normal Space set to Object | CoordinateSpace.Object |
Normal World Space | The normal, in world space, for the material. | • Fragment Normal Space set to World | CoordinateSpace.World |
Specular AA Screen Space Variance | The strength of the geometric specular anti-aliasing effect between 0 and 1. Higher values produce a blurrier result with less aliasing. | • Specular AA enabled | 0.0 |
Specular AA Threshold | The maximum value that HDRP subtracts from the smoothness value to reduce artifacts. | • Specular AA enabled | 0.0 |
Specular Occlusion | A multiplier for the intensity of specular global illumination. | • Specular Occlusion Mode set to Custom | 1.0 |
Radial Smoothness | Controls the internal scattering of light paths and the amount of light the hair fiber absorbs. | • Material Type set to Physical | 0.7 |
Cuticle Angle | The angle (in degrees) that the scales on a hair fiber tilt from the strand direction. For human hair, this value is usually between 2 to 3 degrees. Use this property to “shift” the highlight. | • Material Type set to Physical | 3 |
Strand Count Probe | The four coefficients of an L0 and L1 spherical harmonic near the shading position. Encoded with the strand count on the sphere of directions. | • Material Type set to Physical• Scattering Mode set to Advanced | 0.0 |
Strand Shadow Bias | The extent (in meters) at which the spline is biased toward the light to prevent scattering occlusion. | • Material Type set to Physical• Scattering Mode set to Advanced | 0.0 |
Graph Settings
Surface Options
Property | Description | ||
---|---|---|---|
Material Type | Specifies the type of Material the Hair Shader represents. The options are: • Approximate: This hair material type is suitable for hair card geometry and based on the Kajiya-Kay hair model. When you use this type, you need to adjust the blocks in the Fragment context to suit the lighting environment in your scene. • Physical:This hair material type is suitable for hair strand geometry and based on the Marschner hair model. This type is suitable for all light environments. |
||
Surface Type | Specifies whether the material supports transparency or not. Materials with a Transparent Surface Type are more resource intensive to render than Materials with an Opaque Surface Type. Depending on the option you select, HDRP exposes more properties. The options are: • Opaque: • Transparent: Simulates a translucent Material that light can penetrate, such as clear plastic or glass. For more information about the feature and for the list of properties each Surface Type exposes, see the Surface Type documentation. |
||
Rendering Pass | Specifies the rendering pass that HDRP processes this material in. • Before Refraction: Draws the GameObject before the refraction pass. This means that HDRP includes this Material when it processes refraction. To expose this option, select Transparent from the Surface Type drop-down. • Default: Draws the GameObject in the default opaque or transparent rendering pass pass, depending on the Surface Type. • Low Resolution: Draws the GameObject in half resolution after the Default pass. • After post-process: For Unlit Materials only. Draws the GameObject after all post-processing effects. |
||
Blending Mode | Specifies the method HDRP uses to blend the color of each pixel of the material with the background pixels. The options are: • Alpha: Uses the Material’s alpha value to change how transparent an object is. 0 is fully transparent. 1 appears fully opaque, but the Material is still rendered during the Transparent render pass. This is useful for visuals that you want to be fully visible but to also fade over time, like clouds. • Additive: Adds the Material’s RGB values to the background color. The alpha channel of the Material modulates the intensity. A value of 0 adds nothing and a value of 1 adds 100% of the Material color to the background color. • Premultiply: Assumes that you have already multiplied the RGB values of the Material by the alpha channel. This gives better results than Alpha blending when filtering images or composing different layers. This property only appears if you set Surface Type to Transparent. |
||
Receive Fog | Indicates whether fog affects the transparent surface. When disabled, HDRP doesn't take this material into account when it calculates the fog in the Scene. | ||
Depth Test | Specifies the comparison function HDRP uses for the depth test. | ||
Depth Write | Indicates whether HDRP writes depth values for GameObjects that use this material. | ||
Cull Mode | Specifies the face to cull for GameObjects that use this material. The options are: • Front: Culls the front face of the mesh. • Back: Culls the back face of the mesh. This property only appears if you disable Double Sided. |
||
Sorting Priority | Allows you to change the rendering order of overlaid transparent surfaces. For more information and an example of usage, see the Material sorting documentation. This property only appears if you set Surface Type to Transparent. |
||
- Back Then Front Rendering |
Indicates whether HDRP renders this material in two separate draw calls. HDRP renders the back face in the first draw call and the front face in the second. This property only appears if you set Surface Type to Transparent. |
||
Transparent Depth Prepass | Indicates whether HDRP adds polygons from the transparent surface to the depth buffer to improve their sorting. HDRP performs this operation before the lighting pass and this process improves GPU performance. | ||
- Transparent Depth Postpass | Indicates whether HDRP adds polygons to the depth buffer that post-processing uses. HDRP performs this operation before the lighting pass. Enabling this feature is useful if you want to use post-processing effects that use depth information, like motion blur or depth of field. | ||
Transparent Writes Motion Vectors | Indicates whether HDRP writes motion vectors for transparent GameObjects that use this Material. This allows HDRP to process effects like motion blur for transparent objects. For more information on motion vectors, see the motion vectors documentation. This property only appears if you set Surface Type to Transparent. |
||
Preserve Specular Lighting | Indicates whether to make alpha blending not reduce the intensity of specular highlights. This preserves the specular elements on the transparent surface, such as sunbeams shining off glass or water. This property only appears if you set Surface Type to Transparent. |
||
Alpha Clipping |
Indicates whether this material acts like a Cutout Shader. For more information about the feature and for the list of properties this feature exposes, see the Alpha Clipping documentation. |
||
- Use Shadow Threshold |
Indicates whether HDRP uses another threshold value for alpha clipping shadows. This property only appears if you enable Alpha Clipping. |
||
- Alpha to Mask |
Indicates whether to turn on alpha-to-coverage. If your Project uses MSAA, alpha-to-coverage modifies the multi-sample coverage mask proportionally to the pixel shader result alpha value. This is typically used for anti-aliasing vegetation and other alpha-tested shaders. This property only appears if you enable Alpha Clipping. |
||
Double Sided Mode | Specifies how HDRP renders the faces of polygons in the mesh geometry. The options are: • Disabled: Only renders one face of the polygons. • Enabled: Renders both faces of the polygons. In this mode, the normal of the back face is the same as the front face. • Flipped Normals: Renders both faces of the polygons. In this mode, the normal of the back face is 180° of the front-facing normal. This also applies to the material, which means that it looks the same on both sides of the geometry. • Mirrored Normals: Renders both faces of the polygons. In this mode, the normal of the back face mirrors the front-facing normal. This also applies to the material, which means that it inverts on the back face. This is useful when you want to keep the same shape on both sides of the geometry, for example, for leaves. For more information about this feature, see Double-sided. |
||
Fragment Normal Space | Specifies the normal map space that this Material uses. • TangentSpace: Defines the normals in tangent space. Use this to tile a Texture on a Mesh. • ObjectSpace: Defines the normals in object space. Use this for planar-mapping GameObjects like the terrain. • WorldSpace: Defines the normal maps in world space. |
||
Receive Decals | Indicates whether HDRP can draw decals on this material’s surface. | ||
Receive SSR | Indicates whether HDRP includes this material when it processes the screen space reflection pass. This property only appears if you set Surface Type to Opaque. |
||
Receive SSR Transparent | Indicates whether HDRP includes this material when it processes the screen space reflection pass. This property only appears if you set Surface Type to Transparent. |
||
Geometric Specular AA | Indicates whether HDRP performs geometric anti-aliasing on this material. This modifies the smoothness values on the surfaces of curved geometry to remove specular artifacts. For more information about the feature and for the list of properties this feature exposes, see the Geometric Specular Anti-aliasing documentation. |
||
Depth Offset | Indicates whether HDRP modifies the depth buffer according to the displacement. This allows effects that use the depth buffer (Contact Shadows for example) to capture pixel displacement details. | ||
- Conservative | Indicates whether HDRP only applies positive depth offsets in order to take advantage of the early depth test mechanic. | ||
Add Custom Velocity | Indicates whether HDRP changes the motion vector according to the provided velocity. HDRP adds the provided velocity (the difference between the current frame position and the last frame position) to the motion vector calculation. This provides correct motion vector calculations for any procedural geometry that HDRP calculates outside of Shader Graph. The motion vector still takes into account other deformations (for example, skinning or vertex animation). | ||
Tessellation | Tessellation Shaders subdivide the Mesh and add vertices according to the Material’s tessellation options, see the Tessellation documentation. |
Advanced Options
Property | Description |
---|---|
Specular Occlusion Mode | The mode that HDRP uses to calculate specular occlusion. The options are: • Off: Disables specular occlusion. • From AO: Calculates specular occlusion from the ambient occlusion map and the Camera's view vector. • From AO and Bent Normal: Calculates specular occlusion from the ambient occlusion map, the bent normal map, and the Camera's view vector. If no bent normal is provided, the normal is used instead. • Custom: Allows you to specify your own specular occlusion values. |
Override Baked GI | Indicates whether this Material ignores global illumination (GI) in the Scene and instead uses custom GI values. Enable this setting to add two baked GI Blocks to the Fragment Context that control GI for the Material. Disable this setting to make the Material use the Scene's GI. |
Support Lod Crossfade | Indicates whether HDRP processes dithering when a mesh moves moves from one LOD level to another. |
Add Precomputed Velocity | Indicates whether to use precomputed velocity information stored in an Alembic file. |
Geometry Type | Indicates what geometry is used to represent the hair, which allows the shading model to make informed approximations. The shading model approximates the hair fiber differently in each of the following representations:
• Cards: Hair fibers are projected onto simplified proxy geometry called "cards". • Strands: Hair fibers are represented by screen-aligned ribbons or tubes. |
Scattering Mode | Indicates the light scattering method in a volume of hair. Requires the Physical Material Type and Strands Geometry Type to use:
• Approximate: Fall back to a simplified diffuse component to approximate hair color. This is generally acceptable for high-absorbent (dark) hair. This is the default for both Material types. • Advanced: Simulate the scattering of light through a volume of hair strands. This is important for depicting low-absorbent (light) hair. Adds the Strand Probe Volume parameter. |