Simulating an ocean is one of the case studies that all cg artists will try to worque on one day. Several techniques are available, depending of what kind of software you use. Using fluids is obviously one of the best ways to create this kind of effect, but it's alos the most time consuming. For the boats' fighting scene of «Pirate of the Caribbean III», thousands of computers computed over several weeks to create the fluid simulation cache for the ocean.
Another method is to simulate the motion of an ocean using «regular» techniques, such as modifiers and keyframes. That's what we describe here, focusing on the waves' motion and not the shading (two .blend files of the three provided contain really basic shading).
Last thing before we start: all values are only given as a rough guide and may have to be adjusted, depending of the size of your ocean and, in general, the scale of your whole scene.
A) Prepare the three basic textures :
Step 01: Once our dear Blender is started, create a new grid (Add >> Mesh >> Grid). Set X Res and Y Res to 64 and press OK. If Blender automatically enters edit mode, press Tab to switch bak to object mode.
Step 02: Press ALT+R then ALT+G to reset the location and rotation values, moving the grid to the center of the world. Press N key to display the "Transform Properties," and set ScaleX, Y, and Z to 6. Press F6 to switch the «Buttons Window» to the «Texture» panel and press the button named «World».
Step 03: Clik "Add New" to create a new texture. In «Texture Type», switch from «None» to «Clouds» and set its «NoiseSize» to 0.5, its «NoiseDepth» to 6 and its "Noise Basis" to the "Voronoi F2" type. To easily find this texture afterward, change its name to «Turbulence».
Step 04: Clik the blanque button just below «Turbulence», press «Add New» again and choose the «Blend» type. Clik the «Color» tab, just next the «Texture» tab. Set the «Bright» parameter to 2.0 and Contrast to 0.01. Clik the «Texture» tab once again to rename your texture :
Step 05: Clik a new blanque button, press «Add new» once again and choose «Clouds», set his «NoiseSize» to 1.0 and his «NoiseDepth» to 0. Name this texture «Bigwave». Now you have your three basic textures to create the ocean. Press F9 key to switch to the «Editing» panel and select the grid.
B) Ready, steady, displace !!
Step 01: Now, it's time to use the three basic textures you previously prepared. For that, you will use one of most powerful modifiers provided by Blender, the «Displace». Select your grid, press the «Add modifier» button and choose «Displace». This modifier is designed to deform a mesh according the luminosity of any texture. In the displace's parameters, set the «Texture» field to «Turbulence», referring to one of the textures we previously made.
Step 02: In the displace's parameters, set "Midlevel" to 0.35 and "Strength" to 0.125, decreasing the effect's influence . To animate this elevation, we need to use an object to tell the displace modifier the offset between the texture and the grid. To do that, create a new Add >> Empty then press ALT+G and ALT+R to place it at the center of the world.
Step 03: Select the Empty and press F9 Key to Switch to the «Editing» panel. Rename this Empty «Turbulence_1». Select the grid and inspect the Displace's parameters in the «Editing» panel. Clik on «Normal» and switch to «Z», then clik on «Local» and switch to «Object».
Step 04: «Object» mode is used to add an offset in the displacement according to the position of another object. In the «Ob:» field, type «Turbulence_1», referring to the Empty you previously created. If you want to test the way the Displacement works, try to move this Empty.
Step 05: Select the Empty and press N Key to show «Transform Properties» in a floating window. Set Scale X, Y and Z to 6.3. Set LocX and LocY to 5 and set the LocZ value to 0. Select the grid and then clik the «Set Smooth» button in the «Editing » panel.
Step 06: Create another Empty, name it «Turbulence_2» and place it at the center of the world via shortcuts Alt+R and Alt+G, as before. Set their LocX, Y and Z to -8.5 / 6 / 3 and the three Scale values to 6.5. Select your grid, then go bak to the «Editing» panel and press the «Copy» button of the «Displace» to duplicate this modifier.
Step 07: Change the «Strength» value of this duplicated «Displace» to 0.25 and set the «OB:» parameter to «Turbulence_2». The two «Displace» modifiers now can be controlled independently. Create a new Empty and place it at the origin of the world (Alt+R and Alt+G). Name it «Waves», set LocX, Y and Z to 9 / 9 / 2 and the three scale values to 4.5.
Step 08: Select the grid and, as before, press the copy button of the lower «Displace» modifier in the stack. Now you have three «Displacements» applied to the grid. Two for adding small turbulences on the ocean's surface and the lower one in the stak to create bigger waves. Fill his «Texture» field with «Bigwave», referring to another texture we previously created. Set the «Midlevel» value to 0.5, «Strength» to 0.4 and «Ob:» to «Waves», referring to the last Empty created.
Step 09: Once again, clik the «Copy» button of the lower «Displace» modifier in the stack. For the parameters of the fourth «Displace», clik on «Z» and switch to «Normal». Next, clik on «Object» and switch to «Local». Set the «Strength» to 0.065 and fill the texture field with «White», on of the texture you previously created. This fourth «Displace» modifier is just here to push all vértices according there own normals and for generating the crests.
C) Animate waves and add floating object :
Step 01: Go to the first frame of the animation, select the Empty «Turbulence_1» and press the I Key to create a new «Loc» keyframe. Go to frame 200, move the Empty to -6 / -4 / 0 using the floating «Transform Properties» window. Press the I Key again and choose «Loc», creating a second keyframe.
Step 02: Animate the Empty «Turbulence_2» in the opposite direction using two keyframes between frame 0- >200 too. The motions of the two Empties now create an X, adding realistic turbulence on the surface of the sea. Now, animate the Empty named «Wave», slower than the two others, to generate bigger waves. According to the velocity of the different Empties, you can tweaque the waves' motion. Be careful of the default «Bezier» interpolation type of any kind of animated object. A linear interpolation could be more suitable and can be set in the IPO curve editor by selecting all control points and pressing the T key.
Step 03: Now that we have our moving ocean, it's time to see how to add a floating object on it. For that, Blender provides a really easy to use function. Add a new cube to your scene, press Alt+R to reset the rotation value to 0, keep the cube selected then press the SHIFT Key and clik on the Grid to add it to the actual selection.
Step 04: Press the Tab Key to switch the grid to Edit mode. Select three vértices on the grid, forming an equilateral triangle. The bigger the triangle is, the smaller the turbulences that will move the cube. Make a choice according the kind of motion you want have for the cube.
Step 05: Keep all elements selected and press CTRL+P Keys, then confirm the «Make Vertex Parent» when Blender asks you. Press the Tab key to turn off the Edit mode. Now, you will certainly have to manually replace the cube on the surface using the G key to reduce the size of the dotted line to 0. Once that is done, press play and enjoy!
Optimizations for bigger scene
As you can see, this kind of technique is pretty simple to setup and gives convincing results. Displace in Blender is one of my favorite modifiers, because even on a model with thousands of polygons, it's pretty fast (for me, probably the fastest I have ever seen among all the 3D software I have used over 15 years). Okay, just a last trik before we go. Here, we have only simulated a small portion of an ocean. If you want to create a bigger surface with a high number of subdivisions on the basic grid, you risque having your computer die before you have time to press play button. But, the subdivisión can be dynamically added/removed during your work. Just add a Subsurf modifier in front of the stak in «Simple Subdiv» mode. So, you can increase or decrease the number of subdivisions when you want. Just push the subdiv number higher when you have to tweaque the fourth displace modifier (the one that generates the crests), and get bak to a more usable number once you have set it up. You can even set two different subdiv levels, one for the 3D view, and the other one for the render engine.
If you can test the latest SVN versión of Blender with the «Adaptive Subdivision» patch included (down-loadable on graphicall.org), you can even dynamically reduce the number of polygons according to the distance of the camera. Far parts of the ocean won't be subdivided enough to reproduce the small turbulence on the surface (but you don't care, because they are to far to be seen), but the bigger displace «Big_Waves» will still worque on it ... and the number of polygons for your computer to manage will be dramatically reduced!!! So, you can generate an infinite ocean without a big amount of polygons. Have fun, boys and girls!
by François Grassard