February 7, 2011

UDK Fluid Surface Actor Tutorial

I have been working on my senior project tonight, but I'm gonna switch gears and write a tutorial concerning the work I have been doing for my prototyping team. So here is a tutorial on the Fluid Surface Actor in UDK.

First off, what is it? Well essentially it is a plane with a large number of divisions which is designed to behave like the surface of a liquid, hence the name. This actor reacts by creating deformations in it's geometry which appear as ripples when the player enters it, weapons fire through it, or the Fluid Surface Influence Actor has an effect on it, but we will get to that later. Its time to get started!

First start by making a simple environment.  I simply created a hollow block of BSP with a light and it's walls textured with one of the materials from UDK's default packages. Open up the generic browser and go to the actor classes tab. Expand the Fluid menu option and select the FluidSurfaceActor. Now go back into your level and right click in your level and select add FluidSurfaceActor Here. The actor will appear with the default checker texture.

Now nobody wants to see that checkerboard texture, so lets make a simple material to spice it up. Lets make something that reflects the environment and also has a panning water texture on it to give it the appearance of flowing water. First we will need to set up reflection. Go into the generic browser and pull up the actor classes tab. Find and select the SceneCaptureCubeMapActor under the Uncategorized menu option. Go back into your level, right click and add SceneCaptureCubeMapActor Here, on the Fluid Surface actor. Its going to look like a sphere.

Now back into the generic browser. Within your package right click in an empty space and select new RenderTextureTargetCube. Give it a name and while you still have it selected go back into your level and select the Cube Map actor and open it's properties by pressing F4. Expand the Scene Capture Actor and then expand capture. At the top you will see Texture Target. To it's right click the green arrow the points to the left. That will assign the render texture target cube. At this point the cube should reflect the world around it in a chrome like fashion. If it isn't reflecting enough of the level you can open up the cube map actor's properties to fix that. Adjust the value for the far plane to the unreal units of the farthest item you want reflected. Also, be sure to enable post process, and select SceneCapView_LitNoShadows as the view mode.

Now its time to make that material. While in the generic browser with the RenderTextureTargetCube selected create a new material. When the material editor opens up hold T and left click in an open space to drop the texture sample into the editor. Also be sure to set the material mode to Translucent. This will give the water a level of opacity that you can control. Now drop in a constant by holding 1 and left click. Give the constant a value of 1.5. Now drop in a multiply by holding M and left clicking. Plug the Texture sample and the constant into the multiply. Plug the result from the multiply into the diffuse. You'll get an error but we'll fix that right now.

Now add a refection vector as well as a component mask. On the mask be sure to enable R,G and B. Plug the reflection vector into the component mask. Now plug the component mask into the uvs of the texture sample and there goes the error.

Go ahead and drop in a constant of .75 and plug that into the opacity.

Almost done with the material :)

Search for the Fluid Normal and drop that in. Plug it directly into the normal. This will help smooth out your ripples for a more realistic look. Now add a Multiply along with a constant of 50. Plug the Fluid Normal into the Multiply as well as the constant of 50. Plug the result of the Multiply into the distortion. This will help distort the reflection as a ripple passes through it. Be sure to go back to the main material properties and select Use One Layer Distortion under translucency.

Now you need a seamless tileable water texture. You can use this one or one of your own.


Once you have your texture it import it into your package. Back in the material editor with your water texture selected drop it into your material editor. Now let's make this water flow. Drop a panner in behind the water texture and plug it into the uvs. You will have to play with the values to determine which way you want your water to flow. Now dependent on the size of the fluid surface actor and whatever texture you happened to use you may need to increase or decrease the tiling of that water. If necessary drop a texcoord node in behind the panner and plug that into the panner. Play with the values to get the tiling you need.

Now to make it all work together Drop in a multiply. Go to the diffuse input, right click and break the link. Take the output of the multiply from the reflection and the plug that into the multiply you just made. Plug the output of the water texture into the same multiplier. Now all you have to do is plug that output into the diffuse. Now you should have a panning water texture over a reflective surface that reacts to all sorts of stimuli.

From here just apply the material to the Fluid surface actor and we can really get cooking.In order to put the finishing touches on this we need to make more than just the texture move. We will add some FluidSurfaceInfluence actors.

Go in the generic browser and find the actor underneath fluid and drop it in to a part of the water. Now there are 4 different options that I'll go over briefly to finish this up.

Fluid Flow does exactly what it says. Mess with the settings and get an effect you want.

Fluid Raindrops again does exactly as it says. Mess with those settings to get anything from light rain to a heavy localized downpour as if from a waterfall.

Fluid Wave creates an up and down motion of the water with a wave radiating outwards as per your instructions.

Fluid Sphere is really interesting to me.  It creates either a depression or rise in the water based on your settings. Great in combination with the other actors to create rapids.

Use these different actors together in different combinations to make all sorts of great effects.

One final word for those of you planning to use this as a large surface in a bigger level. Go into the Fluid Surface actor's properties and increase the values of Detail Resolution as well as Detail size to be sure that your water's deformation is visible from a greater distance.

I may make a video tutorial to accompany this, if I have time.

1 comment:

  1. Hi! I've been following your tutorial and I have to say its very informative. I seem to be stuck however, I don't see any water movement. Here's my material layout for reference. http://i.imgur.com/XF9Tv.jpg Any advice on what I did wrong? Can't seem to get my waves to work either. But thats a seperate issue.

    ReplyDelete