The water system was the result of a great cooperative partnership between our shader programmer Nelson Kossuga and me.
The floating components (FloatComps) can be seen in action in the top two gifs as the tiny spheres attached to the sides.
When above the water a gravity force is applied on the FloatComp which gradually increases in magnitude over time. When below the water a constant buoyancy force is applied to the FloatComp, the force exponentially grows the deeper the FloatComp gets.
My FloatComps send their current X and Y coordinate as well as the world time to Nelson’s math function in order to generate a Z height that represents the water surface line. The math function contains the same equations as the shader does. This way we can make sure the water shader’s visuals are synced with the game’s physics. Which allows us to measure if a FloatComp is above or below the water shader and determine what to do with it.