|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.
The following example demonstrates how to use attribute-field pairs. The goal is to create a simulation with a water surface with a
1000 and two sources with
density values of
500. Additionally, the particles should have different colors, represented through a
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.
sphere1to the 4th input of the first source.
Do the same for
sphere2and the second source.
sphere1and change Center to
Repeat step 4 for
You can stop sourcing in the source nodes by adding an expression to the Activation parameter. For the first source, enter
$FF<50to stop emission at frame 50. For the second source, use
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.
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
Here you also define the background value. Set Value to
densityyou also have to turn on Custom Volume Name.
For Volume Name, enter
massdensity. Step 4 and 5 signal the solver that
densityis not fixed.
The second Point Attribute Name is
Cdand 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
At this stage, all fluid particles share the same
Cd values, defined in the FLIP Container, but each source should have different values.
Add an Attribute Create SOP node and wire it between
sphere1and its connected source.
Change Group Type to Points.
Under Number of Attributes, click the + to create a second attribute.
Go to Name and enter
Look for the Value parameter and enter
100for the first value. This is the first source’s
densityand makes the particles float on the water surface.
Set the second attribute’s Name to
A Size of
3stands for a color’s RGB values.
Under Value enter
1,1,1for pure white.
Copy the Attribute Create node with ⌃ Ctrl + C and paste it with ⌃ Ctrl + V.
Wire the copied node between
sphere2and its connected source.
Go to the first attribute (
density). For Value enter
CdValue fields are
0,0.5,1for 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.