Monday, August 20, 2012

Tutorial #4 - Ocean Simulation

This is a quick little tutorial about how to set up the ocean simulator, and a basic scene to create a decent looking ocean. I was asked about this a while back, and with a recent animation I created, I felt like it was time to explain it.

So first, here's what we're going to be creating with the ocean simulator, a ten second clip. I'll then show the tutorial, and explain the steps.

The ocean simulator is actually fairly easy to use. It can be daunting at first, but once you get the steps down, it's real easy to work with.

First in our new scene, we add (Shift+A) a plane. This plane is going to be modified and turned into our ocean mesh. The ocean modifier breaks the plane into subdivisions and then applies the maths to create the ocean like formation.

Once we've applied the ocean modifier, we can see our tools, and options.

And see the plane is now warped, a bit.

So, first we'll look at the options:

Geometry; this is one of two options, Displace, and Generate.

Displace; changes just the mesh itself as is. Without a high poly mesh, it will only deform the 4 vertices. If we had another object with a lot of faces (a sphere for example) we could also apply the ocean modifier, and see it displace the object.

Generate; we'll leave it at generate as this will change our object, into the desired ocean mesh.

Our next set of options is Repeat X and Y. Turning these up will tell the ocean modifier how many times the mesh will repeat, depending on other factors this can become obtrusive and a pain to work with, if you have it set up too high to begin with.

For the tutorial, I'll leave it on 1 for both. For other simulations, I may set this up to 3 for both, but be aware this will exponentially add faces and verts to your scene. So if your computer can't handle it, it may crash on you.

Next we have Time; this is the simulation time, in seconds. We use this later in the tutorial to assign key frames to this value. Making sure the value of time matches the speed of the animation.
For example I'll cut the animation to 240 frames, and at 24fps. This is a ten second long animation. So I'll key frame time from 0s at frame 0, to 10s at frame 240. Allowing the ocean simulator to have it's time value changed at the appropriate speed in the animation.

Spatial Size; this is the reference size of the plane (at repeat 1) in meters. Depending on your scene, like a life raft sitting in the ocean bobbing up and down, you may want to leave it at 50 or make it smaller, this can add or remove detail.
Say for example, you want a helicopter to fly overhead of this water scene, you may want to make the value larger, like 500 meters. For this tutorial, I leave it at 50. Be aware, this also affects the overall size of the mesh.

Resolution; This is the money maker of the modifier, this is where it shows the details of the water effect. In the demo clip, I had it set to 23, this is fairly decent for a quick render. This will add faces and vertices to your ocean simulation, and if set too high, can easily crash blender. You may find values of 17-20 will be acceptable for your application.

Depth; this is an undocumented value, but is meant to be the depth to the ocean floor in meters. Although with my testing, changing it doesn't do much.

Now onto the Waves section in the modifier. This is where you can really change the dynamics of the ocean.

Choppiness: This is the distortion of the waves.
Here's some samples at 1, 3, and 5 values for choppiness.

You can see the wave hardness. I believe I left this at 1 for the animation.

Scale; scale is the amplitude of the waves, or the height. This is all dependent on what you want to portray in your own renders. I had the scale set to 2 for the animation above. Here's what it looks like at 1, 3, and 5.

You can see that scale of 5 is nearly impossible, storm like waves. So anything between 1.5-3 is probably more acceptable for a render.

Smallest: Smallest, is the shortest allowed wavelength in meters, for a wave. This is another one that is kind of strange. When you change the scale you would probably want to play with this value too, this can smooth out the waves if you give it a higher value. Basically removing the smaller, but higher detailed noise waves.
Think of a wave of water coming into the beach... and you're blowing on the water in a different direction, the force of you blowing on the water is a small wave, this value would remove the detail from you blowing on the water, and only leaving the larger waves.

Wind Velocity; is Wind Speed in Meters Per Second, this is the major impact on the speed of the waves, and how fast they travel across the scene, or the plane.

Wave Alignment: This is the one thing that feels like a bug to me. But I'm fairly sure it's not, it's just how the math works. With an alignment of 0, the ocean sim, is fairly calm, and this is good for certain ocean animations.
When you start to change the wave alignment value, your scale appears to change. So, if I had a scale of 2 without alignment, with alignment I need to change the scale to 1.5.
What this really does, is it adds an additional wave generation to the simulation.
"The directionality of the wave shapes due to wind. At a value of 0, the wind and waves are randomly, uniformly oriented. With higher Alignment values, the wind is blowing in a more constant direction, making the waves appear more compressed and aligned to a single direction."
When you change the Wave Alignment, you also get the values of Direction and Damping.

Direction is the direction of the waves, by wind. Damping is the resistance of the wave to continue through the ocean on it's own.

All in all, this adds some of what appears to be randomness to your ocean, which can be really good when creating a "middle of the ocean" scene.

The last two settings is Generate Normals, and Generate Foam.
Generate Normals, can be used for generation of a bump mapped texture.
Generate Foam, will create a mask, that you can then apply a particle system to generate foam like objects or particles on top of the ocean, which could be used on a beach scene.
Both of these, I'm not going to be using in this tutorial.

In the end, this is what I'm using for the settings of my demo setup:

  • Repeat X: 1 Y: 1
  • Time: (Keyframed)
  • Spatial Size: 50 (default)
  • Resolution: 23
  • Depth: 200 (default)
  • Choppiness: 1 (default)
  • Scale: 2
  • Smallest: 0.01 (default)
  • Wind V: 30 (default)
  • Alignment: 0 (default)

With all that, now it's time to set up our scene!

I first wanted to set up the ocean's material. There's a few ways we can do this in cycles, Glass or Gloss. With glass, you'd need to make the material a dark blue color, so you don't see through the layer of ocean. You can however set up a plane under the glass ocean plane, to give some depth to the ocean, etc. etc. etc... but I just want a quick effect.

So, I went with Gloss. And the color wheel set to;
R 0.425
G 0.464
B 0.627
And a roughness of 0.030. (I'll explain why in a moment.)

This was a decent enough blue ocean to get me going.

Sky, and Atmosphere!

Now, we need to set up the sky. In the properties pane, click on the world, and you bring up the world surface. I love using the sky texture, it's a simple tool to make a really neat sky.

I positioned the camera due south, and pointed it north. I then did this, to the world surface with the Sky Texture:

The sky texture, is a vector ball that you can imagine looking down onto your scene, if the white is in the middle of the ball, it's high noon position of the sun in the sky. The picture above is a northern setting sun.

Turbidity is the altitude of your scene, which is actually the amount of atmospheric haze.
I have given it a 1.8 as at the ocean level there is additional atmosphere, vs being at a high altitude.
I have also turned down the strength, to give a nice sunset color.

This looks good! Except, I started to go through real ocean pictures, I took a few years ago on a fishing trips with my father, for reference. This is where I noticed one big difference between these renders and real pictures. There is not enough sun light bouncing from the ocean; you can see some, but in a real picture you'd see a ton of light bouncing from the ocean.

I fixed this by adding a circle mesh (you need to go into edit mode and give it a face), and then setting it as an emitter.

I made it fairly large, and gave it a strength of 20, with some yellow color to it. This is where the roughness comes in on the ocean, to give some disbursement to the light scatter from the circle. This added a large dot to the render, and kind of ruins the look of the sky texture.

It's almost hardly noticeable, but it's enough for me to dislike it.

So in the Properties pane, on the Object tab, for the Circle, you can turn off the ray visibility for the camera, but leave the Diffuse, Transmission, Shadow, and Glossy visibility's turned on.

Now, the circle is hidden from the camera rendering, but it still gives the shine on the surface of the water like a real sun. You can play with the circle if you like, give is some width or make it larger for more disbursement of light across the ocean surface.

You can add some more effects with the compositor to give some more haze or blur, or shine. I used the compositor for my life raft animation render, and it crashed blender each time I changed something. So I learned to save my work often, and found that after a crash, I could load cleanly and make changes. It was a pain, but I think it paid off.

Here's the life raft animation with compositor effects.

Let me know what you think of this tutorial!
Austere Grim


  1. Thank you very much! This was so helpful, it's the best, shortest tutorial I've found yet.

  2. Great Tutorial! Easy to follow as well!I wish you showed how to add foam though, I have no clue how to so that in cycles.

  3. Excellent tutorial. I just got blender today and had a look at some tuts.

    I can honestly say yours was the most informative yet fun to go along with. Will definitely check out anymore you have.

    here is my image from the tut. Changed the color of the water to one of my own textures..

  4. Hello Austere,
    my name is Perry, and I watched your YouTube video on ocean simulation. How do i make an underwater text title rise up out of water like a whale surfacing, or an Atlantean city rising from the depths of the ocean? Sort of like exploding out of water, with foam, and water scattering effects? Do you also sell any tutorials I can study? Please respond when you can at