#5 - Water Shader

#5 - Water Shader 

Been a busy week, but in the evenings I've been working on getting a river water shader, and a spline-mesh blueprint created.


This is the result. A lot of the techniques used were learned from PrismaticaDev's excellent tutorials.

The base of the material is Unreal's SingleLayerWater shading model, which does a lot of the heavy lifting in terms of matching the properties of water and handling things like Translucency, Scattering and Absorption.

The flow effect is handled by two panning normal maps, currently using maps that come as default with UE5. The two maps pan in different directions, relative to the UVs of the object they're applied to.

The shader also includes ripples, edge-foam, and world-position offset, driven using Distance Fields. The "DistanceToNearestSurface" node creates a gradient mask on the object, based on how close it is to surfaces, the result of which can be manipulated to create these kinds of effects automatically.

This effect works for where the water meets the landscape, as well as for any rocks or other objects placed in the water.

The river mesh itself is a simple, subdivided plane mesh:


This mesh is tiled along a spline, using a spline-component blueprint. The blueprint automatically spawns new planes along the length of a spline and inherits their start and end positions, rotations, and scales from the spline points themselves. The blueprint itself looks like this:


And placed in the world, following the river bed, the spline looks like this:

Going forwards, it would be nice to get a more stylised water normal map, and a more stylised foam texture.

Next I'll be working on the long-overdue trees.


Comments