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

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

Debugging the Render Pipeline

Changes to your lighting may be hard to troubleshoot. Thus, HDRP includes a debugging tool to help you dissect the rendered frame.

Go to Window ▸ Render Pipeline ▸ Render Pipeline Debug.

Select the Lighting tab. Locate Debug Mode.

lighting debug mode

Watch the Game view as you toggle modes in the dropdown.

toggling Game view as different debug modes are selected

Some terms may be useful here:

  • Diffuse light contacts a rough material and scatters. This forms the basis of a surface’s color.
  • Specular light hits a smooth or shiny material. The light rays form highlights as they reflect back toward the camera.
  • Direct light travels from the light source to the surface.
  • Indirect light is bounced light. Global illumination calculates how light rays physically react to the surfaces along their path.

The effect of indirect light can be subtle. It’s essential, however, for that extra touch of realism.

Sometimes it’s hard to tell the source of a lighting issue. Is it the result of global illumination? Is it just a reflection? The answer may not be obvious. The Debug Pipeline tool can help you investigate. Keep it handy in your bag of tricks!

Set your Debug Mode back to None. Then, close this dialog for now.

Adding Volumetric Fog

To make the scene slightly more dramatic, add fog, which makes the atmosphere visible and dense.

Understanding Volume Settings

To begin, in Sky and Fog Volume, locate the Fog Override.

Fog override for sky and fog volume

Check Enable. Set the starting Base Height at 0 and fade the fog off at a Maximum Height of 3.

Set the Fog Attenuation Distance to 20 units. Smaller values make it dense and thick. Larger values make it dissipate more gradually.

Check Volumetric Fog. This creates the illusion of light shafts or “god rays.”

Override the Denoising Mode to Both. This will produce high quality results when removing noise from the fog, but will be more resource intensive.

Understanding Light Settings

Scene view with volumetrics, bright light entering room

Select Sun_DirectionalLight. The Light component has a group of parameters called Volumetrics. To exaggerate the effect, override the Multiplier. Then, drag the slider to 16. The volumetric fog appears much stronger.

Enter Play mode to check how the level feels in first-person. Turn right to face the windows, and strafe side-to-side. Light shafts stream through the windows.

level with volumetrics, light ray entering through window

The Shadow Dimmer controls the strength of the volumetric shadows. A value of 0 makes the shadow invisible and fills the entire room with conventional fog. Use a value of 1 to cut out a volume based on the window openings. This just leaves the light shafts themselves. An in-between value blends how strongly the volumetric shadow affects the cutout.

Toggling Scene view with various values of Multiplier and Shadow Dimmer, room getting brighter and dimmer

Experiment with the Multiplier and Shadow Dimmer until you achieve your desired look. This example shows values of 2 and 0.95, respectively.

view panning around the room with light coming in the windows

You can also select Sky and Fog Volume to adjust the volumetric fog.

Adding Lights

You may need to add lighting to accentuate the forms of the mesh. For example, you can throw a spotlight onto the steps to separate them from the shadowed back wall.

Scene view showing an added spotlight

Create a new Spot Light using right-click ▸ Light ▸ Spotlight. Rename it StairsFill_SpotLight and parent it to Lighting.

Set Mode to Baked. This light won’t cast shadows.

Use these values for the Transform:

Position (X: 1.3, Y: 1.5, Z: -0.38)
Rotation (X: 24.2, Y:-95, Z: 0)

Set Shape to Pyramid. In HDRP, you can use shapes other than a cone. In this case, the pyramid shape helps you accent the stairs without catching the wall.

Dial Spot Angle to 29 and Aspect Ratio to 0.4.

Keep the falloff Radius small at 0.1.

Push the color Temperature toward the blue end of the spectrum. Try 13000 Kelvin.

Dial the Intensity to about 20000 Lumen. Because key light is over 100,000 lux, this spotlight will need to be brighter than an average interior light.

Set the Range to about 6.

Light settings for spotlight with values

The effect is subtle, but this pops the stairs from the darkness.

Effects of the new spotlight. The stairs can be seen much more clearly

What are lumen, lux and candela?

HDRP uses physical light units to match the intensities of real light sources:

Measuring illuminance varies by context. You can read lux with a handheld light meter. Lumens requires a more sophisticated goniophotometer.

When trying to recreate an actual light fixture, use the exact specifications from the manufacturer. HDRP will match its real-world intensity. With a factory IES profile, you can also match how a light spreads in real life.

  • Lumen is a “unit of luminous flux.” This is the total amount of light emitted from a source. This is more accurate than wattage when judging a bulb’s brightness.
  • Lux is a measure of illuminance. This is the total amount of light falling on a surface.
  • Candela represents the intensity of one common wax candle.

What are lumen, lux and candela?

HDRP uses physical light units to match the intensities of real light sources:

  • Lumen is a “unit of luminous flux.” This is the total amount of light emitted from a source. This is more accurate than wattage when judging a bulb’s brightness.
  • Lux is a measure of illuminance. This is the total amount of light falling on a surface.
  • Candela represents the intensity of one common wax candle.

Measuring illuminance varies by context. You can read lux with a handheld light meter. Lumens requires a more sophisticated goniophotometer.

When trying to recreate an actual light fixture, use the exact specifications from the manufacturer. HDRP will match its real-world intensity. With a factory IES profile, you can also match how a light spreads in real life.

With the layered effects and lighting settings in place, your level should be taking shape nicely now.

a room that is mostly dark with some light entering from the right side