Simple Water Shader using Shader Graph
Hey, during my current development I discovered a nice and simple way to create a clean and fast water shader.
It took me only about 10 youtube videos to put the different parts together, but you don't have to anymore. There is of course still room for improvements, I'm not an expert, but its incredible what you can create in a couple minutes using shader graph, compared to coding everything yourself.
To start off, you need a water normal map like this, there are plenty on google, creating one yourself is a topic for another time.
Now be sure to open unity and install the shader graph (currently only working for the hd and lightweight render pipeline).
In the end, you will have something like this.
At first were adding a time node, because we want something to be moving, the viewer should get the illusion that the water is actually flowing. Now multiply that with a vector1 that resembles the speed of the animation. I also exposed this one so we can edit it within the Inspector later. (Just right click - convert to property). As you might have already noticed, in this water shader are two textures that are moving at different speeds, so create two new multiply nodes after the first one. Now multiply the value with the x-axis of a vector2 node. (-1 seems to work fine, just try different values)
Create two tiling and Offset nodes now and plug the multiply nodes into the offsets.
Now create two sample texture 2D nodes and input your water normal texture and plug the tiling and Offset nodes into the UV slots. After that, combine both with a normal blend to create our final normal map. You can plug that into the normal channel of your master node now.
Now to the color, which is not too hard, because, as you know, water takes most of its color from the environment. But we want to tint it anyway. To get a cooler effect, we start with a Fresnel Effect node that will serve as a mask for different colors for the outer and inner parts. Now create a Power node and a Vector1 and combine the Vector and the Fresnel in the Power node to soften the effect. Next, create two Color nodes (I exposed these too) and plug them into a Lerp node. And Last but not least the Power node into the T slot of the Lerp node. That's our final BaseColor, so plug that into your master node.
Now, you may want to check that your smoothness value is pretty high up, something around 0,80 works pretty fine.
In the end, your node tree should look something like this.
Now you got your own simple water shader.
Hope this was helpful,
Hanesto


















