Monday 8 June 2015

Puddles!

I wanted to add some puddles into the scene. I checked out the awesome article from the "Remember Me" guys (https://seblagarde.wordpress.com/2013/01/03/water-drop-2b-dynamic-rain-and-its-effects/) and it seemed pretty straight forward on how to do it, except that I wanted to have the puddles on UE4's Landscape and not a static mesh, so it quickly became a bit less straight forward :D.

While in general it worked, the main problem was that there is no way to get the value of the landscape paint layer (or at least none that I could find) the way that you can get the value of the vertex color that is painted on a static mesh. It was important because the value controls the transition between puddle and dry land in the material to tell it how saturated / opaque it is etc.

The solution was... pixelz! I created a black and white texture mask where I wanted to puddles to be and then I was able to plug it in my landscape material on top of the landscape paint layers to add the puddles in. Not the best solution, but for a small scene like this it worked well and because it was a texture, I was able to get the value of it to control parts of the puddle material where normally vertex color values would be used.

Since the landscape is pretty huge and it would require the texture mask to be gigantic in size, to get better texel density I tiled the mask on the terrain in the way where the puddles still roughly align to where I originally wanted them to be, and then any of the ones that end up repeated around are removed using another mask which can be low resolution.




I also decided it would be nice to add some subtle wind to the puddles, since the scene is a bit windy. A quick and dirty approach for now was to pan a tiling wavy normal map across puddle, which is lerped with a flat normal and the alpha of the Lerp is controlled by Time plugged into Sine nodes and randomized a little.





No comments:

Post a Comment