This is the third in a series of articles that explains how developers and technical artists can set up and use the High Definition Render Pipeline (HDRP) in Unity to achieve high-end graphical realism. HDRP represents a technological leap in Unity’s real-time rendering so you can work with light just as it behaves in the real world.
Be sure to read the other articles in our how-to series for high-end lighting:
HDRP includes a number of different Light types and shapes to help you control illumination in your scene.
Light types
These are the Light types available, similar to other render pipelines in Unity:
- Directional: This behaves like light from an infinitely distant source, with perfectly parallel light rays that don’t diminish in intensity. Directional lights often stand in for sunlight. In an exterior scene, this will often be your key light.
- Spot: This is similar to a real-world spotlight, which can take the shape of a cone, pyramid, or box. A spot falls off along the forward z-axis, as well as toward the edges of the cone/pyramid shape.
- Point: This is an omnidirectional light that illuminates all directions from a single point in space. It is useful for radiant sources of light, like a lamp or candle.
- Area: This projects light from the surface of a specific shape (a rectangle, tube, or disc). An area light functions like a broad light source with a uniform intensity at the center, like a window or fluorescent tube.
Modify how Spot, Point, and Area lights fall off with the Range. Many HDRP lights diminish using the inverse square law, like light sources in the real world.
Spot and Area lights have additional shapes for controlling how each light falls off, as covered in the following sections.
HDRP Spot lights can take three shapes:
- Cone: Projects light from a single point to a circular base. Adjust the Outer Angle (degrees) and Inner Angle (percentage) to shape the cone and modify its angular attenuation.
- Pyramid: Projects light from a single point onto a square base. Adjust the pyramid shape with the Spot Angle and Aspect Ratio.
- Box: Projects light uniformly across a rectangular volume. An X and Y size determine the base rectangle, and the Range controls the Y dimension. This light has no attenuation unless Range Attenuation is checked, which can be used to simulate sunlight within the boundary of the box.
HDRP Area lights can take three shapes:
- Rectangle: Projects light from a rectangle shape in the local positive Z direction, out to a defined range.
- Tube: Projects light from a single line in every direction, out to a defined range. This light only works in Realtime Mode.
- Disc: Projects light from a disc shape in the local positive Z direction, out to a defined range. This light only works in Baked Mode.
All HDRP Light types have Emission properties that define the light’s appearance.
You can switch the Light Appearance to Color and specify an RGB color. Otherwise, change this to Filter and Temperature for a more physically accurate input.
Color Temperature sets the color based on degrees Kelvin. See the Lighting and Exposure cheat sheet further down on this page for reference.
You can also add color that acts like a filter, tinting the light with another hue. This is similar to adding a color gel in photography.
HDRP includes some advanced controls under the More Items menu (⋮) at the top-right of the Inspector. Select Show additional properties to see extra options.
These include toggles for Affect Diffuse and Affect Specular. In cutscene or cinematic lighting, for example, you can separate lights that control the bright shiny highlights independently from those that produce softer diffuse light.
You can also use the Intensity Multiplier to adjust the overall intensity of the light without actually changing the original intensity value. This is useful for brightening or darkening multiple lights at once.
HDRP allows you to use Light Layers to make light affect only specific meshes in your scene. These are LayerMasks that you can associate with a Light component and MeshRenderer.
In the Light properties, click the More Options button to view the Light Layer drop-down under General. Choose which LayerMasks you want to associate with the Light. You can also select Show additional properties from the More Items menu (☰). This similarly displays the Light Layer drop-down under General. Choose the LayerMasks you want to associate with the Light.
Next, set up the MeshRenderers with the Rendering Layer Mask. Only Lights on the matching LayerMask will affect the mesh. This feature is invaluable for fixing light leaks, and ensures that lights only strike their intended targets. It can also be part of the workflow to set up cutscene lighting, so that only characters receive dedicated cinematic lights.
For example, if you wanted to prevent the lights inside of a building from accidentally penetrating the walls outside, you could set up specific Light Layers for the interior and exterior. This ensures that you have fine-level control of your Light setups.
To set up your Light Layers, go to the HDRP Default Settings. The Layers Names section lets you set the string name for Light Layers 0 to 7.
For more information, including the full list of Light properties, see the Light component documentation.
Unity 2021 LTS and above includes a Light Anchor system to help you set up lights quickly, by controlling the angle and distance between the Camera and the subject. It also enables you to select common lighting angles via nine presets.
If you need to light a cinematic scene, product, or shot using multiple lights around characters or props, the Light Anchor component offers quick and efficient light manipulation in screen space around an anchor target.
First, make sure that your Camera is tagged as MainCamera, and then add a Light Anchor component to the Spot light you want to control. Align the light and the subject; this position is now the Anchor point of the Spot light. Increase the Distance between the Anchor point and the Spot light, or even adjust the position of the light around the Anchor point by tuning the Orbit, Elevation, and Roll of the light within the Game view, rather than by manually adjusting the Transform of the light in the Scene view.
For more information, check out this introductory presentation on Light Anchors.
HDRP uses Physical Light Units (PLU) for measuring light intensity. These match real-life SI measurements for illuminance, including candela, lumen, lux, and nits. Note that PLU expects one unit in Unity to equal one meter for accuracy.
Units
Physical Light Units can include units of both luminous flux and illuminance. Luminous flux represents the total amount of light emitted from a source, whereas illuminance refers to the total amount of light received by an object (often in luminous flux per unit of area).
Because commercial lighting and photography might express units differently depending on application, Unity supports multiple Physical Light Units for compatibility:
- Candela: One unit is equivalent to the luminous flux of a wax candle. This is also commonly called candlepower.
- Lumen: This is the SI unit of luminous flux defined to be one candela over a solid angle (steradian). You will commonly see lumens on commercial lightbulb specifications. Use it with Unity Spot, Point, or Area lights.
- Lux: A light source that emits one lumen onto an area of one square meter has an illuminance of one lux. Real-world light meters commonly read lux. You will often use this unit with Directional lights in Unity.
- Nits: This is a unit of luminance that is equivalent to one candela per square meter. Display devices and LED panels (televisions or monitors, for example) often measure their brightness in nits.
- EV100: The intensity corresponding to EV100 has an Exposure Value with 100 ISO film (see the Exposure Value formula section on this page). Incrementing the exposure results in the doubling of lighting, due to the logarithmic behavior.
For recreating a real lighting source, switch to the unit listed on the tech specs and plug in the correct luminous flux or luminance. HDRP will match the Physical Lighting Units, eliminating much of the guesswork when setting intensities.
Click the icon to choose presets for Exterior, Interior, Decorative, and Candle. These settings provide a good starting point if you are not explicitly matching a particular value.
Common lighting and exposure values
The cheat sheet shown here contains Color Temperature and lighting intensities of common real-world light sources. It also contains Exposure Values for different lighting scenarios.
You can find a complete table of illumination values in the Physical Light Units documentation.
Make your Point, Spot, and Area lights closely mimic the falloff of real lights using an IES Profile. This works like a Light cookie for applying specific manufacturer specs to a pattern of light. IES Profiles give lights an extra boost of realism.
Import an IES Profile from Assets > Import New Asset. The importer will automatically create a Light Prefab with the correct intensity. Then just drag the Prefab into the Scene view or Hierarchy and tweak its Color Temperature.
In the real world, light reflects and scatters around us. The sky and ground contribute to environment lighting as random photons bounce between the atmosphere and the earth, and ultimately to the observer.
In HDRP, you can use the Visual Environment Override to define the sky and general ambience for a scene.
For instance, use Ambient Mode: Dynamic to set the sky lighting to the current override that appears in the Visual Environment’s Sky > Type.
Otherwise, Ambient Mode: Static defaults to the sky setup in the Lighting window’s Environment tab.
Even with other light sources disabled, the Visual Environment provides the Sample Scene with general ambient light.
Adding the key light of the sun completes the general illumination of the scene. The environment light helps fill in the shadow areas so that they don’t appear unnaturally dark.
HDRP includes three different techniques for generating skies. Set the Sky Type to either HDRI Sky, Gradient Sky, or Physically Based Sky. Then, add the appropriate override from the Sky menu.
Applying a Visual Environment Sky is similar to wrapping the entire virtual world with a giant illuminated sphere. The colored polygons of the sphere provide general light from the sky, horizon, and ground.
HDRI Sky allows you to represent the sky with a cubemap made from High Dynamic Range (HDRI) photographs. You can find numerous free and low-cost sources of HDRIs online. A good starting point is the Unity HDRI Pack at the Asset Store. If you’re feeling adventurous, we also have a guide on shooting your own HDRIs.
Once you’ve imported your HDRI assets, add the HDRI Sky Override to load the HDRI Sky Asset. This also lets you tweak options for Distortion, Rotation, and Update Mode.
Because the sky is a source of illumination, specify the Intensity Mode, then choose a corresponding Exposure/Multiplier/Lux value to control the strength of the environmental lighting. Refer to the Lighting and Exposure cheat sheet above for example intensity and exposure values.
Animating Cloud Layers
You can animate your HDRI Sky and distort the HDRI Map either procedurally or with a flowmap. This allows you to fake a wind effect on a static HDRI or create other specific VFX.
Choose Gradient Sky in the Visual Environment to approximate background skies with a color ramp. Then add the Gradient Sky Override. Use the Top, Middle, and Bottom to determine colors for the gradient.
Blend the color ramp with Gradient Diffusion, and dial the Intensity for the strength of the lighting.
For something significantly more realistic than a gradient, use the Physically Based Sky Override.
This procedurally generates a sky that incorporates phenomena such as Mie scattering and Rayleigh scattering, which simulate light dispersing through the atmosphere, recreating the coloration of the natural sky. Physically Based Sky requires a Directional light for accurate simulation.
Smoke, fog, and haze are traditional tools of cinematography. They can help add depth and dimension to stage lighting or create an atmospheric mood.
Use Fog for a similar advantage in HDRP. Its opacity depends on the object’s distance away from the Camera. Fog can also hide the Camera’s Far Clipping Plane, blending distant geometry back into the scene.
HDRP implements Global Fog as a Fog Override. Here, the fog fades exponentially due to its distance from the Camera and its world space height.
Set up the Fog Override on a Volume in your scene. The Base Height determines a boundary where constant, thicker fog begins to thin out, traveling upward. The fog density continues fading exponentially, until it reaches the Maximum Height.
Likewise, the Fog Attenuation Distance and Max Fog Distance control how fog fades with greater distance from the Camera. Toggle the Color Mode between a Constant Color and the existing Sky Color.
Enable Volumetric Fog to simulate atmospheric scattering. Make sure to check Fog and Volumetrics in Lighting > Frame Settings (either under Camera or in HDRP Default Settings). Also, enable Volumetric Fog in the HDRP Pipeline Asset.
Volumetric Fog Distance sets the distance (in meters) from the Camera’sNear Clipping Plane to the back of its Volumetric Lighting buffer. This fills the atmosphere with an airborne material, partially occluding GameObjects within range.
Volumetric Lighting can simulate the rendering of dramatic sunbeams, like crepuscular rays behind the clouds at sunset or passing through foliage.
Each Light component (except Area lights) has a Volumetrics group. Check Enable, then set the Multiplier and Shadow Dimmer. A Real-time or Mixed Mode light will produce ‘god rays’ within Volumetric Fog. The Multiplier dials the intensity, while the Shadow Dimmer controls how shadow casting surfaces cut into the light.
Room 2 in the Sample Scene features a skylight and Volumetric Fog. The frame of the glass case carves volumetric shadows out of the sunbeams from the ceiling. Dial up the Shadow Dimmer and exaggerate the Multiplier to intensify the effect.
If you want more detailed fog effects than the Fog Override can provide, HDRP also offers Local Volumetric Fog (called a Density Volumecomponent prior to HDRP 12).
This is a separate component, outside of the Volume system. Create a Local Volumetric Fog GameObject from the menu (GameObject > Rendering > Local Volumetric Fog) or right-click over the Hierarchy (Rendering > Local Volumetric Fog).
This generates a fog-filled bounding box. Adjust the size, axis control, and blending/ fading options. By default, the fog is uniform, but you can apply a 3D Texture to the Texture field under the Density Mask Texture subsection. This gives the user more flexibility over the look of the fog.
Download examples from the Package Manager > Local Volumetric 3D Texture Samples or follow the documentation procedures to create your own Density Masks.
Add some Scroll Speed for animation and adjust the Tiling. Your Volumetric Fog can then gently roll through the scene.
HDRP voxelizes Local Volumetric Fog to enhance performance, though the voxelization can appear coarse. To reduce aliasing, use a Density Mask Texture and increase the Blend Distance to soften the fog’s edges.
In HDRP versions 12 and above, you can enable local volumetric resolutions up to 256x256x256 in your HDRP Pipeline Asset. This allows for more precise, large-scale effects.
Skies would not look complete without clouds. In HDRP 12 and above, use Cloud Layers to generate natural-looking clouds that complement Sky and Visual Environment Overrides.
Volumetric Clouds produce realistic clouds with an actual thickness that react to the lighting and wind.
The Cloud Layer is a 2D texture you can animate using a flowmap with red and green channels to control vector displacement. It sits in front of the sky, and provides an option to cast shadows on the ground.
In Play Mode, use the Cloud Layer to add slight motion to your skies, making the background more dynamic.
In a local or global Volume, enable Background Clouds in the Visual Environment. Then add the Cloud Layer Override.
The Cloud Map itself is a texture using a cylindrical projection, where the RGBA channels all contain different cloud textures (cumulus, stratus, cirrus, and wispy clouds, respectively). You can then use the Cloud Layer controls to blend each channel and build up your desired cloud formation. There are two layers with four channels that let you simulate and blend up to eight cloudscapes. Modify the cloud’s animation, lighting, color, and shadows to your liking.
If your clouds need to interact with light, use Volumetric Clouds. These can render shadows, receive fog, and create volumetric shafts of light. Combine these with Cloud Layer clouds or add them separately.
To enable Volumetric Clouds in your:
- HDRP Asset: Go to Lighting > Volumetric Clouds > Volumetric Clouds.
- Local or global Volume: Add the Volumetric Clouds Override.
The Advanced and Manual Cloud Control options allow you to define maps for each type of cloud.
Refer to the Clouds in HDRP documentation for more on the Cloud Layer and Volumetric Cloud Overrides. Please see New Lighting Features in Unity 2021.2 for an in-depth look at Volumetric Clouds.
We can’t perceive light without darkness. Well-placed shadows can imbue your scenes with extra depth and dimension, adding as much character as lighting itself. HDRP includes a number of features to fine-tune your shadows and prevent your renders from looking flat.
Shadow Maps
Shadows render using a technique called shadow mapping, where a texture stores the depth information from the light’s point of view.
Locate the Shadows subsection of the Light component to modify your Shadow Map’s Update Mode and Resolution. Higher resolutions and update frequency settings are more costly.
For a Directional light, the Shadow Map covers a large portion of the scene, which can lead to a problem called perspective aliasing. Shadow Map pixels located close to the Camera look jagged and blocky compared to those further away.
Unity solves this with Cascaded Shadow Maps, as explained in the next section.
A Cascaded Shadow Map splits the Camera frustum into zones, each with its own Shadow Map. This reduces the effect of perspective aliasing.
HDRP gives you extra control of your Shadow Cascades with the Shadows Override. Use the Cascade Settings for each Volume to indicate where their respective cascades begin and end.
Toggle the Show Cascades button to better visualize Cascade Splits. With some tweaking, you can keep perspective aliasing to a minimum.
Shadow Maps often fail to capture the small details, especially at discernible edges where two mesh surfaces connect. HDRP can generate these Contact Shadows using the Contact Shadows Override.
Contact Shadows are a screen space effect reliant on information within the frame for calculations. Objects outside of the frame do not contribute to Contact Shadows. They’re primarily effective for shadow details with small onscreen footprints.
Make sure that you enable Contact Shadows in the Frame Settings. You can also adjust the Sample Count in the Pipeline Asset under Contact Shadows Override in Lighting Quality Settings.
In 2021 LTS and newer versions, this feature was improved to work well with Terrain and SpeedTree. Read more on the blog.
HDRP can extend even minor shadow details into your Materials. Micro Shadows use Normal and Ambient Occlusion Maps to render really fine surface shadows without using the mesh geometry itself.
Add the Micro Shadows Override to a Volume in your scene and adjust the Opacity. Note, however, that Micro Shadows only work with Directional lights.