Stylized Water 3 – Underwater Rendering Documentation

Stylized Water 3 - Underwater Rendering (Extension)

Stylized Water 3 - Underwater Rendering (Extension)
Version: 3.2.2
Review

6.Transparent Materials #

Combing transparent materials with underwater rendering has it’s challenges. You will also notice some particle effects being visible through the fog in the demo scene (eg. river/waterfall). This is simply inherent to how (non-raytraced) transparency rendering works. A compromise has to be chosen.

The underwater fog renders as a transparent material in front of the camera. Both it and the water shader work with a stencil to ensure they create a cohesive effect together.

This means that any other transparent material will:

  • Appear to render completely unfogged.
  • Appear (partially) invisible under water

By adjusting the Render Queue you can control which of two occurs. Transparent materials have a render queue of 3000 by default.

On any material you can offset the render queue through the “Sorting Priority” parameter. For example, the particle effects (bubbles, sunshafts, etc). Have a Sorting Priority of +2

On the Underwater Area component you can control the render queue of the underwater effect.

3000 is the render queue value of the assigned material

For correct shading of underwater rendering and transparent materials together, see the sections below.

Fog rendering

The effect relies on the depth texture Unity renders, which provides a means for shaders to measure the distance from the camera to an object’s pixel on screen. Based on this distance, a certain amount of fog is applied.

As such, shaders that don’t support depth writing will not be affected by fog. This usually means:

  • Transparent materials (water/particles/etc).
  • Sprites.
  • UI elements
  • Details/grass rendered through the terrain system.
  • Custom shaders without a DepthOnly pass.

These materials will either turn invisible under water, or completely unfogged!

The only way around this is to incorporate the fog shading into custom a shader for the above purposes, and using that instead. This is how Unity’s standard fog works, which applies fog directly to an object, rather than as a post-processing effect.

Use the Stylized Water 3/Underwater Transparent shader on particle materials that are used underwater

Incorporating underwater rendering into another shader

You may have a custom transparent shader, for example a fake volumetric light beam or weapon VFX. These will need to incorperate underwater rendering.

Hand-written

Hiding a transparent material under water: https://pastebin.com/vEVN2EZu

Blending a transparent material into the underwater fog: https://pastebin.com/gk66GhUG

Shader Graph

Familiarity with Shader Graph is assumed for this section!

You can implement correct underwater shading by following this example structure:

In the StylizedWater2/Shaders/Underwater/Shader Graph folder you’ll find all the functionality needed to add support to a transparent shader.

As an alternative, use the Stylized Water 3/Underwater Transparent shader on particle materials that are used underwater (such as the light rays in the demo scene)

Amplify Shader Editor

Use the included Underwater Mask node.

This applies to the COZY and Atmospheric Height Fog assets, since their shaders are authored using ASE.

For example, it can be integrated into AHF’s fog shader, limiting its visibility to pixels above the water.

COZY already has this node pre-integrated

Yes No Suggest edit
Last updated on June 2, 2025
1 of 1 users found this section helpful
If you're familiar with this asset, please consider leaving a review!
Your support is what makes complementary updates possible!
Suggest Edit