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 🙂
Multiphase fluids
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.
Better rendering
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).
Foam generation
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.
Improved performance
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.
Stay tuned!
The VM team
Just got Obi Fluid and noticed that fluid renderer does not work! Is there any way to fix that situation quickly? There is an urgent update I need to make and Obi Fluid seems to be the best option if the fluid renderer works!
Hi James!
The current version of the renderer does not support DX11, the version we are about to release (the one described in this post) resolves this issue. In the meantime, switch to OpenGL and it will work. Alternatively, you can write to our support email with your order number and we can send you a hot fix to enable DX11 rendering in your current version.
Looks really nice.. Do you plan on supporting the creation of a volumetric soft body from a mesh? ( maybe you already do in one of the plugins but i can’t find it)
For example: https://www.youtube.com/watch?v=gbRLMiWbXU0
Hi Chris! This is something we plan on doing in the future, it will be released as a separate asset capable of simulating rigid and soft bodies, using shape matching. Note that this approach does not need volumetric (tetrahedral) meshes, works with any mesh instead.
ObiCloth can simulate soft bodies to an extent, but it relies on volume matching constraints (that also work with regular meshes, as long as they don´t have any holes). This means that while the overall volume of the object is preserved, its shape is not. This is good for very saggy objects, like partially deflated balloons, but not very good at simulating more rigid objects -like say, a rubber ball-.
Hi! If you want to suggest new features or follow the status of Obi, signup to our newsletter or join our support website. Find all of it here: http://obi.virtualmethodstudio.com
Hi!
how to set up an elastic fabric as the hat edge?
or tough skin?
Hi there! For questions regarding the use of Obi, please write to our support email or raise a question at the Taiga product page. cheers!
Hi all!
I have….*no* idea how to make a fluid not transparent. Is there no variable for this? What I want to do is start using *honey*, because I like the way it pours and the viscosity, but be able to make it more opaque. I can’t find any way to do this. I’ve tried using all the materials, changing the lambert (the only material that I see in the materials folder) around, and a few other things but I can’t seem to get it. Please help!! I see above you say for question to write the support e-mail but..where is that on your site?
Hi Rachel,
You´ll find our email in the Contact section of Obi’s site:
http://obi.virtualmethodstudio.com/contact.html
To make a fluid opaque, just use the OpaqueFluid material you´ll find right next to the default DielectricFluid material. Drag it to the FluidRenderer’s “material” attribute and you’re done :).
Thank you for your very quick response! However, even doing that doesn’t make the fluid opaque, I need an opaque white liquid for our project. I’ve trying to change the color material, maybe that’s why? After using the opaque fluid I can get opaque black but that’s all. Are there tutorials you can point me too? All I can find are the Obi manual, which honestly isn’t helping much because in the fluid setup section it doesn’t go step by step, and the videos on youtube that just shows the product but not how to use it….
Please ask those things in our forum! You will get proper help now and in future queries!
http://obi.virtualmethodstudio.com/
HI!
I bought OBI fluid 3. There was a description that it works on mobile, but when I put out 200 particles in 2D mode, it will drop to 48 FPS. The device is iphone 7plus. I changed various solver and material settings, but it will not be improved. Is performance limited? Please tell me if there is any good setting for mobile.
Hi Ken,
There’s lots of parameters that greatly affect performance:
– Amount of density constraint iterations. (less iterations = more compressible fluid = better performance)
– Emitter material resolution (lower resolution = less particles = better performance)
– Emitter smoothing (lower values = less “fluid” fluid, better performance)
– Timestep (the default of 0.02 should be ok, but you can increase it)
Recently I recorded a video of 600 particles at 50 fps in a 6 years old iPhone 4S, so with some parameter tweaking you´ll be able to get much more particles in a 7 plus. You´ll find the parameters I used in the video description:
https://youtu.be/0g1TfuNr6pw
Hi! I’m working on a simulation and need to know if its possible to unrender or if there is some way to configure ObiFluid to turn generated particles into on 3d object after a certain number have been generated?
Hi Tyler,
Obi does not use meshing algorithms (like marching cubes) to render the fluid, as these are usually not suitable for realtime. We use screen space splatting to render the fluid, which completely avoids having to generate a 3D surface mesh from the particles.
If you need to extract the fluid surface as a mesh, you´ll have to use your own approach.
Hi I’m wondering if this fluid system can be used to create a matrix of stiff particles that could be disrupted by an animated complex rigged mesh moving through it as in the example here? https://drive.google.com/open?id=0B6BNrq2NGe8MTUNEMU9leXV2bUk The particles need to return to their starting point and ideally be individually scalable or controllable sprites. I have a spring and 2d collider setup but it is too expensive when dealing with complex mesh coliders. Would this be possible with obi fluids?
Hi Baryy,
Using springs is the way to go to implement what you see in that video. Simple springs attaching the particles to their starting position is several orders of magnitude cheaper than full blown fluid simulation -if implemented correctly- since each particle is completely independent from all other particles. This is not the case with fluids, where each particle depends on all other particles.
From what i can tell by looking at the profiler shown in your video, you’re running into a death-spiraling type of situation. It’s not good to have your physics step called 10 times per frame (which is what is the profiler shows). Reduce your max timestep to be 2-3 times your fixed timestep and that alone should boost performance.
cheers,
Is it possible to measure something like milliliters or liters with obi fluid? Id like to use it in a game where we mix several fluids together and where the player needs to use the exact amount of fluid.
Yes, like you can with any particle-based simulator. You just have to keep in mind how much volume is represented by each particle, then multiple that by the amount of particles.
For instance: At resolution 2, there are 2000 particles per cubic meter. So each particle is exactly 0.5 liters. (since 1 cubic meter holds 1000 liters)
Awesome thanks for the fast reply! (and for a detailed example) 🙂
can the fluid be scaled, I mean, the curent sample is like 100x bigger to fit my scene.? Like really?i cant scale my whole scene, to fit this, I got all of your plugins for Unity and Non of them quite work
Just increase the fluid material resolution if you need a finer particle representation. See:
http://obi.virtualmethodstudio.com/tutorials/emittermaterials.html
However keep in mind that when working with any physics engine, it is absolutely crucial that your scene scale and the size of your objects is 100% correct (can’t stress this enough). For instance if your scene consists of filling a glass of water that is 10 millimeters high, the simulation won’t behave or look realistic at all.
Unity (and thus Obi) uses metric units: meters for distance and kilograms for mass.
Hey!
I cant seem to register for the forum? So i will ask this here.
I tried your solution you posted for collision detection and tried to count the amount of particles inside a collider.
It worked but the problem is it seems to count every frame the particles are in the collider. How can I solve this so that the particles are only calculated once.
I tried to kill them too but in the forum you posted a obiemitter script that solves the killing part, which i cant download cause i cant register :p
Thanks!
Please 😛
Yeah, the forum is a little broken but if you send us an email to obi@virtualmethodstudio.com telling us the email and username you want we will create the account for you.
We prefer that you ask things there! Thanks a lot!
Forum is fixed at last!
Worked for me!
Big thank you again.
hey there,
im having some issues with the obi fluids
1- the fluid for some reason is not rendering, like i can see the bounding rectangle that shows it’s emitting particles yet i cant see them in the game view,
2- how do i get feedback if the fluid collided with another object or not ?
3- im getting this alert everytime i run the game “CommandBuffer: temporary render texture _FluidDepthTexture not found while executing Render fluid (SetGlobalTexture)”
hope you reply ASAP
thanks in advance
im also getting this in my camera component :
“1 commant buffers
BeforeImageEffectsOpaque: Render fluid (1.0 KB)
Please, join the community forum for Obi. Our blog is not a good place to get proper support 🙂
http://obi.virtualmethodstudio.com/
im sorry but are you sure you gave me the correct link ?
Yep. There are sections on the top. Find the forum there.