On this page |
Houdini’s SOP FLIP fluids allow for the simulation of fluids with multiple densities or spatial variable density. Typical applications are water and oil or water and foam. For a multi-density or variable density simulation you have to create a custom attribute-field pair and define the density values through appropriate nodes. The following example scene guides you through the entire process.
Fluid setup ¶
The following example demonstrates how to use attribute-field pairs. The goal is to create a simulation with a water surface with a density
of 1000
and two sources with density
values of 100
and 500
. Additionally, the particles should have different colors, represented through a Cd
attribute.
-
On obj level, create a Geometry SOP node and dive into it.
-
Inside the node, create a FLIP Container SOP.
-
Add a downstream FLIP Source: Velocity node and connect the first three inputs with the container’s outputs.
-
Add another FLIP Source: Velocity and connect it.
-
Finally, add FLIP Solver SOP node, and wire the first three inputs to the outputs of the second source.
-
In the solver’s Waterline tab, turn on Waterline to create a water surface.
-
Under Visualization, turn off Color By Speed.
-
Open the Advanced tab and turn off Solve Pressure With Adaptivity. This is essential, because we’ll work with variable densities.
The water source objects can be any object, e.g. a Sphere SOP.
-
Add two Sphere nodes.
-
Connect
sphere1
to the 4th input of the first source. -
Do the same for
sphere2
and the second source. -
Select
sphere1
and change Center to2,3,0
. -
Repeat step 4 for
sphere2
and enter-2,3,0
. -
You can stop sourcing in the source nodes by adding an expression to the Activation parameter. For the first source, enter
$FF<50
to stop emission at frame 50. For the second source, use$FF<75
.
This setup creates a narrow band water surface and two velocity sources, adding particles to the simulation. In the next step, you define the attributes.
Attribute-field pairs ¶
The first stop is the FLIP Container. There, the attribute-field pairs are created. In contrast to DOP FLIP fluids, attribute-field pairs are maintained automatically throughout the chain.
In this simulation, the surface water’s density
should be 1000
- water’s density under standard conditions. This value is also called background value and used for the background grid.
-
In the Attributes sub-pane, go to Custom Attributes and click the + button twice to create two point attributes.
-
For the first Point Attribute Name, enter
density
. -
Here you also define the background value. Set Value to
1000
. -
With
density
you also have to turn on Custom Volume Name. -
For Volume Name, enter
massdensity
. Step 4 and 5 signal the solver thatdensity
is not fixed. -
The second Point Attribute Name is
Cd
and represents the fluid’s color. -
Color consists of three values for R, G, and B. To get the correct format, change Rank to Vector. Three Value fields appear.
-
The main body of water in this simulation should be blue (the background value/color). Set the third Value to
1
.
Source attributes ¶
At this stage, all fluid particles share the same density
and Cd
values, defined in the FLIP Container, but each source should have different values.
-
Add an Attribute Create SOP node and wire it between
sphere1
and its connected source. -
Change Group Type to Points.
-
Under Number of Attributes, click the + to create a second attribute.
-
Go to Name and enter
density
. -
Look for the Value parameter and enter
100
for the first value. This is the first source’sdensity
and makes the particles float on the water surface. -
Set the second attribute’s Name to
Cd
. -
A Size of
3
stands for a color’s RGB values. -
Under Value enter
1,1,1
for pure white. -
Copy the Attribute Create node with ⌃ Ctrl + C and paste it with ⌃ Ctrl + V.
-
Wire the copied node between
sphere2
and its connected source. -
Go to the first attribute (
density
). For Value enter500
. -
The
Cd
Value fields are0,0.5,1
for light blue particles.
The video shows how the white fluid floats on top of the surface like foam. The light blue, slightly heavier fluid, goes beneath the surface, but rises up and creates a boiling effect. The heavier fluid displaces the white particles.
With this setup it’s, for example, possible to simulate oil-in-water scenarios. You can also add a viscosity
attribute and create simulations like liquid chocolate in milk or cream and caramel.
See also |