Search my Blog

Wednesday, 17 October 2018

How I created the rain in unreal engine Part 1: Baking Normal Maps

Yesterday I showed off dynamic animated rain on materials on objects. Today I will be showing how I created them.

First off we need normal maps. To do this I used blender and created rain splashes and drips using the built-in dynamic painting system to create ripples on a plane using a particle system as the brush.

To set this up you create a plane, go to the physics tab at the very right and add the dynamic paint modifier. Create a canvas and change the surface type setting in the dynamic paint advanced section. Then you adjust the speed to 0.5 (50%) and the play around with the samping, spring and smoothness setting to the right of it. This will change the appearance of the ripples that will be created.
Note: the plane also has to be subdivided lots because it determines the quality of the ripples.

To create the rain you add another plane, raise it above the other one as show in the picture, then to to the particles tab and add the rain. Under the emission section the number is how much rain it will create, so the higher this number is, the heavier the rain will become. Un-check the even distribution and make sure it is set to random and not jittered as rain in real life is random. Just a bit lower under the physics section, instead of it being newtonian you want it to be a fluid and check die on hit.
Once that is done, all you need to do is to go to the physics tab and click on the dynamic paint modifier, this time create a brush and set the paint source to be the particle system you just created. Now you have a working rain splash animation.



I created a material for the splashes in cycles by using the geometry node and splitting it off in to the different colours and adding 1 to them, multiplying them by 0.5 and then, combining them , plugging it in to an emission for removing shadows and lastly connecting it to the surface output.

Lastly we are ready to bake the normals. To do this we first move the camera to the top of the plane with the splashes. To hide the plane that spawning the particles we go to the object tab and go all the way down to the bottom and in the cycles section uncheck everything, then in the hierarchy view where you see all your objects press the eye icon on the plane and this will hide it from our view while still being able to see the splashes created by it. once you have aligned the camera with the plane you then set the resolution of the camera to something like 2048x2048 and reduce it to 25% because the higher the resolution is, when we go to stitch the animation later, the tool we will use will stitch the textures together forming one large image, in my case for 512x512 bake of the normals will produce a 4k image to be used in the engine so if we were to use 2048 the final texture could easily be over 24k, which would most likely kill your computer unless you have a beefy system with 16GB or over with enough vram on you gpu! We use a single texture strip because this is what the engine takes to create animations and it could be compressed if you were to remove all the space you are not using such as the space between the puddles.

After you have exported the animation as a png sequence, you can use tools such as Leshy to stitch them together and remove the space that's not needed.

Here is a gif of the final animation:

Here is a video I have made showing these steps


No comments:

Post a Comment