Mix Two Fluids in Blender: Water and Oil
Mix water and oil in FluidLab 1.2: two InFlow emitters, Fluid Interactions, an OutFlow collider, a GN mesh and two shaders blended with fl_color.
In this tutorial we shoot two jets of liquid, water and oil, into a box so they crash into each other, and then blend their shaders on a single mesh so you can see where each fluid ends up.
You will set up two InFlow emitters from presets, make the two groups interact, remove stray particles with an OutFlow collider, mesh the result with Geometry Nodes and mix the materials using the fl_color attribute provided by FluidLab.
Step by step
-
The scene has a box collider (
Cube_00) and two spheres: one for water and one for oil. Select the first sphere, click Add New Group, rename itwater, choose InFlow and click OK. Then click Add Emitter; the group appears in Fluid Groups asG_Water.In Fluid Presets, choose Water and click Set Preset to load the water parameters. Then go to Fluid Settings:
- Emission: in Count | Size, set 50000 and 0.03 m. Frame Start | End is 1 and 100, so the inflow lasts 100 frames, and Lifetime is 185, the length of the timeline. Under Velocity, set Initial Velocity X to 2.7 m/s.
- Physics: enable Adaptive, raise Subframes from 4 to 7 for more accurate calculations, and raise Mass slightly to 0.11 kg.
- Emission → Viewport Display: set Display to Material and pick a water-like blue in the color field.
-
Repeat the process with the second sphere: Add New Group named
oilwith InFlow, then Add Emitter (it appears asG_Oil). In Fluid Presets, choose Oil and click Set Preset.In Fluid Settings → Emission, use the same values as the water: 50000 particles of 0.03 m, frames 1 to 100 and Lifetime 185. The difference is the direction: set Initial Velocity X to -2.7 m/s so the two jets shoot towards each other. In Viewport Display, set Display to Material and choose a yellow.
In Physics, enable Adaptive and set Subframes to 7 as well, but this time lower Mass slightly to 0.08 kg.
-
Hide the collider and play the simulation: both fluids flow, but water and oil don't react to each other. Open Fluid Interactions, click Add Interaction, tick
G_WaterandG_Oilin the dialog and click OK (Interaction_00appears in the list). Run the simulation again: now the two fluids push against each other.Some particles still spill out through the walls of the box. To fix it, go to Colliders, unhide the collider, duplicate it and scale the copy up a little. With the copy selected, click Add Selection Collider and enable OutFlow (Kill Particles) in its Collider Settings: any particle that touches this outer collider is killed, so nothing leaks out. Hide both colliders and rerun the simulation.
Groups don't interact by default
Two fluid groups in the same scene simulate without any interaction until you add one in Fluid Interactions.
-
Click the disk icon next to Current Cache to save the simulation. In the video a file browser opens at that point and the scene is saved as a .blend file.
Then open Mesh and click Add Mesh. In the Add GN Meshes To: dialog keep
G_WaterandG_Oilticked and click OK: a single Geometry Nodes mesh,M_Water, is created for both fluids. In Mesh Settings:- Voxel Resolution: lower it to 0.04 for a bit more detail.
- Size: raise it to 0.07.
- Smooth XYZ: raise it from 1 to 10 to smooth the surface.
Finally, hide the particles in the viewport with the eye icons in Fluid Groups so only the mesh is visible.
-
Open Shading, make sure Assign is active and browse the Materials previews until you reach MixColors (with Fluid selected). Click Assign Material.
In Settings you'll see its default colors: Color 0 pink and Color 1 green, with Blur at 100. Play the simulation to watch the two fluids mixing. You can change these colors at any time: in the video Color 0 is switched to blue.
-
Save the file first. Back in Shading → Assign, pick Water in the materials gallery and click Assign Material; then pick Oil and click Assign Material again. This creates the
Water_00andOil_00materials.Switch to Blender's Shading workspace and turn on Material Preview: the mesh shows the oil. Press Ctrl+Space to maximize the Shader Editor, select all of the oil's shader nodes and copy them. Open the
Water_00material and paste them. You now have both node trees in the same material: the water nodes on top and the oil nodes below. -
Add a Mix Shader and connect the water shader to its first Shader input and the oil shader to the second. For the Fac, add a Color Attribute node and choose
fl_color: this is the attribute you use to mix the two shaders. Put a Color Ramp in between: Color of the attribute → Fac of the ramp, and Color of the ramp → Fac of the Mix Shader. Finally, connect the Mix Shader to the Surface input of the Material Output.The mesh's material is set in its Geometry Nodes modifier. Open the Modifier Properties and, in
FluidLab_Mesh_GN_00, change Material fromOil_00toWater_00, the material you are building the mix in.Fine-tune the Color Ramp by bringing its two stops close together to sharpen the boundary. Now you can clearly tell the oil side from the water side.
-
The interaction reads better with a more contrasting shader. In Shading → Assign, pick Milk and click Assign Material. In the Shader Editor, copy the milk shader nodes, open
Water_00, delete the oil nodes and paste the milk nodes in their place, connected to the Mix Shader.Assigning Milk changed the modifier's Material to
Milk_00, so set it back toWater_00, the material that holds the mix. Fine-tune the Color Ramp again: water and milk now blend through the samefl_colorattribute.
You now have two fluids that interact in the same simulation and a single mesh whose shaders blend along the fl_color attribute. Swap in other materials from the gallery to see the same interaction with a different look.