Houdini 20.0 Oceans and water surfaces

Shallow Water Solver fields

Work with velocity, acceleration, vorticity and force fields.

On this page

The Shallow Water Solver supports the creation of various fields, but you can also use fields as inputs to drive the simulation.

Note

The Shallow Water Solver is a 2D solver and fields are evaluated using only two coordinates. By default, the solver uses the XZ plane, and the water’s height is used for the Y axis. This also applies to incoming fields.

Velocity, acceleration, vorticity

Note

This workflow is based on an already existing Shallow Water Solver network. If you don’t know how to set up a simulation, please visit the Shallow Water Solver intro page for a detailed description.

In the solver’s Output tab you can find checkboxes for three fields: velocity, acceleration, and vorticity. The first two fields are vector fields and they consist of a XYZ components. As mentioned in the note, the normal component (Y by default) is not relevant. vorticity is a scalar and there’s only one value. To get an impression of the water’s different fields, you can visualize them.

  1. Add a Grid to the simulation network.

  2. Check, if Orientation is the same as the HeightField node’s parameter.

  3. The Grid and the Heightfield nodes' Size parameters should match. If the Heightfield’s size is 20x20, for example, use these values for the Grid.

  4. Increase the Grid node’s Rows and Columns to get enough sample points, e.g. 50 for both parameters.

  5. Add a Volume Trail node.

  6. Connect the Grid to its first input and the Shallow Water Solver to the second input.

  7. Under Velocity Volumes you can choose, which field you want to visualize. The drop-down menu on the parameter input’s right lists all available fields. Choose vel.*.

  8. If you don’t like the default colors, go to Ramp and choose Custom Ramp. Now, adjust the Color Mapping gradient.

  9. For a better view of the trails, add a downstream Transform node, then shift the visualization along the positive Y axis until you can see the trails.

Go to the solver and turn on Output Acceleration (accel). You can now find the new field in the Velocity Volumes drop-down menu.

  • With accel.*, the trails are shorter and there are rapid changes. You probably have to change the Volume Trail’s Maximum value to see any differences. The accel field stores the Lagrangian horizontal acceleration experienced by water at each point.

If you also turn on Output Vorticity (vorticity), you can inspect the exported vorticity field. This scalar volume stores the local rotational motion at each point, with larger absolute values indicating faster spinning. Positive (negative) vorticity values signal that rotation is in the counter-clockwise (clockwise) direction when viewed from above. Since this is a scalar field, it’s better to use the Volume Slice SOP to visualize it.

  1. Add a Volume Slice node.

  2. Connect its input to output of the Shallow Water Solver.

  3. Set Source Group to @name=vorticity.

  4. Change Visualization Ramp to Custom Ramp.

  5. Set a symmetric Visualization Range (for example, -1 to 1).

  6. Click the button on the right of Color Mapping and select Two-Tone.

The above steps will visualize the vorticity with a harsh cutoff at the value of 0. This helps differentiate areas of positive and negative local spin.

Force

Under the solver’s Bindings you can see an empty Force Mask Layer. Force masks can be created like any other mask, e.g. through a HeightField Paint or a HeightField Mask by Object node.

Note

Please visit the Shallow Water Solver page for detailed information on how to create masks.

One idea is to create a force field from an animated object’s velocity field. This approach simulates a collision effect with displaced water.

Heightfield setup

The heightfield is the solver’s collision geometry. The quality of the simulation strongly depends on the scene’s scale.

  1. On obj level, create Geometry node and dive into it.

  2. Inside the Geoemtry node, add a HeightField.

  3. Set Size to 5x5.

  4. Set Grid Spacing to 0.01

  5. Add a HeightField File node and connect it to the Heightfield operator’s output.

  6. Under File, add the path to a displacement, for example beach pebbles or a rocky ground.

  7. Under Layer Name, enter height.

  8. Adjust Height Scale until you get the proper vertical displacement.

Paint the mask

The following mask tells the solver where to source water.

  1. Add a HeightField Paint node and connect it with the previous Heightfield File operator’s output.

  2. Move the mouse over the viewport and press Enter to enter the drawing mode.

  3. Use mouse_wheel to scale the brush size and paint on the heightfield. Red spots indicate the source areas.

  4. Add a downstream HeightField Copy Layer and set Destination to source.

  5. Reset the old mask with a downstream HeightField Mask Clear.

Sphere collision setup

A fast moving sphere can lead to instabilities or other simulation glitches, e.g. water inside the sphere. For better control over the sphere’s speed, you can use expressions instead of animations keys.

  1. Add a Sphere node.

  2. Under Center.X, enter sin($FF*3)*0.25 to create an oscillation with an amplitude of 0.25 in positive and negative X direction.

  3. Under Center.Z, enter $FF*0.015-1.5 to create a slow linear motion along the Z axis starting at -1.5.

  4. For Rows and Columns enter 50 to get enough velocity sample points.

The sphere’s motion is now turned into a velocity field.

  1. Put down a Time Shift node and clear its Frame expression by ⌃ Ctrl + ⇧ Shift + LMB clicking it. Connect its input to the animated Sphere node. This will serve our rest geometry for deforming scattered points.

  2. Add a Pyro Source node and connect the animated Sphere node to its first input. Wire the Time Shift node to its second input.

  3. Set Mode to Volume Scatter.

  4. Add Point Velocity node and connect it with the Pyro Source. This node caclulates the velocities.

  5. To create a field from the velocity, add a Volume Rasterize Attributes node and connect it with the previous node.

  6. Under Attributes, add v - the velocity.

  7. Set Voxel Size to 0.008

  8. Add a Name node and connect it with the Volume Rasterize Attributes node’s output.

  9. Go to Group and enter @name=v to isolate the velocities.

  10. Set the group’s Name to vel to make the velocity field available to the solver.

Heightfield and velocity fields are now merged and will serve as an input for the animated force mask.

  1. Add a Merge node and connect Name and HeightField Mask Clear nodes to its input.

  2. Add a downstream HeightField Mask by Object. Connect the Merge node to the first input, and the Sphere to the second input.

  3. Add another downstream HeightField Copy Layer and set Destination to force.

  4. Reset the old mask with a downstream HeightField Mask Clear.

Solver setup

The solver brings everything together and creates the water. The sphere’s velocity is also converted into to a force field that will be used by the solver to push water.

  1. Add a Shallow Water Solver and connect it with the HeightField Mask Clear node’s output.

  2. Under Setup go to Velocity Diffusion and enter 0.0005 to blur the velocity field and dampen the waves.

  3. Set Source Scale to 0.03 to reduce the amount of sourced water.

  4. Turn on Force Frequency and choose Once per Frame to tell the solver that there’s an animated force mask.

  5. Go to the Bindings tab. Under Force Mask Layer, enter force.

  6. You can also visualize the water. Under Output go to Visualization and choose Color by Water Layer.

  7. Play the simulation; if you encounter instabilities, go to the Simulation tab and increase Substeps.

The video shows the sphere, slightly displacing the surrounding water.

Oceans and water surfaces

Shallow water solver

Oceans

Ripple solver