Creating a Toon Ocean

By -
Duration
5 mins
Last modification: 16 Sep, 2017

UPDATE: This tutorial has been modified. The old versions had a node update problem where the rendered ocean would only change shape every other frame. The fix was to create an expression using dgdirty that forced the node to be dirtied each frame.

toonOcean.ma (scroll to the bottom to download related material) One of the more difficult things to toon shade is water. A difficulty with the Maya Toon feature is that currently it does not work with the Maya Ocean feature, or for that matter, displacement mapping in general. One can convert the displacement to polygons, but for an ocean one needs the animation and displacement to poly does not support history. One workaround is to create several blendshapes and animate between them, but this is tedious. The following tutorial takes advantage of the ability of the toon shader to create an interactive displacement mapped mesh. 1. MENU "Create: Polygon Primitives: Plane" Initially set the subdivisions to about 50,50 and scale it up to the size you want your ocean to be, although try to keep the size as low as possible so you don't need too high a subdivision level. 2. MENU "Toon: Assign Outline"

3. Edit "pfxToonShape1": Making the following edit creates an offset mesh we can use for our displaced surface: profileLines = "Offset Mesh" lineOffset = 0.1 (the offset mesh should appear) Now turn off all the other lines on the toon node: borderLines = OFF createLines = OFF

4. Hide the plane (select pPlane1, then type Cntrl+h) 5. Edit the toon offset mesh in the attribute editor: In the outliner select "polySurfaceShape1" under "pfxToon1ProfileMeshes". Under "Render Stats" in the attribute editor turn off "opposite" and turn on "double sided". Under "ObjectDisplay: Drawing Overrides" turn off "enable Overrides" 6. Map the line width of pfxToonShape1 with an ocean texture: Click on the map button on "Line Width Map" in the attribute editor and select the ocean texture. The connection editor should appear. Connect ocean1.outAlpha to pfxToonShape1.lineWidthMap. 7. Set pfxToonShape1.lineWidth to 50 (type in the edit cell). The offset mesh should now look displaced somewhat. You can use the lineWidth on the toon node to control the amount of displacement

8. We need to force a rebuild of the toon offset mesh during playback, otherwise our ocean won't animate during playback (although it does update when playback stops). To guarantee all the connections on the toon node will compute each frame we dirty them using the command dgdirty. To get this command to execute each frame we put it in an expression. You can add the line "dgdirty pfxToonShape1" in the expression editor, or simply type expression -s "dgdirty pfxToonShape1" into the command prompt. The default setting for expressions is to always evaluate the expression each frame, so the node will thus be dirtied whenever the time changes. 9. Edit the ocean texture in the attribute editor: To make the waves move type: "= time * 0.5" into the time edit cell. The " * 0.5" is just to slow the waves down a little. You should now be able to see motion when you playback. ocean1.scale = 30 ocean1.numFrequencies = 10 (good for big ocean waves) waveLengthMax = 10 (larger range between big and small waves) We now have a mesh with an interactive ocean displacement. We can now toon shade it. 10. Select the ocean surface ( "polySurface1" ) 11. MENU "Toon: Assign Fill Shader: Light Angle Two Tone" (set the color ramp to your preferred ocean colors) 12. MENU "Toon: Assign Outline: Add New Toon Outline" On pfxToonShape2: creaseLines = OFF ( lines along triangle boundaries look bad on an ocean, we can only use profile lines ) borderLines = OFF You should now see lines around waves when the view is near the water.

13. MENU "Create: Lights: Directional Light" 14. Enable shaded view with "all lights". In the window "render" menu select "high quality" If you have a good graphics card you should see the two tone wave shading. You can rotate the directional light to find the best direction.

This is the basic setup. We can now add some refinements. 15. Make the tops of the lines white using a line modifier. Select pfxToon2 MENU "Toon: Create Modifier" On the modifier enable "modify Color", set the color to white and the widthScale to 1.0(no effect) Set the modifier "shape" to "Cube". Scale the modifier such that it covers the entire ocean and move it up so the bottom is near the ocean bottom, yet still covering. Edit the dropoff ramp such that you get a transition from black to white near the wave tops( a quick drop from 1 to zero near the right side of the ramp). You will likely wish to increase the resolution of the mesh before rendering ( increase subdivisions on polyPlane1 ). Also the render antialiasing should use contrast sensitive production and for good lines enable paint effects oversample and post filter. Here is the file after some fine tuning. toonOcean.ma (scroll to the bottom to download related material) I have made the lines somethat transparent (lineOpacity) and adjusted the thick thin effects by using lightingBasedWidth and profileWidthModulation. I also enabled screenspaceWidth and set distanceScaling such that the lines get smaller in the distance, but not by as much as they would with strict perspective.

toonOcean2.ma
Published In
Tags
  • Tutorials
4 Comments
To post a comment please login or register
| 7 years ago
Note also that there is now an easier workflow to toon shade the ocean in Maya. 1. Fluid: create ocean 2. convert: displacement to poly with history 3. toon: assign outline However there may be cases where the method in this tutorial is better. The method of displacement used in the tutorial is more efficient than displacement to poly. It also may be a bit safer.
Edited by XfBIG9DY 7 years ago
| 7 years ago
Actually both mappings work in this case. The surface is offset by the width + offset. The offset surface profile lines by their nature can't show the effect of offset(lines separated from the surface), so it just looks like width.
| 7 years ago
hi, how amazing your work is. this is the style ocean i tries to reach. however, i have a little question! as you mentioned in step 6. "Connect ocean1.outAlpha to pfxToonShape1.lineWidthMap." in your demo file "ocean1.outAlpha" was connected to "line offset map". is it just a typo? or it doesn't matter to connect to either map??
| 12 years ago
wow! amazing!! Duncan, theese days you've got some time to give you precious hints.. Thanks a lot. -elvis
*Save $66 per month on Autodesk's Suggested Retail Price (SRP) when purchasing 1 year term 3ds Max or Maya subscription.