Unity 6 HDRP Water Shorelines/ContactFoam

Hey, there’s an example of that in the HDRP Package Manager water sample scenes.

For example, you can download the samples, open the island scene and select the Ocean gameobject.
On this gameobject, you will see that it has a custom material under the appearance tab.

If you open the Shader Graph linked to this material, you can spot this specific bit

The idea is simple, it’s basically subtracting the scene depth (from the opaques objects) from the actual depth of the pixel. The closer they are together, the higher the value in the end, meaning, when the water is shallow foam will be added in the custom foam output. This will create this kind of effect.

As I said, it’s a pretty simple implementation and it’s far from perfect, but hopefully enough to get everyone started on making procedural custom foam from the shader graph depending on their needs.

Hope that helps.