Underwater view
Underwater is rendered as a fullscreen postprocess effect. It uses either a simple analytic formula to estimate light absorption by the water volume, or if volumetric fog is enabled, it will be included in the vbuffer and rendered using volumetric lighting, supporting god rays and light shafts from shadows.
Define the underwater area
To change the area where the camera displays an underwater view for a non-infinite water surface, use the Volume Bounds setting. Follow these steps:
- Create a GameObject with a collider component, for example a cube with a Box Collider component.
- Place the GameObject where you want the underwater view to be visible.
- In the collider component, select Edit Collider to set the size of the visible underwater area.
- Select the water GameObject.
- In the Inspector window, under Appearance, under Underwater, set Volume Bounds to the GameObject you created.
To set the area of the underwater view for an ocean, follow these steps:
- Select the ocean GameObject.
- In the Inspector window, under Appearance, enable Underwater.
- Adjust Volume Depth.
Water line
When the camera is at the limit of the water surface, the underwater view adds a boundary when transitioning from below to above the water's surface.
Additionaly, to customize even more the water line, you can sample the generated underwater buffer in a Custom Pass by using the HD Sample Buffer node from the Shader Graph using the "IsUnderwater" option from the Source Buffer dropdown.
See the Waterline scene in the HDRP Water samples for more details.
Limitations
- When using a custom mesh, underwater will not behave as expected if mesh is not at 0, or if the mesh isn't flat.
- The Receive Fog option on transparent materials will also disable underwater. This can be useful to disable absorption on objects when using excluder underwater (like a porthole in the hold of a boat), or simply as an optimization when it is known that fog will not affect the object color.