Water Shader Tutorial
Contents
Overview
This tutorial will give you an overview and example on how to create a translucent water shader and has been updated to be compatible for engine version 4.13.1
Before you get started you can download the test project using the water shader in case you would like to quickly add it to your project or would like to reverse engineer the material.
Material Properties
Below are the settings used for defining the materials properties to render correctly with the instructions provided.
Base Color
What we are doing here is defining a dark water color and a light water color by using two Vector3 nodes. Then creating a falloff between the dark and light color using a fresnel which can be controlled by the exponent parameter. To increase the contribution of the color you can use the 'Diffuse Multiply' parameter.
Opacity
For Opacity we are using a single Depth Fade node to drive the overall Opacity and the distance at which it fades based on scenes depth. You can use this to create a shallow water fade effect.
Normals
The normals are important as this is what defines the waves size and speed. For the small wave panner the Speed X is set to 0.03 and the Speed Y is set to -0.02. For the large wave panner the Speed X is set to -0.1 and the Speed Y is set to 0.1. These values are chosen so the normals pan against each other creating a ripple like effect.
Wave Surge Height and Frequency
This section is optional functionality as it drives the waves up and down using World Position Offset. This effect can be used to add a more dynamic feel to your water so it rises and falls like wave washing against the shore.
Refraction
Here we are defining refraction using the Index of Refraction technique by combining a physically based value and lerping between a constant.
Constants
Below are the remaining connections needed to complete the material. They are simple constants that need to be converted to parameters for editing your material instance.
Material Instance Example
Below is an example taken from the project provided in the link at the beginning of the tutorial. The master material has been instanced and applied to a plane, and then suited to fit the scene using scalar parameters.
If you enjoyed this tutorial head to my Wiki Profile Page for more!