Flow Shader Fix / Flow Editor

So first of all, I’ve fixed a little bug in the water flow shader which basically inverted one of the texture coordinates and made all of the flow animations look weird or just wrong. This is how the flow map from my last tutorial looks in action now:

And it’s WAY more impressive when animated!

Next, I thought that the way of creating flowmaps I’d described before is a little bit too complicated and so I created a little flow editor in Qt to make preparation of flowmaps more straightforward. You can sketch the flow as you see fit and the rest will be interpolated using Natural Neighbor algorithm. Due to the nature of NN the more flow points you add, the faster it works (recomputation of Voronoi diagram is faster, read NN description if you want to understand). The example flow field takes just a couple of seconds on one 3GHz core.

And this is what it looks like in Unity with little debug info added:

and without debug:

It’s WAY WAY more impressive with animation, you can actually see the water interacting with obstacles. I tried going back to Simple Daylight Water from Unity and it looks like a child’s play now when my water is INTERACTING with the environment. Pretty cool. Thanks Valve (guys from Valve came up with this idea at SIGGRAPH 2010), GraphicsRunner (guy who wrote all about it and prepared a demo in C#) and Alzahiel (guy who prepared the initial port to Unity). I’ve modified Alzahiel’s shader a little bit and now I’m contributing the flow editor. Enjoy! 🙂

DOWNLOAD: Flow Editor

PS. You can also try the updated monkey game

DOWNLOAD: Monkey Dodge – Unity Game


  • The flowing water looks remarkable, and I tried using Alzahiel’s code (with some fixes) within Unity for a small project. However, I couldn’t get the water to flow, then I got a few too many coding errors. Could I be able to look at your version of the shader to see where I went wrong?

        • Darn, I forgot to do it again. I will when I get back from a delegation. But it’s very simple really, I had to fix a couple of lines in Alzahiel’s version, notably I removed this whole noise stuff which probably makes the effect a little bit less realistic but I didn’t quite get it how the noise is supposed to be used so I’m just interpolating between the two normal maps with half cycle animation offset. I would say it works very good given that I actually use the same normal map for both lol 😉 With different maps + noise it would look even better. I will post it.

          • Thanks,

            it just everything else works but it just doesn’t flow according to the flowmap (used with your editor ) it doesnt flow at all

            Waiting for your version

Leave a Reply

Your email address will not be published. Required fields are marked *