Obi Fluid 3 for Unity: what’s new
Obi Fluid 3.0 is available! This new version is compatible with Obi Cloth 3.0, and quite a few features and improvements have been added.
Note that most images and videos in this post are 2D to better illustrate the points, but the same is applicable to 3D.
Simplicity and robustness
The parameter set for materials has been reduced and simplified. Separate material assets have been created for fluids and granular materials, so parameters specific of one of the two materials don´t clutter the other one.
A single parameter (aptly named “resolution“) controls the amount of particles that make up your fluid or granular material.
Keeping all other parameters constant, your fluid will behave in the exact same way at different resolutions, only the level of detail will change. Particle radius and mass are automatically calculated from this single parameter, so you don´t have to spend time tweaking lots of non-physical values.
Here you see the same fluid at resolutions 1 and 3, from left to right. No other parameter except for resolution has been changed, so the qualitative behaviour of the fluid is exactly the same for both. There’s no need anymore to tweak all parameters every time you change particle size.
Also, fluid parameters behave in the same way both in 2D and 3D. You simply switch the solver from 2D mode to 3D or viceversa, and you get the exact same fluid behaviour, just one dimension more or less 🙂
2.x already supported multiphase fluids (kind of), but 3.x can handle much larger density ratios without any artificial gaps at the interface between phases (meaning, where both fluids touch each other), and without any instabilities.
In the following video there are four different fluids, each one with its own density, viscosity and surface tension, a total of 10.000 particles. The density ratio between the orange and the white fluid is 1:10. You can see how denser fluids sink to the bottom quickly, and how bubbles of lighter fluid are formed and rise to the surface. It runs realtime (50 fps) in a Core i7 CPU, using the default Unity timestep (0.02) and seven density iterations per step.
Screen-space fluid shading has been upgraded and simplified. Support for DX11 and Unity 5.5 has been added, and you can now write your own fluid shaders in a streamlined, simple way. Here’s two simple shaders made with the shader template included in 3.0:
One-liner cartoon shader:
fo.color = lerp(inner_color,outer_color,step(thickness,0.13f)) * tex2D(_Foam,i.uv);
Diffuse phong shader
(We are not showing the code here as it is slightly more involved. Eye space and world space fragment position, normal and view vectors are readily provided by the template shader).
The new ObiFoamGenerator component can spawn shuriken particles in zones of high vorticity, which will then be advected by the fluid velocity field. This can immensely increase the realism of your fluid, specially at low resolutions, making interesting flow patterns inside the fluid visible. Works both in 2D and 3D, foam rendering takes fluid transmittance into account when using the included dielectric fluid shader.
Since foam particles are spawned using a regular Shuriken particle emitter, you can still control things like particle color, size, material, trails, etc. just like you would in any standard particle system.
The spatial partitioning structure used for particle nearest-neighbor detection is now incrementally updated from frame to frame, instead of being rebuilt from scratch. This allows Obi to take advantage of temporal coherence and has cut the average time spent in neighbor bookeeping almost by 80%.
Also, Obi Fluid 3.0 inherits the new task-based threading architecture introduced by ObiCloth 3.0, and density constraints now process 4 neighbor particles at a time thanks to SIMD.
We are really excited about this release! we hope it will bring easy to use, robust, versatile and performant particle-based fluids to Unity.
The VM team