This is the fifth 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:
Modern high-end graphics would be incomplete without post-processing. While we can’t always “fix it in post,” it’s difficult to imagine our rendered images without the filters and fullscreen image effects that make them more cinematic. That’s why HDRP comes bundled with its own built-in post-processing effects.
HDRP Post-processing uses the Volume system to apply the image effects to the Camera. Once you know how to add overrides, the process of applying more post-effects should be familiar.
Post-processing Overrides for controlling color and contrast sometimes overlap in functionality. Finding the right combinations might require some trial and error. You won’t need every effect available; just add the necessary overrides to create your desired look and ignore the rest. Refer to Volumes in the Sample Scene for example usage.
Tonemapping is a technique for mapping high-dynamic-range colors to the more limited dynamic range of your screen. It can enhance the contrast and detail in your renders.
If you want a cinematic look, set the Tonemapping Mode to the industry standard ACES (Academy Color Encoding System). For something less saturated and contrasted, select Neutral. Experienced users also have the option of choosing Custom to define the tonemapping curve for themselves.
Shadows, Midtones, Highlights
The Shadows, Midtones, Highlights Override controls the tonal and color range for each of the shadows, midtones, and highlights of the render. Activate each trackball to affect the respective part of the image. Then, use the Shadow and Highlight Limits to prevent clipping or pushing the color correction too far.
Bloom creates the effect of light bleeding around the light source. This conveys the impression that the light source is intensely bright, as though overwhelming the Camera.
Adjust the Intensity and Scatter to alter Bloom size and brightness. Use Threshold to maintain sharpness on dull or non-bright pixels.
Lens Dirt, meanwhile, applies a texture of smudges or dust to diffract the Bloom effect.
Depth of Field
Depth of Field simulates the focus properties of a real camera lens.
Objects close to or further from the Camera’s Focus Distance appear to blur. You can set Focus Distance from:
- The Volume Override with the Manual Ranges Focus Mode: Here, the Volume itself controls the focus distance. For instance, you can use this to make the Camera intentionally blurry based on location (e.g., underwater scenes).
- A Cinemachine Camera with the Volume Settings extension: Use this to follow and autofocus on a target.
- The Physical Camera properties in Physical Camera Focus Mode: Use this to animate the Focus Distance parameter from the Camera component.
When Depth of Field is active, an out-of-focus blur effect called a bokeh can appear around any bright area of the image. Modify the Camera aperture’s shape to change the appearance of the bokeh. See the section on additional Physical Camera parameters from this how-to page on anti-aliasing, volume, and exposure.
For cinematics or offline rendering, you can choose a more expensive but Physically Based Depth of Field to enable additional settings and Custom Quality.
The White Balance Override adjusts a scene’s color so that the color white is correctly rendered in the final image. You can push the Temperature to shift between yellow (warmer) and blue (cooler), and the Tint to adjust the color cast between green and magenta.
In the HDRP Sample Scene, the Local Volumes include White Balance Overrides for each room.
Use Color Curves to adjust specific ranges in Hue, Saturation, or Luminosity. Select one of the eight available graphs to remap your color and contrast.
Use the Color Adjustments options to tweak the overall tone, Hue, Saturation, and Contrast of the final rendered image.
The Channel Mixer lets one color channel impact the “mix” of another. Select an RGB Output, then adjust its influence. For example, dialing up the Green influence in the Red Output Channel will tint all green areas of the image with a reddish hue.
Lens Distortion simulates radial patterns that arise from imperfections in the manufacture of real-world lenses. This results in straight lines appearing slightly bowed or bent, especially with zoom or wide-angle lenses.
Vignette imitates an effect from practical photography, where the corners of the image darken and/or desaturate. This effect can occur with wide-angle lenses or result from an appliance (like a lens hood or stacked filter rings) blocking the light. It can also be used to draw the attention of the viewer to the center of the screen.
Real-world objects appear to streak or blur in a resulting image when they move faster than the Camera exposure time.
Use the Motion Blur Override to simulate that effect. To minimize performance cost, reduce the Sample Count, increase the Minimum Velocity, and decrease the Maximum Velocity. You can also reduce the Camera Clamp Mode parameters under the Additional Properties.
Generally, a lens flare appears when bright light shines onto the lens of a camera. It can take the form of a single bright glare or multiple colored polygonal flares matching the aperture of the camera. In real life, flares have an unwanted effect but can be used for a narrative or artistic purpose. For example, a strong lens flare can grab the attention of the player or change the mood of a setting or scene.
In HDRP, use Lens Flare as a post-processing effect in the later stages of the rendering process.
Lens Flare Asset
The appearance of the flare is indicated in the Flare Asset, but in order to render the effect, you need to add the component Lens Flare (SRP) to an object in Scene view, such as a light source or other object that will generate the flare.
The component controls the general intensity, scale, and occlusion parameters of the effect. It also provides the option to run off-screen when the flare is outside the Camera view (though it should still project some flare effects in the scene, especially if the flare comes from a static source).
To become more familiar with Lens Flares, install the Samples from the Package Manager. This will add a set of predefined Flare Assets and modify the HDRP Sample Scene to include Lens Flare effects. You’ll also find a test scene where you can browse Lens Flares and build your own.
If you select Directional Light Sun in the project, for example, you’ll find the component Lens Flare (SRP) attached to the light, as well as a data asset. Change the asset to observe different flare effects.
Lens Flares are made out of Lens Flare Elements. Each element represents a different artifact that a flare can produce. The shape of the element can be a polygon, circle, or other custom Image. Element parameters enable you to tweak the Color, Transform Position, and Scale.
When attached to a light source, the Flare Elements can leverage Tint to reuse the same Flare Asset with many different light sources.
Watch this presentation to learn more about how Lens Flares work.
The Rendering Debugger window (Window > Analysis > Rendering Debugger) contains debugging and visualization tools specific to the Scriptable Render Pipeline (SRP). The left side is organized by category. Each panel allows you to isolate any issues Lighting, Materials, Volumes, Cameras, and so on.
The Rendering Debugger is also available at runtime under Game view in Play Mode, or in a Player build under Development build. You can open its menu by using Ctrl+Backspace or pressing the two sticks of a game controller.
Fullscreen Debug Mode
The Debugger can help you troubleshoot a specific rendering pass. On the Lighting panel, you can enter Fullscreen Debug Mode and choose features to debug.
This mode lets you play “pixel detective” and identify the source of a specific lighting or shading issue. The panels on the left show you how vital statistics from Cameras, Materials, Volumes, and so on, can optimize your render.
With the Fullscreen Debug Mode active, the Scene and Game views switch to a temporary visualization of a specific feature. This can serve as a useful diagnostic.
You can also debug several common Material properties in Material screen > Common Material Properties, including Albedo, Normal, Smoothness, and Specular.
To debug performance, go to the Rendering Debugger window when in Play Mode. There you can access a statistics panel.
See the Debugger documentation for complete details.
Ray tracing (Preview)
Ray tracing is a technique that can produce more convincing renders than traditional rasterization. While it has historically been expensive to compute, recent developments in hardware-accelerated ray intersection (or tracing) have now made ray tracing possible for real-time applications.
Ray tracing in HDRP is a hybrid system that still relies on rasterized rendering as a fallback and includes Preview support for ray tracing with a subset of select GPU hardware and the DirectX 12 API. See Getting started with ray tracing for a specific list of system requirements.
To enable ray tracing (in Preview), you need to change the Default graphics API of your HDRP project to DirectX 12. Open the Render Pipeline Wizard (Window > Render Pipeline > HD Render Pipeline Wizard).¹ Click Fix All in the HDRP + DXR tab, then restart the Editor. Follow the Pipeline Wizard prompts to activate any disabled features.
You can also set up ray tracing manually.
Once you enable ray tracing for your project, check that HDRP Global and Camera Frame Settings also have ray tracing activated. Make sure you are using a compatible 64-bit architecture in your Build Settings and validate your scene objects from Edit > Rendering > Check Scene Content for HDRP Ray Tracing.
¹ In Unity 2021, locate the HDRP Wizard under Window > Rendering > HDRP Wizard.
Overrides: Ray-Traced Ambient Occlusion
Ray tracing adds some new Volume Overrides and enhances many of the existing ones in HDRP. The following sections detail each override.
Ray-Traced Ambient Occlusion replaces its screen space counterpart. Unlike Screen Space Ambient Occlusion (SSAO), Ray-Traced Ambient Occlusion allows you to use off-screen geometry to generate the occlusion. This way, the effect does not disappear or become inaccurate toward the edge of the frame.
HDRP divides your scene into an axis-aligned grid, centered around the Camera. It uses this structure to determine the set of local lights that might contribute to the lighting whenever a ray hits a surface. It can then compute light bounces for certain effects, such as Ray-Traced Reflections and Ray-Traced Global Illumination.
Use the Camera Cluster Range Volume Override to alter the range of this structure and ensure that it encompasses the GameObjects and lights that need to be considered.
You can use an HDRP Debug Mode available via Windows > Analysis > Rendering Debugger > Lighting > Fullscreen Debug Mode. This helps visualize the Light Cluster Cells (highlighted in red), indicating where the light count has reached Maximum Lights per Cell in the HDRP Asset. Adjust this setting to reduce unwanted light leaking and other such artifacts.
Ray-Traced Global Illumination
Ray-Traced Global Illumination is an alternative to Screen Space Global Illumination (SSGI) and Light Probes used for simulating bounced, indirect lighting. It calculates in real-time, and allows you to avoid the lengthy offline process of baking lightmaps while yielding comparable results.
Use Quality Settings for complex interior environments that benefit from multiple bounces and samples. Performance Mode (limited to one sample and one bounce) works well for exteriors, where the lighting mostly comes from the primary Directional light.
Leverage Ray-Traced Reflections to achieve higher quality reflections compared to reflection probes or Screen Space Reflections. Off-screen meshes appear correctly in the resulting reflections.
Adjust the Minimum Smoothness and Smoothness Fade Start values to modify the threshold at which smooth surfaces start to receive Ray-Traced Reflections. Increase the bounces if necessary (e.g., two mirrors reflecting each other), but keep the performance cost in mind.
Use Ray-Traced Shadows for Directional, Point, Spot, and Rectangle Area lights. They can replace Shadow Maps from any opaque GameObject. Directional lights can also cast Ray-Traced Shadows from transparent or translucent GameObjects.
Ray tracing produces natural-looking shadows that soften as their distance from the caster increases, like in real life. Directional, Point, and Spot lights can similarly generate semi-transparent shadows.
Additionally, HDRP’s Directional lights generate semi-transparent, colored shadows. In the example, a glass surface casts a precisely tinted shadow on the floor.
Watch Activate ray tracing with HDRP for a walkthrough of the High Definition Render Pipeline’s ray tracing features in Preview. See the Ray tracing documentation for more information.