Im stuck developing an important detail of my game water: Making it flow downwards!

Considering a typical 3D world in wich water tends to go towards gravity g=(0,-1,0) , and having the normal of the water surface n=(x,y,z), how can I calculate, based on that, the water flow direction vector?

As an example, consider this badly-done graph (In 2D, though)

Water flow graph

Update: I'm considering a very simplified water surface (Just a plane: No ripples, no waves, no pressure, etc.). If any of those needed to be applied, the answer would depend on more factors than just the normal.


One way to do it, considering you want a 90° angle, is to find the cross product of the normal and gravity, normalize it, then cross that with the normal again.

In your diagram, the first cross will produce a vector pointing into the screen, and the second cross will produce the flow vector.

An interesting side-affect of using cross products is that the flow vector will be longer the further the normal vector is away from vertical, which could be used for flow speed?

This assumes you are using a right-handed coordinate system, if your system is left hand, the intermediate vector will point out of the screen instead, but will still produce the same result.

  • \$\begingroup\$ Yeah, that looks great. Even it looks so simple when explained, I spent like half an hour thinking about different (wrong) ways of doing it, and i missed this one completely. Thanks! \$\endgroup\$ – Ivelate Mar 29 '16 at 20:30
  • \$\begingroup\$ This won't produce anything that remotely resembles what you would normally think of as a direction of flow. To see why consider what the surface normals of a river flowing across your map would be and how they're going to differ in a river flowing east to west and west to east (i.e. they're not). \$\endgroup\$ – Jack Aidley Mar 30 '16 at 12:58
  • 1
    \$\begingroup\$ What if the normal and the gravity are (anti)parallel? I can't help but find no sense in this answer. As @JackAidley said, there are infinitely many possible flow directions given a normal. \$\endgroup\$ – Margaret Bloom Mar 30 '16 at 14:36
  • 1
    \$\begingroup\$ Given the simplified model presented in the question, I believe this answer will produce the vector they were looking for. @Margaret If the vectors are (anti)parallel then the flow vector will be (0,0,0) which would be the expected flow in a flat body of water, i.e. a pond/lake \$\endgroup\$ – KingPin Mar 30 '16 at 19:45
  • \$\begingroup\$ @KingPin: A river is also a flat body of water, and most lakes flow out to rivers. \$\endgroup\$ – Jack Aidley Mar 31 '16 at 8:50

You cannot determine the direction of flow of water from its surface normals, you will need to store additional data.

A simple trip to look at a river should be sufficient to convince you of this. Any difference in the surface normals merely reflects rippling in the surface, the mass of water continues to flow in the same direction. But the underlying reason is because the normal defines a plane and you need a vector of flow. Your vectors are about the shape of the surface not the movement of the water.

  • 1
    \$\begingroup\$ True, you are right. I was considering just a very simplified water body (No ripples, no waves, no pressure, etc.), but certainly in real life this calculation wouldn't be so simple. Im going to update the question to make those details clear. Thanks for your input! \$\endgroup\$ – Ivelate Mar 30 '16 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.