Ocean wave tutorial

Ocean Tutorial

Not sure if any of you remember my old wave script (www.oregonstate.edu/~Dennisa/Blender/water.zip). It’s pretty outdated now, especially since there are better methods of creating wave motion than that python script. What my script did was use a hybrid fractal noise generator and used the values to create a heightmap of ‘waves’. But now that these sorts of noise functions are built into Blender’s procedural textures and we have true displacement functionality, this exact behavior can be duplicated without the hassle of a script.

http://oregonstate.edu/~Dennisa/Blender/ocean.jpg

  1. Create a plane which will be your ocean. For this example, I resized it so it’s 20x20 units.
  2. Under the Edit Buttons (F9) enable “SubSurf” and change the subsurface mode to Simple (In the drop down box)
  3. Underneith those buttons, there are two adjustable numbers. Change the one on the right side (That recalculates the subdivision during render time) to 6. Don’t forget to hit the tan ‘Set Smooth’ button.
    *This sets the resolution of the waves. 6 is the maximum for render-time subdivision. If you want more resolution, simply go into edit mode and subdivide further.
  4. Under the Material Buttons(F5) add a new material, and then add a new texture(F6)
  5. Set the texture type to be ‘Clouds’
  6. For water, I’d set the Noise Basis to ‘Voronoi F1’, the Noise Size to 0.450 (or however large you want your waves) and the Noise Depth to 1.
  7. Go back to the Material Buttons, and under the ‘Map To’ tab, unselect Col, and select Disp. Slide the Disp slider to it’s maximum.
    8 ) Add a lamp and do a test render. Adjust any of the size settings if needed. At this point the waves won’t move.
    *If the waves aren’t high enough, assign the same texture to your material on the second channel. You’ll have to set the same MapTo settings for this instance also.

Additional Steps to animate the water

  1. Add an empty, go to the Edit Buttons (F9) and name it “Water”. It doesn’t matter where you put it for now.
  2. Resize it so it’s as big as your ocean (20x20 units in my case).
  3. Now select the ocean plane again, and go to the Material Buttons (F5) and under the “Map Input” tab for the displacement texture, select ‘Object’ and type in “Water”. It is CASE sensitive!
  4. The texture will now move with the empty so…
  5. Go to frame #1 ([Shift][Left Arrow]), Select the Water empty and press I->Loc
  6. Move up 50 frames ([up arrow] 10 times), move the water empty up on the Z-Axis about 10 units. Press [I] and save the LOC again.
  7. Make sure the empty is selected and, with your cursor in the 3D window, hit [Shift][F6] to bring up the IPO curves for the empty.
  8. Press the [Home] key on your keyboard to center the view.
  9. Select the LocZ curve (Probably Yellow), and then from the Curve menu, select Extend->Extrapolation.
    *This makes the water move at that speed forever.
    18 ) Switch back to 3D view by pressing [Shift][F5].
  10. Now render your animation to check the wave speed. If it’s too fast, simply go back to frame 51 where we made our second keyframe, move the empty down on the Z-axis, and resave the keyframe.

Now all you have to do is create a water material and set up some better lighting. Good Luck!

I’ve uploaded an example to my webspace:
www.oregonstate.edu/~Dennisa/Blender/Ocean.blend

Nice work RipSting! :smiley:

Looks like a good tutorial, I’ll try it out, at school today. :smiley:

Thanks

Excellent. It’s clear, easy to follow, and only took me a couple of minutes to set up an animation with almost no previous experience with this part of Blender. The only thing I had to do that wasn’t explicit in the instructions was an IKEY-Loc on the Water Empty between steps 14 and 15. Thanks. I’ll definitely use this effect in future projects.

As RetroJ noticed, there is a step missing between steps 14 and 15.

  1. Move up 50 frames ([up arrow] 10 times), move the water empty up on the Z-Axis about 10 units.
  2. Make sure the empty is selected and, with your cursor in the 3D window, hit [Shift][F6] to bring up the IPO curves for the empty.

It doesn’t say to add a keyframe for the location on frame 51. Apart from that the tutorial is very easy to follow. I’m going to try it.

Thanks. :slight_smile:

WOW!! :o :o :o :o

That was super easy, and really good. Now… for a question: How to I export my video??

Do you mean how do you save your movie?
Go to the Render window (F10)
In the Format area, set the format to AVI Raw. (it’s in a dropdown list)
In the Anim area set the Start and End frames.
Click the Anim button.
When it’s done rendering you will have a new avi file. For my setup, the file is created in the /tmp directory. I have also seen mention of a “render” subdirectory of your project location.
The file will be huge, but you can compress it. I use mencoder in the linux environment. I don’t know what a good one for Windows is.

I put in the instruction to save the LOC again:) Thanks.

if you delete the texture that provides the speckle and decrease the subsurf resolution from 6 to 4 (and disable AO) the waves come out rounder:
http://img65.photobucket.com/albums/v199/simonharvey/ocean.jpg
It also renders 2-3 times faster!!!

simon

Do you mean how do you save your movie?
Go to the Render window (F10)
In the Format area, set the format to AVI Raw. (it’s in a dropdown list)
In the Anim area set the Start and End frames.
Click the Anim button.
When it’s done rendering you will have a new avi file. For my setup, the file is created in the /tmp directory. I have also seen mention of a “render” subdirectory of your project location.
The file will be huge, but you can compress it. I use mencoder in the linux environment. I don’t know what a good one for Windows is.[/quote]

Thanks. Another question… my video was working fine (when I had exported it a JPEG), Now it speeds up till fram 51, then slows to a
normal’ pace. Quite odd, wondering if anybody else had an answer…

You want to change the interpolation type from bezier to linear in the curve->interpolation mode in the IPO window.

simon

I’ve been trying to adapt this technique to a toon-shaded environment, but I’ve run into a problem in the mesh (the part circled on red). For some reason, the waves look blocky on this area.
The disp. values are the same as in the original image, the only difference being the subsurf at lv 4 (cause 5-6 caused a mess).

http://img28.exs.cx/img28/2425/Ocean2.gif

I don’t know if anyone else feels this way but aren’t oceans flat where they meet the horizon? A lot of the scenes of oceans I have seen look like the boundary between sea and sky is a bit unnatural. This may well be to do with the clipping range but if you model as though 1 Blender unit is 1 metre then a clipping range of 1000 units is only 1000 metres. Is there a way to fake the sea-sky boundary better?

Perhaps if you could do non-linear scaling of the sea surface depending on the distance from camera. Even the people who produce images with Terragen seem to cheat all the time by putting mountain ranges along the boundary. I was wondering if anyone knew how to do it properly.

BTW, that toon ocean looks pretty good, it might be better with a toon sky, though. As for the blockiness, you’ve probably tried doing set smooth again and checking normals. The only other thing I can think of is maybe you used triangles in some places. You should just use quads all the time when using subds.

The ocean I created was very small. If you want more realism you could create an ‘adaptive’ mesh (Make one with a high poly count up close, and low poly count on the horizon), then when you move your camera, move the ocean mesh with it, and the displacement empty in the opposite direction. The camera will appear to move across the ocean, but the camera and mesh will stay relative to each other.

Hey thats a very nicce and easy tutorial, i have 2 questions though…

  1. Why does this Water(Empty) make the plane move. I probably dont understand this Object:Water thing and,

  2. How can i make a bottle floating on the waves

Thanx,
Twan. :smiley:

Normally when you see the the perfect blend between sky and water, you can’t see any other land. If you made your ocean… oh, about three times this, then you’d probably acheive that effect.

As far as making the waves flatter on the horizon, you could use a “Blend” texture on the second texture channel and use this set to displacement, this will act to wipe out the effect of the first channels wave texture in the distance making it seem flatter on the horizon

Ken