Water Shader Tutorial

From Epic Wiki

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.

Water Shader Example Project

Material Properties

Below are the settings used for defining the materials properties to render correctly with the instructions provided.

Material Details


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.

Base Color


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.

Opacity and Refraction


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.

Normals: Click to Enlarge Photo


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.

Wave Amplitude and Frequency


Refraction

Here we are defining refraction using the Index of Refraction technique by combining a physically based value and lerping between a constant.

Refraction Graph.png

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.

Single Constants



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.

WaterExample.png


If you enjoyed this tutorial head to my Wiki Profile Page for more!