Realistic Waterfall which flows according to geometry of surface?

Can I create waterfall shader in unity in which water flows according to the geometry of the surface on which water is flowing?

Something like this

I have succeeded in creating this waterfall shader so far…

http://dl.dropbox.com/u/55556065/water%20fall/WebPlayer.html

But it doesn’t work according to geometry…

Not to be R18 but when you come close to waterfall and look up, the particles look like spermies.

It might be done using 2 ways, 1st with a very good uv mapped and well conformed water geometry, 2nd with calculating the normals of the ground geometry and adjusting the uv of water geometry according to in a shader.

Very hard work to make a generic shader to suit every condition though, good luck.

You could make a tool that creates a river mesh along the surface of a terrain, but I believe that Six Times Nothing has already made this… River Tool | Terrain | Unity Asset Store , although, I remember there being a breaking glitch between the tool and the keyboard.

I worked on this problem on UDK. See my implementation here: http://www.pixelbeam.org/shader2/capture-2.mp4

You can not do this ‘automagically’. The best way to do this if you want to have a “multipurpose solution” is to build a shader and tell him how to flow water by painting the mesh vertexes with specific colors.
It is also possible to use a flowmap instead of painting the vertex but personally I think it’s faster to do it with vertex paint because with UDK you can do it right away from within the editor and see the result in real time.

Basically I’m playing by panning UVs , then I use 2 vertex color channels :
Red for X axis and Green for Y axis.

I can then move the “flow” of the water in any direction in the following way:
Painting RED bellow 128 will pan the UV on the left, painting above 128 will pan UV on the right
Paingint Green bellow 128 pan the UV down and of course painting above 128 pans UV up
The more I paint above or bellow 128 the faster the water streams.
If I leave it on 128 water symply stops. I could go deeper into the shader and perhaps let him know in case of 128 to move the water randomly but without an actual flow direction but I didnt do that.

I use the Blue vertex channel to paint bubbles.

To make the shader look better you could use 2 or 3 transparent flow layers, and perhaps use the alpha vertex channel to paint dark (deeper) or lighter spots on the water to give depth impression.

It’s a bit confusing at first to paint the flow on X Y but once you get the grip it goes pretty smooth with a lot of fun and defenetly will make you win a lot of time if you have two or more places to use it.

Regards.
David

2 Likes