Improving Game Visuals with Unity’s HDRP

Improve your game visuals and take them up by several notches using the High Definition Render Pipeline from Unity. By Wilmer Lin.

5 (4) · 3 Reviews

Download materials
Save for later
Share
You are currently viewing page 2 of 5 of this article. Click here to view the first page.

Adding Some Visual Flair

Going back to the Daylight scene, notice that a single Directional Light under Lighting is active. Rename it Sun_DirectionalLight.

Renamed directional light object

Now, swing the light direction, so it enters from the window to the right. Adjust the rotation to (X: 27, Y: -79, Z: 0).

Turn on the light’s shadows. Check Enable under the Shadows component.

Shadow map enabled and resolution set to ultra in the Shadows tab for the light

To improve the shadow map resolution, switch the Resolution to Ultra. The shadow edges sharpen and become less blurry.

Raking the shadows across the concrete blocks makes for a more dynamic composition. Diagonal lines help draw the viewer’s eye into the scene.

room with beams of light entering from the upper right

Understanding Environment Lighting

Currently, the scene has a bluish cast. This stems from some existing environmental lighting. In the Scene view, three main colors represent the outer boundaries of the world:

  • A dark earthy ground color
  • A brighter, white horizon
  • A blue sky

The source of the color is DefaultHDRISky inside HDRPDefaultResources.

Preview of the default HDRI

Double-click the image to open a preview. It consists of six smaller 128 × 128 images, stitched into one larger 768 × 128 EXR file. EXR is a high-dynamic range format. It contains a wider range of color and contrast than a typical image file.

How do you generate an HDRI?

[spoiler title=”How do you generate an HDRI?”]
Changing effects to an image as its exposure is modified

A high-dynamic range image, or HDRI, merges several exposures from a digital camera into a special file format. The resulting image contains detailed information about the actual lighting conditions when photographed. Unity can then use this HDRI to approximate the environment lighting in your scene.

Want to shoot your own HDRIs? Follow these guidelines.

If you don’t want to make your own, Unity also provides an excellent HDRI Pack in the Asset Store to help you get started.

HDRI image with rocks on the ground and blue sky

Many sites like HDRI Haven also offer free or low-cost HDRIs suitable for use within Unity.

[/spoiler]

How do you generate an HDRI?

[spoiler title=”How do you generate an HDRI?”]
Changing effects to an image as its exposure is modified

A high-dynamic range image, or HDRI, merges several exposures from a digital camera into a special file format. The resulting image contains detailed information about the actual lighting conditions when photographed. Unity can then use this HDRI to approximate the environment lighting in your scene.

Want to shoot your own HDRIs? Follow these guidelines.

If you don’t want to make your own, Unity also provides an excellent HDRI Pack in the Asset Store to help you get started.

HDRI image with rocks on the ground and blue sky

Many sites like HDRI Haven also offer free or low-cost HDRIs suitable for use within Unity.

[/spoiler]

The Texture Shape is set to Cube in the Import Settings.

Texture Shape of the Default HDRI is set to Cube

Unity basically unwraps the cubemap and projects it onto the interior of a sphere. Drag the preview window to rotate the projection. Adjust the -/+ slider to visualize the bracketed exposures.

Preview of the Default HDRI

This HDRI sky sphere creates the illusion of the ground, horizon, and sky.

HDRI map used in scene by Unity to give an effect of ground, horizon and sky

During the rendering process, light rays bounce around the world. Some of these rays return and strike the scene geometry. Each such reflection transfers a little bit of color from the HDRI sphere. This environment lighting and reflection creates the general bluish tint.

In this particular case, you’ll swap out the default HDRI to change the ambient color.

Adding a Sky and Fog Volume

Now, you’ll add some realism to the level using the Volume framework.

Understanding the Volume Framework

Unity uses the Volume framework to control aspects of the pipeline. An active Volume currently works as the default source of environment lighting.

Default Volume Profile Asset selected in the HDRP Default Settings tab

Return to Edit ▸ Project Settings and locate the HDRP Default Settings tab. The Default Volume Profile Asset is set to VolumeGlobal.

Click New to create a custom Volume profile. This generates an asset called DefaultVolumeSettingsProfile, which is added to the HDRPDefaultResources folder.

Scene view after a new volume profile is created

In the Scene view, the colored HDRI environment disappears. The Game view, meanwhile, becomes extremely stark. It’s completely black and white, lit only by the direct rays from Sun_DirectionalLight.

Surfaces in the path of direct sunlight turn white. The light doesn’t bounce and scatter as you would expect in real life.

The current direct lighting strikes a surface and stops. Without indirect or bounced lighting, everything just looks unnaturally black.

Game view after adding a new volume profile

You can fix that with some environment lighting.

Right-click in the Hierarchy to create a Volume ▸ Sky and Fog Volume. Now everything turns bright white. Don’t panic! This is just temporary. Parent this to the Lighting transform to stay organized.

Scene hierarchy after creating a new Sky and Fog Volume

It’s hard to see anything, so adjust the light intensity as a stopgap fix. Select the Sun_DirectionalLight. Find the Light component and locate Emission. Drag the Intensity down to something small, like 40 lux.

The blue cast disappears. The Game view now sports a warmer ambient light.

room with a brownish tone and light entering from the upper right

In the Scene view, the surrounding world changes color. The ground turns into an earthy yellow-brown, while the sky becomes a silvery light blue.

exterior view of building with light settings from the previous image

Understanding Overrides

Select Sky and Fog Volume. The Volume component allows you to influence the camera render with a series of overrides. Each override controls one part of the pipeline, giving you fine-level control of the rendered output.

Note that the Mode is set to Global. This means the component affects the entire scene. Weight and Priority help decide priority when more than one Volume is active.

Overrides tab for Sky and Fog Volume

Nested below the Volume component are three overrides:

  • Visual Environment: This override determines what type of sky appears in the background. The default is Physically Based Sky, a procedurally generated environment. You can also choose a simple Gradient color or replace this with a photographed HDRISky.
  • Physically Based Sky: This override simulates light dispersing through the atmosphere. It reproduces both Rayleigh and Mie scattering.
  • Fog: This recreates thick, cloudy air that hangs close to the ground. The fog density attenuates as it rises upward and moves away from camera.

Unity stores all the Volume overrides in a Profile asset. Be careful! Any changes you make are saved immediately to disk.

Select the Sky and Fog Settings Profile in the project window. This is located in the RM/Scenes/Daylight folder.

Rename it to Day Settings Profile. You can have more than one Profile in the same scene. Name each one descriptively to tell them apart.

Now, modify the current Profile to the Day Settings Profile.

Updated Volume profile to Day Settings Profile