Water Shader

I added in an effect where if the water isnt being rained on for a while, it will start to dry out. and it will leave a stain where it has rained.

Read on to See how i made this.

Hi Everyone, this this mini project i wanted to make a rain shader that makes a surface wet depending on where the water is landing.

To get this project started i did some research into what a wet surface looks like and how it differs from a dry surface and how different surfaces look.

You can see in this picture how the rain makes a surface such as stone look darker and increases the saturation such as the red highlights on the dry area are not as vibrant as the wet ones.

Also depending on how pouress a surface is the rain will be absorbed more and be less reflective. For example the surface above is very pouress so the rain gets absorbed into it.

Whereas a surface like this one is a lot less pouress so the water sits on top of it and becomes a little more reflective.

Ben Cloward does an amazing job at explaining this in further detail.

So i had my wet material, what i wanted now was to only have areas where the rain had fallen to be turned wet. So at the start it would be all dry but then depending on if the area has been rained on it would go wet.

I made this simple Rain fall using niagara which i then turned into a blueprint. and added a line trace to be able to check underneath the rain to see whether anything was hit or not. Such as the texture, And i could see that the texture was being picked up but i wasnt sure how to comunicate this to a 2d texture or a UV space.

So i knew from past experiences that i would have to some some form of dynamic textures that updates at runtime. but i wasnt sure as to what the right method was. initally i had thought it was an RVT in unreal. but then i thought the project would be too specific to unreal and i like to replicate my projects in different engines. So after doing some more research and testing i realised that RVT was not the correct method.

I then came across something called render texture when i was in unity and looked a little more into it and the first sentence which said “A Render Texture is a type of Texture that Unity creates and updates at run time.” So i looked into the unreal counterpart and it was a render target.

Using this piece of blueprint i was able to take the Hit location from the Sphere and translate into UV space and apply the texture to my material.

Using the Render Texture in my material i can apply a mask to where the rain hits and only make that area wet.

By creating a material function I was able to minimise the amount of clutter in my shader graph.

My Next goal is to make rain ripples where the rain lands and also to add puddles into the material Similar to this.

By combining a few normal maps i was able to get the ripple effect in the water.