Stylized Water 2 - Underwater Rendering (Extension)
At this point you should already have the Stylized Water 2 asset installed. The Underwater extension will import directly into its folder. Without this installed first, you’ll be posed with at least one unsolvable console error.
Initial set up
Ensure the water mesh(es) in the scene have the “Water Object” component attached to them.
To enable underwater rendering in a scene, go to Window → Stylized Water 2 → Set up underwater renderer.
Assign the material that is used in the scene and set the water level to match the Y-position (in world-space!) of the water mesh. If there is only 1 water object in the scene, the water material and level will be automatically configured for you.
You’re now set! The waterline and underwater fog will automatically render once the bottom of the screen touches the water.
In order to prevent cracks between the waterline and the water surface. The water mesh requires a decent vertex count (eg. 4 vertices per unit).
Under the Advanced tab on the water material, you can enable Tessellation to ensure the vertex density is always high enough near the camera.
Fog and large worlds
It’s important to understand that the underwater fog is based on scene depth. If the terrain abruptly ends, showing a void/skybox, the fog will appear as 100% dense there.
Consider taking this into account and ensure the boundaries of your world does not have any holes. Most open world games have a stretch of land that goes beyond the playable area.
Controlling setting through volumes
On the Underwater Renderer component there is the “Use Volume Blending” option for the fog. When enabled, these settings are ignored, and will be controlled through volume profiles instead. If no volume has any underwater settings, the default values are used
Using volumes works just like any other volume component. For usage instructions, see the Unity manual.
For the time being, ironing out any possible bugs or usability issues have priority, since it’s a new asset.
Directional caustics support for versions older than Unity 2020.2 Option to use fast directional caustics (by reconstructing the required depth normals texture from depth) Disable rendering when in prefab edit mode C# API to change the water material and level more easily (this could be used in conjunction with triggers)
- Refraction masking for objects between the camera and water, when viewed from below
- Boundary rendering. Injects a hidden sphere into the fog, to avoid the end of the game world being visible in the distance.
- Camera entry/exit effects: Water washing over the screen when moving out of the water. And/or splashes as it enters the water. This all needs to be scalable and based on how fast the camera hits the water.