On this page |
The Shallow Water Solver node simulates how water behaves in certain scenarios, for example
-
ripples and non-breaking waves
-
ponds and puddles
-
water running over cracks and surface irregularities
-
simple boat waves
-
stylized water or water surfaces in distant areas
-
fast flooding of large areas
-
streams and trickles
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.
-
On obj level, create a Geometry node and dive into it.
-
Inside the Geometry node, create a HeightField node.
-
Set Size to
20,20
. -
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.
-
Add a HeightField File node and connect its input to the HeightField’s output.
-
Under File, load the displacement map you want to use.
-
In the Layering sub-pane, change Layer Name to
height
. -
Set Size to
20
to match map and heightfield. -
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.
-
Add a HeightField Paint and connect it with the HeightField File node
-
Make sure that Layer is set to
mask
. -
Move the mouse cursor over the viewport and press Enter. A big red sphere indicates the brush to draw the mask.
-
Adjust the brush’s Radius with the or set it manually to a value around
0.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.
-
To convert the mask into a source, add a HeightField Copy Layer node and connect it with the HeightField Paint node.
-
Under Destination enter
source
. -
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.
-
Add a Sphere node or any other object.
-
If necessary, change Uniform Scale to scale the object. This example uses a value of
6
. -
Add HeightField Mask by Object node.
-
Connect the HeightField Mask Clear node to the first input and the Sphere to the second input.
-
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. -
Add another HeightField Copy Layer after and connect it with the HeightField Mask by Object’s output.
-
Go to Destination and enter
sink
. -
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.
-
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. -
Go to the Bindings tab and check that Seabed Layer is set to
height
, Source Layer is namedsource
, and Sink Layer issink
. -
Go to Setup ▸ Constraint Updates and change Source Scale to
0.2
. Thesource
band becomes lower. -
Click the playbar’s button to start the simulation.
-
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.