· shading · 9 min read
Stylized water: depth, bands, refraction and foam
How the toon water I made in 2025 in Shader Graph is built: everything comes from scene depth, from the banded color to the foam, and vertex waves set it in motion.
Goal
A toon water for URP built in a single Shader Graph, SG_StylizedWater, with three Sub Graphs: SbG_DepthFade, SbG_TextureMovement and SbG_WavesMoment. Color, transparency, foam and refraction strength all come from one value: how much water there is between the surface and whatever lies beneath it.

The graph is Unlit and Transparent, casts no shadows and needs the Depth Texture and the Opaque Texture enabled on the URP Asset. Every phase capture comes from the same scene and the same material, with whatever hasn’t been explained yet turned off: foam alpha at 0, refraction and waves at 0.
Depth as the base
SbG_DepthFade subtracts two depths. The Scene Depth node, in Eye mode, gives the distance from the camera to the opaque surface behind the water. Screen Position in Raw mode carries in its w channel the distance from the camera to the water surface. The difference is the water thickness along the view ray; divided by DepthFadeDistance and saturated, it is 0 where the water touches something and 1 from that distance on.
view full size (opens in a new tab)
That value is used three times: for the color, to hold back refraction at the shoreline and, with another distance, for the foam.
Color in HSV
Depth blends from TopColor (shallow water) to BottomColor (deep water). The blend is not a plain Lerp: it is a Custom Function, HSVLerp.hlsl, that converts both colors to HSV, interpolates hue, saturation and value, and converts back to RGB. The hue takes the short way around the color wheel:
half d = B.x - A.x;
if (A.x > B.x)
{
half temp = B.x;
B.x = A.x;
A.x = temp;
d = -d;
T = 1 - T;
}
if (d > 0.5)
{
A.x = A.x + 1;
hue = (A.x + T * (B.x - A.x)) % 1;
}
if (d <= 0.5) hue = A.x + T * d;
An RGB Lerp between two saturated colors passes through a grayer middle; in HSV the saturation holds. Alpha is interpolated separately, with the original T, because alpha later decides how much of the background shows through.


Smooth or banded
An enum keyword, Fade Method, picks between Smooth and Steps. With Steps, depth first goes through a Posterize with ColorSteps steps (floor(x × steps) / steps), and the color comes out in stripes like contour lines. Since it is a keyword, each material uses a variant compiled with only its method, with no branch inside the shader.
view full size (opens in a new tab)
Refraction with Scene Color
The water doesn’t rely on material alpha to be transparent: its alpha is 1, and it draws what’s underneath itself with the Scene Color node, which reads the Opaque Texture. That’s what lets it distort the background.
The distortion comes from a single normal texture sampled twice. Both samples go through SbG_TextureMovement, which scales the UV by RefractionScale and offsets it by Time × Speed, one with RefractionSpeed and the other with its negative. The two normals cross and are combined with Normal Blend; Normal Strength adjusts them, and the result is multiplied by RefractionStrength × 0.2 and by depth. That last factor turns refraction off where the water touches something, so the shoreline and the objects don’t warp at the edge. The vector is added to the screen position, and that UV samples the Scene Color.
view full size (opens in a new tab)
view full size (opens in a new tab)At the end, a Lerp blends that distorted background with the water color by its alpha. The lagoon’s TopColor has an alpha of 0.11 and its BottomColor 0.74: at the shore you see almost only the background, and in the deep parts almost only the color.

Foam
Foam reuses SbG_DepthFade, this time with FoamAmount as the distance, which is shorter. The result times FoamCutoff is the edge of a Step against a Gradient Noise that scrolls through SbG_TextureMovement (FoamScale, FoamSpeed). Where the water touches something the edge is 0 and all of the noise passes: solid foam. Further out the edge rises and only the noise peaks pass: broken foam. With a FoamCutoff above 1, nothing passes beyond that.
view full size (opens in a new tab)The mask is multiplied by the alpha of FoamColor and blends the water toward that color. Since alpha also rides along in that blend, the foam is opaque even where the shoreline water has almost no color.
view full size (opens in a new tab)
Vertex waves
SbG_WavesMoment moves the vertices in object space. It adds to the height a sine that advances with time and depends on the X position. In the main graph it takes three properties and its output goes straight into the vertex Position.
view full size (opens in a new tab)Written in HLSL, the Sub Graph comes down to this line:
y += sin(_Time.y * WavesSpeed + x * HighFrequency * 6) * WaveAmplitude;
view full size (opens in a new tab)The waves only travel along X, and their resolution depends on the mesh: the lagoon is a 151 × 151 vertex grid over 30 m, one vertex every 20 cm. Since depth is computed per pixel with the surface already displaced, the bands and the foam line rise and fall with each wave at no extra cost.

Presets
The same shader drives four waters that only change material values: the lagoon from the earlier captures and three pools, tropical, toon and swamp.

| preset | method | DepthFadeDistance |
ColorSteps |
RefractionStrength |
foam (FoamAmount · FoamCutoff · FoamScale) |
waves (WaveAmplitude · HighFrequency · WavesSpeed) |
|---|---|---|---|---|---|---|
| Lagoon | Steps | 6.38 | 6 | 0.15 | 0.5 · 1.04 · 198.9 | 0.07 · 0.28 · 1.2 |
| Toon | Steps | 2.6 | 4 | 0.03 | 0.55 · 0.97 · 24 | 0.04 · 0.6 · 1.5 |
| Tropical | Smooth | 1.6 | — | 0.12 | 0.3 · 0.985 · 30 | 0.04 · 0.6 · 1.5 |
| Swamp | Smooth | 0.9 | — | 0.06 | 0.25 · 0.975 · 18 | 0.02 · 0.4 · 0.5 |
Colors come in TopColor to BottomColor pairs, with their alpha: lagoon #4DF2E0 (0.11) to #005C9E (0.74), toon #8CEBFF (0.55) to #144DB3 (1), tropical #59F5D9 (0.2) to #008CB3 (0.85) and swamp #738C40 (0.55) to #1F3314 (0.97). The swamp also tints its foam green, #BFCC8C, with an alpha of 0.9.