This was a puddle/wetness material function I created while working on a comprehensive landscape shader system. I found it works quite well as a standalone effect, so I wanted to break it down.
In this example the function has been used as a post-blending step in a landscape material, controlled by a landscape layer, but it could also be used on any other shader using a mask or vertex color with little to no changes. Also, using specular in the way shown may not be perfectly PBR compliant, but it's usually necessary for obtaining the correct look in Unreal Engine's shading.
Assets shown are from Megascans and the MAWI Broadleaf Forest Pack.
The goal was to allow for the full range of wetness values, from slightly damp all the way to fully submerged. Here I've multiplied the wetness amount by a sine wave to show the entire transition from dry to wet.
Because this function only needs the displacement and wetness amount as an input, it should transfer well to any PBR material that includes height.
In the use case of this landscape material, the artist can paint a target value in order to get the specific amount of wetness they desire.
Slope is also taken into account, so that only flatter areas will include puddles, as you would expect in real life. The strength of this effect is tweakable via parameters.