Houdini 20.5 Oceans and water surfaces

Shallow Water Solver

Fast creation of water in shallow water scenarios.

On this page

The Shallow Water Solver node simulates how water behaves in certain scenarios, for example

The keyword is “shallow”, because this solver can’t be used for large oceans with breaking waves or the typical filling effects you can achieve with particle-based fluids. Splashes from fluid-object collisions are also not possible. Since the Shallow Water Solver is a 2D solver, newly sourced water can’t flow over already existing layers of water.

Heightfields and masks

The Shallow Water Solver is based on heightfields and masks. The heightfield describes the seabed’s topology and collision geometry. Quality and resolution is controlled in the HeightField node’s Grid Spacing. You can import displacement maps for use as a heightfield, paint a landscape, or create complex heightfields with Houdini’s own tools. The solver’s Seabed Layer (height by default) binds the collision terrain heightfield.

Note

Heightfields play a central role in the Shallow Water Solver. You can make yourself familiar with fundamental concepts under Basics of heightfields.

To create a water source, you need a mask. You can, for example, draw a mask with a HeightField Paint node. Another way is to import a single image or an image sequence for an animated mask. You can also use the HeighField Mask by Occlusion and HeightField Mask by Object nodes, or combinations of different methods. You can also create separate masks for sinks or areas where forces are applied.

The mask values are also important. For example, in the HeightField Paint node you can find FG Value and BG Value. With FG Value set to 1, sinks have full strength. A BG Value of 0, on the other hand, means that no water will be sourced or removed. With a sink, and FG Value set to 0.5, only 50% of the incoming water will be deleted on each frame. The solver has a Source Scale parameter that can be used to tweak the amount of sourcing, but the sink field will be used as is.

The simulation result–the solver’s Water Layer–is also a heightfield. The Shallow Water Solver differentiates between absolute and relative Water Layer values. To change between the modes, go to the Output tab, and turn on or off Output Water Height is Absolute. When

  • turned on, Water Layer contains the location of the water surface

  • turned off, Water Layer contains the height of the water column at each voxel.

When Output Terrain Includes Water Height is turned on, the Water Layer is added to the Seabed Layer. In the viewport, the water appears elevated from the underlying collision surface. When turned off, the water appears as a thin colored film over the collision geometry.

Basic setup: heightfield and masks

Technically speaking you need three nodes to set up a complete shallow water simulation. The following example requires more nodes, and introduces separate source and sink masks. Start with the heightfield node.

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

  2. Inside the Geometry node, create a HeightField node.

  3. Set Size to 20,20.

  4. Set Grid Spacing to 0.025 to get enough detail.

Up to this point you don’t see anything. In this example, the surface detail is added through a displacement map. This can be any map, e.g. from a commercial repository or something self-painted. Here, it’s a ground with pebbles and stones.

  1. Add a HeightField File node and connect its input to the HeightField’s output.

  2. Under File, load the displacement map you want to use.

  3. In the Layering sub-pane, change Layer Name to height.

  4. Set Size to 20 to match map and heightfield.

  5. If the resulting heightfield is too high or too flat, change Height Scale.

The heightfield is now visible in the viewport and you can draw a water source.

  1. Add a HeightField Paint and connect it with the HeightField File node

  2. Make sure that Layer is set to mask.

  3. Move the mouse cursor over the viewport and press Enter. A big red sphere indicates the brush to draw the mask.

  4. Adjust the brush’s Radius with the or set it manually to a value around 0.5.

  5. Paint the mask. The brush follows the heightfield and leaves a red mark on it. Here, the mask is a crack in the ground for the water to pour out.

  6. To convert the mask into a source, add a HeightField Copy Layer node and connect it with the HeightField Paint node.

  7. Under Destination enter source.

  8. Add a HeightField Mask Clear node to delete the current mask and keep the network healthy.

Now add the sink. We will use an object to control the sink’s shape and position.

  1. Add a Sphere node or any other object.

  2. If necessary, change Uniform Scale to scale the object. This example uses a value of 6.

  3. Add HeightField Mask by Object node.

  4. Connect the HeightField Mask Clear node to the first input and the Sphere to the second input.

  5. Change Blur Radius to 3 for a smooth mask. Without smoothing, the fluid is just cut away at the sink’s boundaries. A blurred mask creates more natural results.

  6. Add another HeightField Copy Layer after and connect it with the HeightField Mask by Object’s output.

  7. Go to Destination and enter sink.

  8. Add another HeightField Mask Clear SOP node to delete the current mask.

Basic setup: solver

The Shallow Water Solver is the core operator and processes the upstream input. What you get is another heightfield, stored in the output’s water field.

  1. Add a Shallow Water Solver and connect it to the sink’s HeightField Mask Clear node. You can now see a band in the form of the source mask.

  2. Go to the Bindings tab and check that Seabed Layer is set to height, Source Layer is named source, and Sink Layer is sink.

  3. Go to Setup ▸ Constraint Updates and change Source Scale to 0.2. The source band becomes lower.

  4. Click the playbar’s button to start the simulation.

  5. To see colors, open the solver’s Output tab and change Visualization to Color by Water Layer.

The water flows over the terrain, fills the gaps between the pebbles, and vanishes around the sink object.

Oceans and water surfaces

Shallow water solver

Oceans

Ripple solver