The HDRP water system in Unity 2022 LTS

Hi everyone,

We have some good HDRP news this week!

First of all, if you haven’t seen it yet, there’s a new technical e-book about HDRP: Lighting and environments in the High Definition Render Pipeline (Unity 2022 LTS).

In this edition for Unity 2022 LTS, you’ll learn about the new water system, Terrain tools, more capabilities for creating skies, clouds, lighting effects, HDRP shaders and materials, and much more.

Along with the e-book, you can also watch a video tutorial about the water system where we dive deep into the steps and workflows for creating a realistic body of water in your Unity scenes.

The rest of this post is an excerpt from the Lighting and environments in the High Definition Render Pipeline (Unity 2022 LTS) e-book, and it focuses on getting started with the water system in Unity 2022 LTS or above.

We hope you find this article useful!

Now, if you’re new to the water system, we recommend starting with Unity 2023 .1 (HDRP 15) which features several notable improvements from previous versions:

  • Local currents
  • Surface deformers
  • Water excluders
  • Local foam generators
  • Water line and underwater features
  • Extra Debug modes

You’ll also need Unity 2023 .1 or higher to explore the sample scenes.

To get your project ready for the water system:

  • Activate and configure water for each Render Pipeline Asset (per quality level that requires water).
  • Enable water in the Frame Settings of your camera(s) (Edit> Project Settings > Graphics > HDRP Global Settings).
  • Use the Water Rendering Volume override in the scene to control where water rendering is active, based on the camera’s position.

Enable Water Rendering in the Volume overrides

Once water is active, you can add preconfigured water bodies from the GameObject menu. HDRP provides three water surface types: pool, river, and ocean.

Water object in the GameObject menu
Add a water object from the GameObject menu.

Water Surface component

Water surface objects come with a Water Surface component script that controls the water’s general parameters.

The Water Surface component

These parameters configure the water surface’s simulation and rendering:

  • General: Defines the overall type of water body (e.g., Ocean/Sea/Lake, River, Pool) and geometry used to render the water surface (e.g., Quad, Custom, InstancedQuads, Infinite)
  • Simulation: Controls how the wave patterns and ripples form, emulating how the wind and moon affect the water’s surface
  • Deformation: Influences how a local deformation can raise or lower part of the water, useful for making waterfalls or other elevation changes
  • Appearance: Determines the water’s color, smoothness, refraction, and light scattering; caustics and special underwater settings enhance the physically based shading.
  • Foam: Controls the appearance and behavior of foam at the crest of waves, around objects in the water, or along the shoreline
  • Miscellaneous: Controls the Rendering Layer Mask and Debug modes

HDRP Water samples

The best way to familiarize yourself with all of the water system’s properties is to see them in action. HDRP includes several sample scenes to demonstrate capabilities and provide starting points.

In the Package Manager, install them from the Samples tab of the High Definition Render Pipeline.

Let’s take a look at each sample.

Swimming Pool: This scene shows multiple water surfaces for pools at different heights. It also demonstrates using custom meshes to achieve unique pool shapes beyond basic rectangles.

The Swimming Pool sample

Island: This scene features a small landmass surrounded by a body of water with waves. Water masks remove swell around the island, while deformers create waves. Decals and foam generators add foam for breaking waves. Physically simulated seagulls float on the water surface using the scripting API.

The Island sample

Glacier: This scene includes a river, waterfall deformer, current simulation to make the water flow, foam behind moving icebergs, decals for spray effects, and projected caustics.

The Glacier sample

Water Line: This scene modifies the water’s surface level and underwater rendering using a custom pass, generating a larger blurry water line and simulating water on a camera lens.

Rendering a water line

If you’re new to the water system, use one of these samples as a starting template for a similar environment. Then, you can customize the look of the water to match your own game world.

Physically based shading

The water system uses a physically based water shader. Modify its smoothness, refraction, and light-scattering properties in the Appearance parameters.

The scattering works like the base color of the water, establishing a general feel. Then change the Absorption Distance and Refraction Color to control how transparent your water is. This tints the objects seen through the refracted water.

Customizing the Appearance parameters

For example, use a large Absorption Distance with a cyan scattering and refraction color if you want the water to appear a deep, clean Caribbean blue. For turbid water from a muddy river, opt for a dark brown scattering color with a small absorption distance.

Modifying the Absorption Distance parameter

You can also modify the water material using a custom Shader Graph. See the River Shader Graph asset in the samples as a reference.

The River Shader Graph customizes the water material.

Simulating waves and wind

Each Water Surface component contains a number of simulation parameters that determine how the water reacts to factors like waves and wind. Waves are procedurally generated using a Fast Fourier Transform (FFT) simulation. This sums together different frequencies of simple waves to form a more complex one.

Swells, agitation, and ripples

One band of frequency produces broader waves called Swells (for sea, ocean, or lake surfaces). Swell parameters modify the amplitude, direction, and wavelength of larger Gerstner Waves. These approximate the effects of distant wind and/or the pull of the moon.

Larger waves determine the swells. Source: “Trochoidal waves,” Wikipedia

Agitation is the equivalent of swells but only for river surfaces. Whereas swells are optimized for larger bodies of water, agitation parameters simulate the more dynamic and turbulent conditions found in rivers.

Another band of higher frequencies simulates currents or local winds that produce Ripples. These are smaller waves that are close together and add fine detail to the water surface.

These parameters can be customized globally or per water body. Thus, different bodies of water within the same scene can have waves moving in different directions based on their local settings.

Simulation parameters
Simulation parameters control swells and ripples.

Current Maps

A Current Map is a 2D texture that dictates a water surface’s current direction and speed. Here, the texture’s Red and Green channels determine the direction, while the Alpha channel indicates its speed. Import the texture into Unity, then configure its settings for use in the water material or Volume override.

Follow these guidelines for creating your own Current Maps in third-party software like Photoshop or Krita.

Use the Miscellaneous > Debug Mode dropdown menu to preview the resulting current.

A Current Map shown through Debug mode

Procedural rendering
The water system uses vertex displacement for rendering water plane deformation. This procedural approach, similar to terrain rendering, works for vast expanses like infinite oceans or long rivers.

For the detailed rendering of minor ripples, HDRP uses GPU tessellation. This process subdivides triangles with specialized shaders, increasing triangle density near the viewer.

Water rendering uses GPU tessellation.

Deforming a water surface

A Water Deformer component can alter the water surface’s shape. You can choose one based on predefined shapes or customize the deformation using a texture.

Water Deformer components can influence one another additively when they are placed in the same location. For instance, stacking two one-meter box deformers results in an equivalent to a single two-meter box deformer. This offers you extra control and flexibility for shaping the water surfaces.

Add deformers to create a waterfall.

However, be aware of the maximum number of deformers that can be active simultaneously. Adjust this limit in the HDRP Asset via Rendering > Water > Deformation > Maximum Deformer Count.

Also, note that only a specific region of a water surface can undergo deformation. The size and offset of this confined region can be adjusted directly from the water surface’s Inspector window. For debugging, select Deformation via Miscellaneous > Debug Mode.

To create a deformation, navigate to GameObject > Water > Deformer and select the desired deformer type. For a water deformer to influence a water surface, the Water Surface must be enabled in the Deformation dropdown. Make sure this feature is also active in the Project’s HDRP Asset and the Frame Settings.

The properties available in the Inspector vary based on the type of deformer chosen. Use Scale Mode, Region Size, and Amplitude to control the size and height.

Water deformers come in different shapes.

Each specific Deformer (Sphere, Box, Bow Wave, Shore Wave, and Texture) has a unique set of properties, described on this documentation page.

Water Deformer component
The Water Deformer component

Adding foam

Foam simulates the white frothy water seen at the crests of waves or where water interacts with objects. This effect can help connect the water surface with objects making contact with it.

Surface foam

To activate foam for a GameObject, enable the corresponding checkboxes in the Water Volume component, and adjust the Foam parameters.

Currently, you only need to change two settings:

  • Foam Amount determines foam patch size and controls the overall strength and prominence of the foam effect on the water surface. Increase its value to make the foam more pronounced, or reduce it for a subtler effect.

  • Wind Speed Dimmer maps the amount of foam to the Distant Wind Speed parameter. Use the curve tool to determine the percentage of the Foam Amount to apply.

Surface Foam simulates frothy white water.

After fine-tuning these parameters, play the scene and observe how the foam behaves at runtime. Pay attention to where dynamic objects interact with the water or where the waves connect with the surroundings.

Foam parameters
Adjusting the foam parameters a Water Surface

Foam generators
When objects or characters move through water, they often disturb the water’s surface. You can also use a foam generator to stir up local foam to help integrate those objects. This can add white water for a boat trail or around rocks in open water.

The foam generator comes in three types: disk, rectangle, and texture-based. Adjust the parameters to control the foam’s size, depth, and intensity.

A foam generator creates local foam around an object.

More resources

Unity best practices hub

Advanced best practices page on Unity Documentation

See the Unity 2022 LTS updates to two of our biggest e-books: URP and HDRP for advanced users

The new Water System in Unity 2022 LTS and 2023.1

GDC 2023 talk: An overview of the new HDRP Water System

We hope you feel inspired to try out the new water system features in your Unity scenes. As usual, let us know in the comments if you have any feedback about the e-book or the video tutorial.

Thanks for reading!