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 3 of 5 of this article. Click here to view the first page.

Setting Exposure and Light Emission

Changing the exposure and light emission settings can have a dramatic effect on your scene.

Understanding Exposure

You’re currently using some physically incorrect values for the sake of visualization. HDRP works much better when you respect real-world exposure and light intensity.

Exposure value in photography follows a logarithmic scale. The formula relates a camera’s shutter speed and its f-stop/aperture:

formula for exposure value

In this formula:

  • N is the f-number.
  • t is the shutter speed in seconds.
  • 0 EV: Moonless night
  • 3.0 EV: Moonlit scene
  • 6.0 EV: Interior scene
  • 8.0 EV: Exterior sunset/sunrise
  • 12.0 EV: Cloudy exterior
  • 15.0 EV: Sunny exterior
Note: Here are some common exposure settings:

Set an accurate exposure value to render the image. With the Sky and Fog Volume selected, click Add Override below the Volume component. These menu items represent all the possible overrides for this Volume.

Select Exposure. In Exposure Override, change the Mode to Fixed.

Follow the checkmarks on the Fixed Exposure slider for reference. Adjust it to a value of 11.

Mode set to Fixed and Exposure set to 11

The current lighting intensity doesn’t match real-world conditions, so the game camera goes dark. You’ll need to bring the light up to the level of sunlight.

Understanding Light Emission

Select Sun_DirectionalLight. In the Emission group, the Intensity of a directional light uses lux. This standard unit of illuminance records how much light falls over a surface area.

Following the guide marks on the slider, choose a physically accurate value. Set the Intensity to a really bright 130000 lux.

HDRP uses physically accurate Kelvin temperatures to set the light’s color.

To mimic the afternoon sun, set the temperature roughly to 6500 Kelvin. The level turns warm and golden.

Updated intensity under light emission

warm light game view

Adding More Volume Overrides

With the sunlight serving as the primary light, or key light, it’s time to start adding more overrides.

Select Sky and Fog Volume. Check Add Override. Use the following menu items, overriding a few fields:

Tonemapping settings

Color adjustment settings

Bloom settings

Dial down the Shadows slightly by setting its Y value to -0.3, lift the Midtones by modifying its Y value to -0.15 and increase the Highlights by changing its Y value to 0.2. This makes for a bold, high-contrast look. If you don’t see a UI interface similar to that below, just increase the Inspector window size to reveal it.

settings for Shadows, Midtones, Highlights

And here’s how these settings will affect the Game view:

Cumulative effect of the previous settings being applied, cycling through different lighting conditions

Ambient occlusion settings

Ambient occlusion being toggled, with bookshelves lightening and darkening

  • Post-processing ▸ Tonemapping: This maps the high-dynamic range values into viewable, low-dynamic screen colors. Set Mode to ACES. ACES uses the same algorithm featured in film and television. It shows higher contrast than Neutral with more saturated colors.
  • Post-processing ▸ Color Adjustments: This provides additional controls for contrast, color and saturation tweaks. Increasing the Contrast makes the blacks blacker and the whites whiter. Decreasing the Saturation — reducing the intensity of the colors — is a popular look for certain games. Set the Contrast to 10 and the Saturation to -20.
  • Post-processing ▸ Bloom: Use this to add glowing fringes around bright light sources. Only pixels brighter than the Threshold receive the effect. Increase the Intensity to strengthen the visible glow. Set the Quality to Medium, Threshold to 0.95, Intensity to 0.25 and Scatter to 0.71.
  • Post-processing ▸ Shadows, Midtones, Highlights: Use these settings for finer control of the dark, medium and light pixels in the final render.
  • Lighting ▸ Ambient Occlusion: This helps darken cracks and crevasses. Though not physically accurate, it can help accentuate certain details. Using these example values helps darken the cubicles in the bookshelf, for example.

Now that you’ve learned about these overrides, try toggling each override off and on to review its effect on the Game view.

Setting Lightmapping and Global Illumination

To further improve the look of the scene, use global illumination (GI), a set of techniques that model the physical behavior of light. During global illumination, you bake the lighting into a special texture called a lightmap.

Understanding Global Illumination

For global illumination, each mesh must have:

  • Contribute GI marked in MeshRenderer.
  • A set of non-overlapping UVs. Unity can generate these automatically upon import.

Confirm this for yourself. Inspect the child objects under Building. Note how each MeshRenderer has Contribute Global Illumination checked. Receive Global Illumination should be set to Lightmaps.

Contribute GI and Receive GI for a mesh

You can also enable this from the Static menu in the top-right of the Inspector.

Contribute GI option checked in the static menu

In RW/Meshes, under the Model tab, each model geometry has Generate Lightmap UVs enabled in Import Settings.

Generate Lightmap UVs checked under Model menu for the models

Depending on the complexity, each lightmap could require several minutes to many hours to calculate. Once baked, however, playback is quite performant. Thus, your app can display high-quality GI lighting while retaining a good frame rate.

To enable lightmapping, select Sun_DirectionalLight. Switch the Mode to Mixed. The light works in Realtime for dynamic objects and Baked mode for static objects.

Light mode changed to Mixed

Select Sky and Fog Volume. Override Ambient Mode in Visual Environment to Dynamic. This allows the baking process to use the Physically Based Sky for ambient light.

Ambient mode set to dynamic for the light

The scene will temporarily become very bright, but ignore it for the moment.

room lit much more brightly than before

Go to Window ▸ Rendering ▸ Lighting.

The Lighting Settings saves your settings to an asset on disk.

Choose one of the assets provided with the project, like LightingSettings2Medium. Alternatively, create your own using New Lighting Settings.

Modified Lighting Settings highlighted

Baking Lightmaps

Use the following Lightmapping Settings:

  • Lighting Mode: Choose Baked Indirect. Unity bakes bounced lighting into lightmaps for static objects. Moving objects continue to receive real-time lighting and cast shadows.
  • Lightmapper: Use Progressive GPU (Preview) for hardware-accelerated lightmapping. This can reduce your bake times dramatically. Use Progressive CPU if your machine doesn’t meet the requirements for the GPU Lightmapper.
  • Direct Samples / Indirect Samples / Environment Samples: 50 / 250 / 50: These determine how many rays to use for lighting calculations. The higher the samples, the more accurate the results but the longer the bake times.
  • Lightmap Resolution: 40: This specifies the number of texels, or texture elements, per unit. Larger values mean higher quality and longer bake times.
  • Lightmap Padding: 5: This is the spacing between different shapes in the lightmap. Large values can reduce bleeding when lighting from one part of the mesh incorrectly appears on a different part.
  • Directional Mode: Directional: When using Directional, a second lightmap stores the general direction of the key light. This is useful with normal-mapped materials.
  • Lightmap Parameters: Default-Medium: These determine some preset quality settings for lightmap generation.

Click Generate Lighting. This begins the lightmap baking process.

If you have good graphics hardware, the GPU-accelerated lightmapping should take just a few seconds. If you need to use your CPU instead, the GI calculations may run for several minutes.

Watch the progress bar in the lower-right corner.

baked lightmaps for the scene

When the process completes, the brightness level in the Game view returns to normal. Lighting bakes into the surfaces of each static mesh.

Switch to the Baked Lightmaps tab to view the actual maps. Click Open Preview to see the image in closer detail.

preview of baked lightmaps