From BlenderWiki

Jump to: navigation, search

[edit] Documentation (GSoC 2016 - Blender Mantaflow Integration)

Main idea of this GSoC project was to integrate Mantaflow liquid effects into Blender. The exisiting Mantaflow smoke integration, which builds on top of the smoke modifier, was therefore taken as a basis and extended to handle Mantaflows FLIP based liquid effects as well.

This way the smoke modifier can be seen as a general fluid modifier, handling both fluid types smoke and liquid. The current liquid modifer (Elbeem "fluid" modifier), which was left untouched anyways, is not needed in this setup.

[edit] Getting started

The code for this project is in the branch fluid-mantaflow. You can build it under Linux and Mac - Windows is unfortunately not supported (see Future Improvements).

[edit] Building

When building it is important that CMake flags WITH_MANTA, WITH_SMOKE and WITH_OPENMP are all set.

Follow the official build instructions and everything should work fine.
Since Mac does not use an OpenMP enabled compiler by default, one has to explicitly set one. You can use the Clang compiler from the lib folder for that:
   cd blender-git/build
   cmake ../blender/ -DCMAKE_C_COMPILER=<your_path>/blender-git/lib/darwin-9.x.universal/clang-omp-3.5/bin/clang 

Another problem on Mac seems to be MacOSX10.11.sdk. I was only able to compile using MacOSX10.10.sdk and explicitly setting that.

Currently not supported

[edit] Quick Liquid

The easiest way to setup a liquid simulation and to try out Mantflow liquids inside Blender is to use the new quick effect Quick Liquid. Just as Quick Smoke and Quick Fluid, it is accessible from the Spacebar Menu.

Setting up a liquid simulation using Quick Liquid

[edit] Sample scenes

Another good starting point are the Blender Mantaflow sample scenes for smoke and liquids. They should give you an idea which values to use for the new liquid settings.

Blender3D FreeTip.gif
Loading Elbeem liquid scenes
The Mantaflow integration is fundamentally different from the current liquid solver Elbeem. There are new settings to control the liquid behaviour, smoke and liquid cache are unified and baking results appear directly in the viewport for instant replay. For now, it is therefore recommended to start fresh and build new liquid Blender scenes instead of loading old ones.

[edit] Overview Fluid UI

Getting liquids into the smoke modifier required bigger changes in the UI. Smoke settings had to be reorded and liquid settings had to be added. If you are familiar with the current smoke UI though, this layout should not take you long to get used to.

[edit] Fluid Domain

Fluid tab settings for a liquid domain object

The most notable change for domain objects is that a domain type needs to be chosen. Right now, you can choose between either liquid or gas domains. Depending on what you choose you will be presented with settings matching your domain type in addition to the general domain settings (e.g. gravity, border collisions, time scale).

Gas settings are the same as in the current master (2.77) - they just have been reordered a bit.

For liquids there are two new parameters:

This factor controls how particles are sampled. A higher value results in more randomness. For the mesh surface this means that it will become rougher the higher you set the value.
Controls how many particles are sampled. A higher value results in more particles.

[edit] Fluid Flow Objects

Fluid tab settings for a liquid flow object

With the additional flow type liquid it made sense to clean up terminology a bit. When setting up a flow object you now not only choose the type but also its flow behavior. Options are for this setting are:

Constantly add fluid to the simulation. Up until now we always used this flow behavior for smoke, for liquids you can consider this as being your tap.
Removes fluid from the simulation. It is essentially your drain for the fluid domain and prevents it from filling up completely.
Only the given geometry is used for inflow. Think of this as type "inflow" but only for one frame.

For flow behavior types Inflow and Geometry it is also worth noting that there is an animatable property to enable / disable the flow. Elbeem provided this feature as well.

Liquid inflow with different border collisions: vertically open, horizontally open, collide all

[edit] Fluid Quality

Grouping settings that control the fluid quality was part of the UI cleanup. The Fluid Quality panel was therefore introduced. It contains a lot of settings that already existed, only the viewport display switch was added. However, it should give an idea of how high resolution settings for smoke and liquids can be combined.

[edit] Fluid Cache

Caching under Elbeem works by writing out a sequence of bobj.gz files. The Mantaflow integration does the same, the only thing that changed is that those liquid mesh files are accessed like the pointcache files.

That is, you can access cache settings for liquids through the same UI known from the smoke. Only the file format needs to be set differently (for liquids you would set it to Object file format).

There are multiple advantages to this approach: All cached fluid files are now stored in one central location, changing file names is much easier and, most importantly, baked scenes can be replayed instantly in the viewport (no more waiting for the cache to finish baking to see first results).

[edit] Future Improvements

There is still room for improvement. Here are some things to keep in mind and watch out for:

[edit] Features

High resolution option for liquids
Similarly to the smoke high resolution option, it should be possible to improve liquid simulations with an upres factor.
Liquid obstacles
In my view, this is one of the features with higher priority. Static smoke obstacles already work. Animated ones and the all liquid obstacles, however, don't work yet.
Backwards compatibilty to older liquids simulations
A lot of people will want to use older liquid scenes. This has to be taken care of (probably in versioning files).
Windows support
During this GSoC it turned out that there is a linker issue with the Blender Mantaflow integration on Windows. The issue has to be fixed in Mantaflow itself, then Windows builds will work as well.
Mixed domain setups
"Smoke on the water" pretty much says it all. Now that we're using a single fluid solver it should (finally) be possible to create nice interactions between liquid and smoke (or even fire :).

[edit] Bugs

A list of current bugs, todo's and possible smaller features can be found over here:

Liquid splash at 512 divisions. Simulated with the Mantaflow integration and rendered with Cycles

[edit] Acknowledgements

A very big thank you goes to Nils Thuerey for mentoring this project and for helping me with Mantaflow! Thanks, I learned whole lot about liquid simulations!

I would also like to thank Ronan Ducluzeau (zeauro) for helping with the new Fluid UI (and for taking the time to create some cool videos, check out the video page!) and Gottfried Hofmann for testing the branch.

Thanks again to everyone who helped with the project, the Mantaflow integration has become a lot better!