Water Shader

Welcome to this showcase of our stunning water shader created in Unity using Shader graph! In this post, I will showcase the capabilities of our water shader, the problems we encountered and how we dealt with those obstacles. So, let’s get into it!


This shader is fully adjustable.

Our team decided to give the water shader a volume instead of a simple plane to achieve a richer and more dynamic look in our game world. By creating a 3D water volume, the water can have better reflections and is able to blend in better with the environment which results in a more immersive and believable experience for the player. Additionally, a volumetric water shader allows for the creation of waves, ripples, and other dynamic movements that enhance the overall look of the water and make it feel alive. Overall, using a volumetric water shader is a key component tool for creating a believable and immersive game environment 

In order to make some simple waves, we use sine / cosine waves. We can control the wave height, frequency and wave speed.
To have some beautiful colors for the water shader, we used the subtract node in combination with multiply and clamp to essentially make a distinction between deep and shallow water. After that we simply lerp the those two depths with two colors for both deep and shallow water. This will create a believable depth effect.
There are two available normal maps for the water shader, these add some unevenness and noise to break up the wave pattern a little bit. Lastly, we scroll those two normal maps against each other.

Mesh Generator

In order to achieve the quality and consistency of our water shader, we created a mesh generator to dynamically create the water volume mesh. By generating the mesh dynamically, we are able to ensure that the water textures and normals do not get stretched or distorted. This allows us to maintain the smooth and believable look of the water. The mesh generator also provided us with greater control over the shape and form of the water, it would be a huge waste if we had to model every different size for all possible water sizes. Overall, using a mesh generator was a key factor to improve the workflow of integrating water in our world. 

Rendering issues

Just compiling the shader isn’t enough. There are still extra steps to take to fix some underlying issues. One example is the clipping / rendering artefacts we have encountered. This is where forward renderer assets come in. This asset gives you control over how the rendering is done based on objects on a certain layermask. With the most important feature; being able to control how the depth buffer interacts with a certain object. It fixes most of our transparent shader, but it is not perfect. There are still some minor clipping artefacts if you look directly from under the water shader up.