Monday, 25 June 2012

Making Ocean Water

Here's a hopefully quick tutorial on how I did the water in the Steve fishing video. This isn't exactly realistic water, so if you want that look up another tutorial on YouTube or somewhere. This is just a technique to get quick, stylized, and somewhat interactive water.

This isn't a fluid simulation by the way, the core of this is the Ocean modifier. Add a plane, go into the modifiers and select Ocean. I'm doing this on 2.62 by the way, I'm not sure how many other versions have this modifier since it's a fairly recent addition. If you don't have it you might want to update.

So now that you have a plane with the ocean modifier, you're basically done most of it. Play around with the settings to get the look that you want, if you want to know exactly what everything does there's a good documentation on it here: http://wiki.blender.org/index.php/Doc:2.6/Manual/Modifiers/Simulate/Ocean
Make it a good size, don't make it too big and detailed because it'll just eat away at your ram. What I did in the video to make it seem to stretch past the horizon is I added a single plane just underneath the ocean, made it the same colour and then scaled it up to be enormous. Since the camera was always at a relatively low angle there wasn't any noticeable cut from ocean water to a flat plane, but it filled up all the space up to the horizon. To animate the water simply set a keyframe for the time value (hover over it and hit i), then move to a different frame, increase the time to something else and then make another keyframe. You might want to make the animation linear though, so it doesn't slowly ease into it and then ease out. Go to the graph editor or dope sheet, select the keyframes and hit T, then linear.

Now the next part is to make the material. What I did is make a dark blue diffuse colour, sharp and bright specularity (using WardIso) and then I added reflection, with the fresnel bumped up to 1.1 (I found it gave it some nice highlights.)

One thing I wanted was to have some small detail in the water, but I didn't want to increase the resolution to some enormous number. So I created a cloud texture and mapped it to the normal value so it can act as a bump map, and then I animated the offset values (done the same way as the time value was, hover your mouse over them and hit i to set keyframes).

The rendering time will probably be pretty high, for me it was 1m 30s or so per frame. Depends how close you get to the water, reflections can take a long time to render.

Now to make the water react to different things, enable Dynamic Paint in the physics options and set it to canvas. In the Dynamic Paint Advanced options, set the surface type to Waves. Next create a new object, enable Dynamic Paint again but this time set it to Brush, and add a brush. If you play the animation (alt+a), and then move the object around in the water you'll see waves will form around it.

That's right, in real time. It's not going to be too realistic though since it's not an actual simulation, so you won't get any detailed splashes. It's just a cheap way of making a water-like surface that responds to things being in it. Although I found that if you leave things in it for a while with little movement, the water around the object will start jittering and glitching out. What I did with the Steve video is create an invisible boat mesh above the water that acts as the brush, and whenever the boat jerks around in the animation I dip the invisible mesh into the water to stimulate the waves. Leaving it in made it too glitchy. One final note, each time the animation is played the dynamic paint resets, so if you want to save the movement based on everything that is affecting the water at a certain point, go to the Dynamic Paint Cache in the canvas and hit Bake.

Hope that helps.