The water in Barely Breathing stays clear enough to see Sheen, foams at the edges and moves when you pick up a container. Jaspreet Singh Matharoo explains how they made it.
The water mesh has a thin outer layer, made with Blender’s Solidify modifier. Jaspreet flipped its normals and gave it a separate material. Foam appears on the inside, but not on the outer layer, where it could get in the way of seeing Sheen through the water.
He also wanted nearby objects to show through more clearly. A custom depth fade checks the distance to what’s behind the water and uses it to change both its transparency and color.
Getting the foam in the right places took more work. A Fresnel effect alone left a flat white patch across the surface. Jaspreet painted the top of the water into one vertex color channel to remove foam there, then used another channel to mark the edges where foam should appear. Animated noise breaks up the outline so it isn’t perfectly smooth.
Changing the colors and foam settings lets him use the shader for other liquids too, including tea, coffee and gutter water.
For water that flows, Jaspreet painted a separate foam texture and scrolls it across the mesh. On a falling stream, the UVs run vertically so the foam moves downward. He uses the same idea for water running along a gutter.
The water inside a moving container is
a shader effect rather than a fluid simulation. A height setting determines how full it looks. A script reads the container’s velocity and drives two rotations in the shader, making the surface wobble. Jaspreet credits
MinionsArt for the wobble script.
There was one more problem: using only the container’s coordinates made the water tilt rigidly with it. Using only world coordinates kept the surface level, but left the waterline behind when the container moved upward.
Jaspreet combined the two so the waterline follows the container while the surface can still wobble. A second height cutoff, placed slightly below the first, adds a thin band of foam that moves with the waterline.
Keep exploring Unity shaders.