Learn about storing fluid simulation results on a disk.
- [Instructor] When we have the simulation the way we want it, we're ready to create a user cache, and that's what this chapter is all about: Caching and meshing. Before writing a user cache, definitely double-check the Bifrost options in the FX menu set. Go to the Bifrost Fluids menu. Near the bottom, open up the Bifrost Options. We just need to make sure that Background Processing is disabled and Scratch Caching is also disabled.
Likewise, if you're opening a scene that already has a cache attached, then these features need to be off before you open that scene. All right, so that's the way we want it to be. Hit Apply and Close. To create a disk cache, select the liquid properties container or its transform node. I'll do that from the Outliner. In the Bifrost Fluids menu once again, go to Compute and Cache to Disk options.
First and most importantly, at the top of the dialogue is the cache directory, and that's where the files are going to be saved. The first time we do this, we don't know how much storage this is going to use up. I've tested this scene previously and I know it's going to consume something in the range of tens of gigabytes of storage, and that's why at the beginning of the course, I placed my Maya project on a secondary drive, here on the F drive, and my Maya project is called "Exercise Files." There's a cache directory inside every Maya project, and inside that is a Bifrost directory.
We're going to now create a subfolder in there called 03_01_write_cache, and that name is just derived from the currently open scene. We could change that if we wanted, but we're going to leave that alone. Below that is another field labeled Cache name, and this is going to create another subfolder to actually house all of these many cache files that we're going to create. By default, that subfolder's name is going to be derived from the currently selected container node.
Inside that subfolder, we'll have a whole bunch of bif or Bifrost cache files. Below that, we have compression format, and with simple compression, we'll save a little bit of disk space, and we won't actually lose any data. It's a lossless compression. Below that, we have cache elements. This allows us to save out the simulation or level set, and/or the mesh. I want to save out the simulation this time, and we'll save the mesh for later.
In the cache time range, the default is to inherit the render settings. That's only going to be frames 1 through 10 by default. We could choose the time slider, but that would create a whole bunch of unnecessary cache files before the simulation even begins, so to save disk space and to keep things simple, we'll only cache out the frames in which the simulation is active. Choose Start/End and set the start to frame 96 and the end to frame 360.
We have several modes down here. We haven't created a cache yet, so we want the write mode to be Write All. Now there's good news and bad news about the cache write operation. The bad news is that this is going to take a while. On my system, which is a mid-range workstation, it took about three hours. The good news is that we can interrupt the cache writing process at any time, and then pick up where we left off, so we can let the simulation run until frame 120 or so, then hold down the Escape key and cancel the write operation, then come back into this dialogue and we can switch it over to write from last matching frame, and the simulation will pick up where it left off.
All right, so we can go ahead and click Create. We won't get any update in the viewport, but we can check in on the directory in which these files are being stored, and I've got that open in another window. Let's take a look. Inside our current project, which is Exercise Files, we've got a cache folder. I can open that up, and then inside that, we've got Bifrost. Inside that, we have 03_01_write_cache. Then the name of the container, and then two subfolders, one for solids.
We can open that up, and we see a bunch of bif files, and of course, the solids are for calculation of collisions, and then we have voxel_liquid, which is the liquid proper, and it's here in two forms because again, it's a flip solver. It's a hybrid. We have the volume aspect of the liquid, and then we also have particles. Okay, let's get back to Maya, and I'll cancel the simulation. I'll minimize this window, and give focus to the Maya window by clicking in it and then hold down the Escape key to cancel the cache write operation, and we can see that part of the timeline is displayed in blue, as long as we have one of these liquid nodes selected.
If I select the domain or the liquid properties node, then we see the cached area of the timeline in blue, and we can play the simulation now, and we can even scrub. But we have to be careful because if we accidentally go into an area out here that's not in the range of cached frames, then there's going to be a very long run-up to that frame, and we'll need to cancel the operation with the Escape key. To prevent that from happening, you can just simply set the end of your playback range to one frame before the last cached frame here.
I can set the end of my playback range to frame 104, for example, and now I can play this simulation, and see it in a few frames a second. Once it gets into that cached range, we see, it drops down to maybe five frames per second. It's going to be limited by disk and processor bandwidth. All right, I'll stop that, and rewind it, and set the end of my playback range back to frame 360, and with the liquid properties node selected, go back into Bifrost Fluids, Compute and Cache to Disk options, and switch the write mode over to write from last matching frame, and click Create, and we get a warning message saying that there are files already in that directory, but we don't need to worry about that.
That's kind of a spurious warning, because Maya is smart enough to check for the existing frames, and it's not actually going to overwrite them in this particular mode of the write operation, so we can choose Replace Existing, and it actually won't replace the existing files. It skipped immediately to frame 105 and started simulating. In this mode, Maya finds the last cached frame saved to disk and resumes writing the cache beginning on the next frame. That's how to create a user cache for the level set of a Bifrost liquid.
I'm going to end the movie there, but of course, that's not the end of the caching process. That could take several hours. We'll check back in once the entire frame range has cached out.
- 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