Learn about converting a fluid simulation to polygons.
- [Instructor] Bifrost meshing is the process of converting particle data into a renderable polygon object. We can use meshing to art direct the shape of the liquid, Bifrost meshing is an optional step in the workflow because we can also render the particles directly. We'll learn about that in the chapter on shading. Meshing provides a few key advantages, such as shorter render times, compatibility with other programs and a convolution kernel to add peaks on waves.
Select the liquid shape node, you can find that in the outliner, open up the shape hierarchy, and select liquidShape1, and in the attributes of the liquid shape node, we can enable meshing. Scroll down, you're looking for the Bifrost meshing section. Open it up and turn on the enable switch. The timeline is currently on frame one, so we see no change in the viewport. Our simulation begins on frame 96.
Let's hide the liquid shape nodes so that we'll only see the Bifrost mesh in the viewport. Select the top level transform node, which is bifrostLiquid1, and go to the channel box/layer editor. In the layer editor, click the button to create a new layer and assign selected objects. Double-click layer one to rename it. And we'll call it liquid_layer. Click save and turn off visibility for the liquid layer.
Let's also make a display layer for the mesh object. In the outliner, select bifrostLiquid1Mesh. And once again, create a new layer and assign selected objects. Double-click the new layer, and we'll rename this one as well, calling it liquid_mesh_layer. Click save and we'll leave this one's visibility enabled. Go to a representative frame in the animation. I'll set the current time to frame 120.
It will take a moment for this to process as Maya loads the Bifrost cache, and then converts it to a mesh with default settings. It's currently selected. We can go back to the attribute editor. Once again, select the liquid shape node, because that's where the meshing properties are located. Select liquidShape1 from the outliner. And it's displayed with a default material that's transparent. To visualize the mesh better, I'm going to use existing opaque material.
Select the mesh object once again. Right-click and assign existing material. Ideal diffuse lambert. Once again, select the liquid shape node and go back to the Bifrost meshing attributes. We can get in closer on the fluid in the viewport if we want. And maybe turn on wireframe on shaded. Now, we found in the shading menu for that panel, wireframe on shaded.
If we get in very closer, then we can see individual polygons. Before experimenting with any of the attribute values in the Bifrost meshing section, it's a good idea to disable the meshing, because as soon as you touch one of these sliders, a heavy processing will begin and your computer will appear to seize up. So, to prevent that happening, turn off the enable switch and make your changes and then turn enable back on again.
Let's talk about these parameters. Surface radius is the radius of each particle and it's a multiple of the master voxel size. With a default value of 1.4, the mesh surface is generated even in places that particles don't touch each-other. A low surface radius value can sometimes result in a spongy fluid. It looks like it's full of holes, and that takes a long time to calculate. I'm going to leave it at the default of 1.4.
Droplet reveal factor controls the influence of the droplet radius below. Droplet reveal factor using something called the droplet score. Each particle in the fluid has a droplet score, based upon the number of nearby particles. Droplet reveal factor uses that droplet score to reveal particles, so that they can be affected by the droplet radius. Let's experiment. I'll set droplet radius to one and leave droplet reveal at its default of three.
Just press the enter key and re-enable the mesh. It'll take a moment to calculate. So here is the droplet reveal factor of three and droplet radius of one. I'll increase the droplet reveal factor to 10. And then wait a moment while it updates. And we saw that it changed slightly, but all it sort of did was make it a little bit more detailed. But it didn't change the overall shape.
That's because droplet radius is set to one, meaning we're not changing the radius of droplets, we're leaving them at their default value, passing them through at unity gain. But if we increase or decrease the droplet radius, we'll see an effect in the areas that are disconnected from the fluid. I'll set droplet radius to a value of 10. The result of that is that it has increased the thickness of the fluid overall, especially in the areas disconnected from the main body.
If I set droplet radius to zero, then I'm going to attenuate the areas that are disconnected. And now we've got the effect that I want, which is we're subtracting a little bit from the fluid. We can take a look at this from different angles. We can deselect. And we can analyze the effect of changing the meshing settings. We'll need to go to other frames in the timeline to better evaluate the results.
So maybe I'll go forward to frame 180. Once again, that'll take a moment while the cache loads in. And then we can dolly back, take a look at some of the more active areas here. This will help us better understand the meshing properties. Reselect the liquid shape node in the outliner, and if the magenta highlighting is giving you trouble with visualization, you can disable selection highlighting from the show menu.
Show, selection highlighting off. And it'll be displayed in default wireframe colors. Kernel factor is one feature that's unique to Bifrost meshing. It enhances curvature, creating sharp peaks at the crests and waves. This can improve the credibility of a relatively low-resolution simulation. Physically accurate water should have a master voxel size in the range of millimeters. In this teaching demo, the master voxel size is 3.3 centimeters.
We'll use the kernel factor to add peaks, improving believability without increasing processing and storage requirements. Set kernel factor to three. If it helps to change the shading mode, by all means, do that. Then go back into the shading menu and turn wireframe on shaded off again, and changes to the kernel factor will not be so dramatic unless we increase the resolution factor down here. Resolution factor is the overall level of detail, but it's not subdivision, it's more like a sampling factor.
The Bifrost mesh adapts to the curvature of the level set. With a resolution factor of one, we are almost certainly not seeing the full detail of the simulation. In this scene, we could increase the resolution up to three to sample the data more accurately, but to save time on calculation, I'll use a medium-resolution factor of two. Put a value of two in there. And that will take a little bit longer to calculate. On my system, it took about 30 seconds to calculate the mesh on frame 180 with a resolution factor of two.
But now I'll be able to see the kernel factor much more clearly. Set the kernel back up to a value of three. And once again, wait for the calculation to complete. Okay, now we're getting a bit more exaggeration on the wave peaks. Don't want to push it too far, then leave kernel factor at three. We come to smoothing. Smoothing, once again, is not subdivision. It doesn't alter the overall level of detail, like resolution factor does.
And hole kill threshold down here only applies if you've got lots of holes in the interior of the fluid. That's not the case here, so we can leave it at zero. Those are good meshing attribute values for this situation, which is a medium-scale simulation with relatively low resolution. We've employed the convolution kernel to improve the shot's credibility without incurring the cost of a high-res simulation. And just to wrap this up, we should re-enable in our viewport here show selection highlighting back on again.
And that's how to set up Bifrost meshing.
- 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