Underwater#

Crest supports seamless transitions above/below water. It can also have a meniscus which renders a subtle line at the intersection between the camera lens and the water to visually help the transition. This is demonstrated in the Main.unity scene in the example content.

For performance reasons, the underwater effect is disabled if the viewpoint is not underwater.

Tip

Use opaque or alpha test materials for underwater surfaces. Transparent materials may not render correctly underwater. See Transparent Object Underwater for possible workarounds.

Underwater Renderer#

The Underwater Renderer is built into the Water Renderer and executes a fullscreen underwater effect between the transparent pass and post-processing pass.

It is similar to a post-processing effect, but has the benefit of allowing other renderers to execute after it and still receive post-processing. An example is to add underwater fog correctly to semi-transparent objects.

Tip

You can enable/disable rendering in the scene view by toggling fog in the scene view control bar.

Setup#

  • Configure the water material for underwater rendering. Under Surface Options make sure both sides are enabled with either Render Face to Both or Double-Sided enabled.

  • Enable Crest Water ‣ Underwater ‣ Enabled.

  • Make sure that Crest is set to the underwater material.

Note

If you are using the underwater effect in URP, it is recommended to set Opaque Downsampling to None. Opaque Downsampling will make everything appear at a lower resolution when underwater. Be sure to test to see if recommendation is suitable for your project.

Appearance#

The underwater effect gets its appearance from two sources: the water material and the underwater material.

The water material can be overriden by setting Water Renderer ‣ Volume Material to a material variant of the water material. Not every property on the water material affects the underwater effect. To see what can be overriden, see the read-only properties on the underwater material.

The underwater material has more properties which can further adjust the underwater effect.

Detecting Above or Below Water#

The Water Renderer component has the Viewer Height Above Water property which can be accessed with WaterRenderer.Instance.ViewerHeightAboveWater. It will return the signed height from the water surface of the camera rendering the water.

There is also the Query Events component which uses UnityEvents to provide a scriptless approach to triggering changes.

Portals & Volumes#

Underwater rendering can be restricted to a mesh.

Please see Portals & Volumes.