Normal based flowmap





 Hi, today Ill post a cheap technique that I discover recently. It comes in handy for terrain rivers, global rain, lava, quicksand or any fluid like material.

The point is to use the normal of the object to guide the flow of the texture, so lets start first creating a simple flow panner:


Flow Panner



A flow panner is composed of a panner, another panner with a 0.5 delay and a lerp that shows the first or the last. Changing between panners achieve a continuous movement in one direction, without "running out" of texture.

Lets create a simple panner, here Im using a checker texture from the engine content:








So far so good, lets create another one with a different so that the position is allways "half texture behind the first". To be more accurate, lets say that the first phase is 0 and the second 0.5.

In other words, we can say that the phase is the amount of offset the texture has without repeating itself (kind of like a frac, from 0 to 1).







We got two nice samples, but how are we gonna interpolate between them? For that we need a linear function going from 0 to 1, from 1 to 0 and repeat. A simple ping pong function. To keep things simpler, we are gonna use the linearSine node as this node does exactly what we want:









Now lets create that lerp and voalá! A simple flow panner:

*Ive added a couple of frac nodes so the panner doesnt break with float precision loss after some time.
 
Not very interesting isnt it?
 


And you may ask yourself, why is it worth the trouble? Well, this way we can panner the texture in any direction we want without breaking it. Lets spice things a bit with with a simple normal map and a noise texture:




 
 



As you can see we can feed a -1 to 1 value in the distorsion range so the flow goes in that direction, in this case we used a normal map, but usually a flow map is made for specific cases.

Now that we know how the flowmap works, lets use it to create a world based flow.


Normal based flowmap


To get a uniform world flowmap we just need to use the world normal as our flow vector:










Easy terrain flow!


If we want to use this in a landscape, this will be enough. But notice that the normals facing down flow up. This is a side effect of the normal direction going to 0 again.

For now lets end here, have fun with cheap terrain flowmaps!

Comments

  1. Your posts are amazing, I would like to read more. Thank you very much!

    ReplyDelete
    Replies
    1. Glad you like it! Got a couple more planned soon :)

      Delete
  2. Thx for sharing it (͠≖ ͜ʖ͠≖)👌

    ReplyDelete

Post a Comment