Learn about spawning foam particles from a fluid simulation.
- [Narrator] Foam is an additional Bifrost property container that adds secondary particles to a liquid simulation. It comes with its own shape node, and the particles can render as a surface or a volume. I do recommend that you cache the liquid before creating foam. You can create them both at the same time, it's just going to calculate very slowly. If we go to my current Bifrost liquid properties note and it's attributes. If we go into the cache section, caching, liquid cache.
We'll see that I have a cache in place from a previous exercise, the beginning of chapter three, 0301 write cache. If you haven't done this exercise, and don't have the cache files on your hard drive, you want to build the cache of this scene before proceeding. I've also disabled all of the nodes except for the primary container nodes and the Bifrost liquid properties. If we go into any of these others ones, they've been disabled.
With those nodes disabled, we can go ahead and press play in the time controls, and it may hiccup once it starts loading the cache, but once the cache is loaded you should see pretty fast performance in the view ports. And we have random access. Let's stop it around frame 120, or 130 or so. Before adding foam we want to know the ranges of the churn curvature and velocity channels. So let's preview that in the view port.
Select the liquid shape node in the outliner, and in the attributes, you'll see that I'm displaying as Voxels. So close the particle display section, and you'll see the Voxel display section here. And there's a switch for diagnostic color. You can turn that on and it defaults to the velocity color channel. Open up the color channel remap section below it, and we can see that the default range of twenty for the velocity looks actually pretty good.
We're seeing the entire range of colors here. I'm using these very harsh colors for clarity in the analysis. And I've chosen linear interpolation for the gradient ramp. Foam works based on churn, curvature, and velocity, so velocity is the first one on our list, and it looks like we can bring the color channel max down to, let's say ten. And now we're getting actually a better distribution of the colors. We're seeing that intense red here in the very fast moving parts of the fluid.
Let's look at churn. Go up to the color channel and choose churn. And that is technically a range from zero to two. We can set the color channel max to two. We're just using this to emit particles so we're not too worried about the shading properties here. We can intentionally clip off some of the data, set the color channel max to a value of one, and press enter. And now we're seeing a lot more effect from that churn. Last we have the color channel of curvature.
And likewise it ranges from zero to two. In this case I think I'm going to opt to not clip off that data. I'll set color channel max to a value of two. Now we're ready to add the foam. Rewind back to frame one, and select the Bifrost liquid. Go into the FX menu set and from the Bifrost fluids menu, choose add foam. The new foam one shape is also a child of the Bifrost liquid, and we also have the Bifrost foam properties node.
With the foam one shape selected, go over to it's attributes. Go into the particle display section, and change the point size to three, so that when we play this we'll be able to see that foam better. Also at the top we can disable display bounding box. With foam one still selected, let's put it on it's own display layer. Go to the channel box layer editor and click create a new layer and assign selected objects. Double click the new layer one and rename it foam layer.
Press enter and click save. We need the colliders to work again for the foam, so go back to the attribute editor, and select the Bifrost collider room node, turn on the enable switch, select Bifrost collider door, and also turn on the enable switch, and we can now play the simulation. Maximize the perspective view with the space bar, and press play, and let's see what the foam looks like with default parameters.
It's definitely running more slowly because of the foam and the collisions, but foam is being emitted from the liquid, and in the following movies we'll adjust it's attributes to make it more beautiful.
- Bifröst basics
- Analyzing the node structure
- Emitting from a polygon mesh
- Colliding with a polygon mesh
- Adding velocity, friction, and drag with motion fields
- Optimizing space and time accuracy
- Caching simulations
- Meshing and exporting liquids
- Render-time meshing in Arnold
- Applying channel data to Arnold shaders
- Generating foam from a liquid
- Rendering and shading foam in Arnold