For some time I was wondering how to render rivers flowing on a terrain.
Using a special mask texture to choose where to draw the river in the pixel shader was an obvious solution, but how to make them flow?
Some days ago I've found a post on a blog talking about the way flowing water is simulated in Left4Dead 2 and Portal 2, linking to a Valve document written for the Siggraph.
This paper is mainly about using a "flow map" to scroll the water normal map in a given direction. For me, the most intersting thing in this paper is how the normal maps are scrolled.As I don't really want to generate a flow map, I just used the terrain normal to retrieve the flow direction, because basically, the water always flows the direction of the slope.
Then, having a normal-mapped water flowing in the right direction, I just added some basic fresnel & specular reflexion to give it a nice look.
**!NEW VIDEO!**
Here, a video, my terrain geometry hasn't any true riverbed so sometimes it's quite strange in video, but globally it's working.
The necessary screenshot:





