Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Fluvio - Fluid Dynamics for Unity

Discussion in 'Assets and Asset Store' started by lilymontoute, Jul 3, 2011.

  1. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Thanks for purchasing Fluvio!

    Good catch on the mobile example - that's due to an incorrect setting (the sphere is supposed to ignore collision with the wheel, to help prevent fluid from going through the wheel due to increased timestep). I'll get that fixed up for next release.

    As far as Fluid Box - it's quite literally just the mobile example scene in a box. The script you're looking for, FluvioTouch.cs, is already included in the package, and works with multi-touch. The only other addition is accelerometer support (Physics.gravity changes based on the device orientation), plus the colors/interface stuff.

    It contains a few other 3rd party plugins (GUI and iOS native stuff), so I can't sell it as is - if you have any questions, feel free to ask either here or in PM, and I can help you out.
     
  2. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    That's excellent! I'll check out FluvioTouch.cs. That makes Fluvio even more of a bargain.

    Allan
     
  3. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Awesome, and thanks!
     
  4. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Any idea how Portal 2 paints fluids into the scene? Are they drawing collisions into a texture atlas? Would it be possible with Your system?
     
  5. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    From what I understand, their paint system uses decals like Fluvio's (although heavily optimized). I haven't messed with the Source Engine in a while, but they have a pretty extensive decal/overlay system that the paint likely takes advantage of. More complex objects getting painted probably have special cases (painting textures/replacing objects)

    Portal 2 fluids are actually quite constrained and don't use real fluid dynamics. That said, you could definitely paint fluid using Fluvio - everything in the paint example video is included in the package, and it's very easy to tell which surfaces have been painted for gameplay purposes. Fluvio's decals are mesh decals, but you could probably write a plugin that does actual texture painting based on where a fluid collides (this may be either faster or slower, depending on the situation).
     
  6. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    A small update:

    ******** VERSION 2.0.8 ********
    Fluvio:
    - RENAME (Pro only): VersionInfo.cs to FluvioVersionInfo.cs
    - Changed menus to unified Thinksquirrel menu
    - Updated the common libraries
    - Tweaked multithreaded implementation (still in need of further testing; not production ready)]
    - Removed extra gizmo file
     
  7. mikesmallhorn

    mikesmallhorn

    Joined:
    Aug 2, 2009
    Posts:
    46
    Can anyone provide an example of a trigger set to detect the particles? I'm having trouble setting one up.
     
  8. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Sure thing!

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using ThinksquirrelSoftware.Fluvio.Plugins;
    5.  
    6. public class MyFluidTriggerPlugin : FluidPlugin
    7. {  
    8.     protected override void Initialize()
    9.     {
    10.         // Anything that you want to run on Awake should be put here
    11.     }
    12.    
    13.     void OnTriggerEnter(Collider other)
    14.     {
    15.         if (fluid == null)
    16.             return;
    17.        
    18.         // Testing by layer is the fastest way to get a particle
    19.         if (other.gameObject.layer == fluid.layer)
    20.         {
    21.             // Do some stuff, a particle is in the trigger
    22.         }
    23.     }
    24. }
    25.  
     
  9. mikesmallhorn

    mikesmallhorn

    Joined:
    Aug 2, 2009
    Posts:
    46
    Thanks! If I wanted to destroy that particle, can I just call Destroy(), or will I need to go through a manager of some sort?
     
  10. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Check out the FluidDestructor component, it does exactly that.

    If you need to do more than destroy it (thus needing a custom plugin), you'll need to call fluid.DestroyParticle(...).

    API References:

    Fluid Destructor

    DestroyParticle() - this method has a bunch of overloads for convenience

    -------------
    Also,

    Just wanted to give a heads up that the 50% off sale on Fluvio Professional/Standard ends tomorrow!
     
    Last edited: Apr 8, 2012
  11. mikesmallhorn

    mikesmallhorn

    Joined:
    Aug 2, 2009
    Posts:
    46
    Should I not be able to simply add a FluidDestructor component and have it destroy that particle after the default 0.1 seconds? I get a "no Fluid defined", but I can see the Fluid is set.
     
  12. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, that sounds like a bug may have creeped in there. Can you check the About Fluvio window (Thinksquirrel > Fluvio > About Fluvio, or Fluvio > About Fluvio for older versions) and let me know what version (number + standard/pro/evaluation) you're on? I'll try to reproduce it on my end. I can't seem to get this on the latest version, so if you haven't updated, you may want to try that first.
     
    Last edited: Apr 8, 2012
  13. mikesmallhorn

    mikesmallhorn

    Joined:
    Aug 2, 2009
    Posts:
    46
    Fluvio 2 Pro Version 2.08, and I'm using Android Basic.

    I'm just using the standard water source that is created when selecting Thinksquirrel > Fluvio > Create Fluid. I store the particles into an ArrayList and add a FluidDestructor to the object in the first index when there list is greater than 10.
     
  14. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Are you adding the destructor to the particle itself or on a trigger object? It needs to be attached to a separate object with a trigger on it.

    That said, I looked over the plugin implementation and found an issue with it automatically finding fluids at runtime. I have a fix for this already and will roll it out with the next update, but for a workaround (pseudocode):

    Code (csharp):
    1.  
    2. void AddFluidDestructor()
    3. {
    4.     FluidDestructor myDestructor = AddComponent<FluidDestructor>();
    5.     myDestructor.fluid = myFluid;
    6.     myFluid.Register<IFluidPlugin>(myDestructor);
    7. }
    8.  
    I'm not sure how UnityScript handles generics in this case, but if you're not using C# you can replace myFluid.Register... and toggle the component (myDestructor.enabled = false; myDestructor.enabled = true;) and it should also work.

    You can then safely ignore any errors in the editor.
     
    Last edited: Apr 8, 2012
  15. mikesmallhorn

    mikesmallhorn

    Joined:
    Aug 2, 2009
    Posts:
    46
    Ah, yeah I was adding it to the particle and not my trigger. Derp. Thanks a lot! That clears things up quite a bit. I suppose I should have just been paying more attention to your docs.
     
  16. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
  17. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    Hi!

    I just purchased the pro version of your tool and I have a few important questions.
    I am actually interested in making a fluid into a beer bottle, that will move when the iphone device it runs on is tilted.
    -How can I make the fluid not transparent but slightly tinted(as yellow for a beer)?
    -Water seems a bit viscous to me. How could I make it less viscous?

    Thanks, that is a great addition

    Stephane
     
  18. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey Stephane,

    Thanks for purchasing Fluvio! You can change the color/transparency of a fluid through two areas - the fluid's material, and the FluidEffect component in the camera (composite color). They each have slightly different effects. There is also a master opacity control on the FluidEffect component.

    For viscosity, check out the viscosity setting in the Fluid component. Turning viscosity down and tweaking the smoothing distance should get the effect you're looking for.
     
  19. forket86

    forket86

    Joined:
    Apr 12, 2012
    Posts:
    2
    I'm really interested in testing this library...I can't download the evaluate version from the suggested link:

    http://thinksquirrel.com/products/fluvio/evaluation

    I've tried multiple times filling out correctly the form but the server give me back an empty page...is this normal?

    Thank you very much for your support,
    Alessandro
     
  20. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    It seems to be down at the moment - I'll have my server admin look into it. In the meantime, I'll send you a copy over PM later today. Sorry about that!

    -----------------------------------
    Edit:

    I'll be pushing out version 2.0.9 in a few days. This will work with 3.5.1 and have an update to FluidPlatformProfiles with iPad 3rd generation support. I'm holding the update back a few days for some more testing and to follow up on some bug reports.
     
    Last edited: Apr 13, 2012
  21. forket86

    forket86

    Joined:
    Apr 12, 2012
    Posts:
    2
    Now it works perfectly!

    Alessandro
     
  22. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    Hello,

    Do you have a demo for gasses please?

    Thanks

    Stephane
     
  23. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Sure thing! Here's a simulation of a gas that is only slightly heavier than the air around it.

    1) Create a default fluid with Thinksquirrel > Fluvio > Create Fluid
    2) Import this .fld file: Download. To import a fluid, click Import... at the top of the Fluid component.
    3) For the stream emitter, change the force multiplier to 0.02. This is important!

    Here's what I changed from the default fluid.

    • I've lowered the mass per particle and the density to something more typical for a gas
    • I've increased the viscosity quite a bit.
    • I've added an interactive force of 9.79 y - this almost completely cancels out gravity. The reason for this is to account for the difference in density between the gas and the fluid around it (air is a fluid, after all). In this case, the gas is actually heavier than air, but by a very small amount (it will take a while for it to lose energy and fall back to the ground). You will need to adjust this if your Physics.gravity isn't at the default.

    These are just baseline settings - you can probably tweak them a bit more to get even more interesting results.
     
  24. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
  25. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    A new version is coming soon with a new example scene - "Bloody".

    I've had some feedback from various people regarding the scale of the example scenes - the Bloody example uses the default Unity scale (1 unit = 1 meter).

    Try it out here!
    Web Player

    2.0.9 also includes a huge performance and memory fix for fluids with large particle counts.
     
  26. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    thank you :)
     
  27. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    About to submit an update with in-editor documentation support:



    I'll also be updating the reference manual for Fluvio to be much more descriptive and fully cover every inspector property.

    Also, just a reminder. Both Fluvio Standard and Fluvio Professional are still on sale!
     
    Last edited: Jun 24, 2012
  28. unity_sg

    unity_sg

    Joined:
    Sep 14, 2010
    Posts:
    95
    Hi, you've done a really nice job, very impressive !
    I've downloaded the free version, I'm interested to purchase the professional one but i have to do some tests before.
    So I hope you can help me

    What I want to achieve is some kind of basic sand simulation.
    I've tried to play with the differents parameters to do some accumulative particles but I didn't manage it
    Could you maybe help me to do this ?
    Is this possible ?
     
  29. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, sand is a bit tricky due to how it acts like both a solid when still and a liquid when moving. I would start with the default template, and change the physic material to something with more friction (very high static friction, medium-to-low dynamic friction). Increase the viscosity a small amount as well.

    I actually just tried this. Here's my result, with the changed settings. This would probably be a good starting point.

     
  30. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Just finished polishing up 2.1 - and the new documentation is already live!

    http://support.thinksquirrel.com/docs/fluvio/reference/



    Changelog:

    ******** VERSION 2.1.0 ********
    Fluvio:
    - Added in-editor documentation! Browse the Fluvio docs directly in Unity.
    - Updated reference manual to be much more robust, with a detailed component reference
    - Removed the switch emitter dropdown for now; will re-introduce it at another time.

    Note: If you have Fluvio Pro, you can re-enable the switch emitter dropdown by uncommenting the lines from FluidEmitterEditor.cs. If you have Fluvio Standard, you probably don't miss this feature since it wasn't working correctly.

    It'll return in a better form pretty soon.
     
    Last edited: Jun 25, 2012
  31. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Version 2.1 has been released!
     
  32. burnill

    burnill

    Joined:
    Mar 24, 2012
    Posts:
    31
    Hey, can you save me any time with a Water.fld file?
    I'm trying to tweak as best as possible but the particles don't fill a bucket properly, they end up flying off or only clumping in a corner and not filling like water would.
    Thanks for any help.
     
  33. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    The default fluid (Fluvio > Create Fluid) has water properties, with each particle representing 1 kg of water. Make sure to check the physic material for both the bucket and the fluid (changing the fluid's friction combine to minimum instead of multiply should fix the clumping behavior).

    Since you're filling a bucket, it sounds as if you're working at a smaller scale. I would try the fluid from the new bloody example, but with the viscosity/physic material of the default fluid.
     
  34. burnill

    burnill

    Joined:
    Mar 24, 2012
    Posts:
    31
    I've got it working slightly, however when the water settles it either stops dead once settled (sometimes in a tower formation with one particle on top of another) or goes flying upwards slowly as if there is low gravity, there doesn't seem to be a middle ground. I've tried lots of settings including the water physic material settings but don't seem to be getting anywhere. Can you shed any light please?
     
  35. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hiiii Nice works on the hydrodynamics simulation, I just purchased the standard version.
    I am an artist and totally a newbie to Unity 3D. The demos I have seen is all sphere-like. But what I am looking to make, is a scene, where a realistic fish swim through an area of water, and the impurities are swirling in the turbulence made by the fish's movement.

    This video more or less shows the effect that I want:
    http://www.youtube.com/watch?v=44kXAITPM1A

    Basically, just the movement of impurities in turbulence.
    So I would like to ask for some hint, how should I set the parameters in order to achieve this effect, not like a sphere looking fluid.

    Thanks for your help;)
     
  36. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Can you send an .fld file or preferably an example scene/project to josh . AT . thinksquirrel.com? I'll be able to take a closer look at this that way. Thanks.

    The video above uses a different method of fluid dynamics known as a Eulerian grid. It works better for modeling things such as turbulence and ripples, but requires a set grid and has a higher computation cost.

    To reproduce something similar in Fluvio:

    Simulation - set your simulation to either X/Y or X/Z with gravity disabled. Make sure your emitter reflects these settings as well.

    Display - the Fluid Effect shader wouldn't be appropriate here, as it is designed for metaballs. However, Fluvio will work with any shader. I recommend a particle shader (such as Particles/Additive or Particles/Alpha Blended) for this. To get rid of the spherical shape, make sure to use a different texture in your material, rather than the default.
     
  37. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi First of all thanks for help me out.
    I spent whole night to tweak the parameters, but the learning curve is still too steep for me.
    Basically the problem is:

    1. I applied a particle material with a particle/additive shader to the fluid particles. But it seems that, after I hit play button, in the scene view the fluid gizmo start to appear immediately, however in the game play viewport, every fluid particle only appear after a certain time. And this certain time seems to be associated with the particles' life parameter. The longer it is, the more time it takes to appear in the gameplay viewport.

    2. Because I want to simulate the impurities in a water field. So the life of particles (impurities) should be as long as possible. But if I increase the life time of particle, than actually I will never be able to see them on my screen, due to the reason 1.

    3. Particles bounce off the character once they collide with each others. It's hard to perceive that any turbulence is forming....TT

    So may I ask you a favor to set up a basic physic model of the turbulence water in .fld. Just a simple one will do. Thank you for your kind help and patience.
     
  38. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    1 and 2) This is a known issue that seems to happen with Unity's particle system (only in the editor, from what I can recall). If you could send me an example scene with this, that would be greatly appreciated - it's been extremely difficult to reproduce on my end, and I've only seen it a few times. Try setting particle life to 0 and trying a build to see if the problem persists.

    3) I'm actually able to get this with the default fluid settings - I'll send you an example scene through PM within a few hours.

    EDIT: I was finally able to reproduce and fix the alpha transparency issue - it seems to related to a bug (optimization?) on Unity's end regarding particle systems. As an added bonus, I've added a "fade over time" setting to the particle renderer. I'll have a new version released soon.
     
    Last edited: Jul 6, 2012
  39. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi, thanks for the kind help. The fade over time function is exactly what I need!!looking forward to the new release. Bravo!
    For the issue 3, probably it's because I didnt give a boundary to the particles. I thought they would perform like thick water. I will try more. In a word, thanks a lot!;)
     
  40. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I've found a few other issues and will be releasing 2.2 fairly soon once those are all sorted out.

    2.2 also includes a new example scene with a top-down fluid surface.
     
  41. theprojectabot

    theprojectabot

    Joined:
    Nov 11, 2011
    Posts:
    38
    your evaluation version is still at 2.04 btw. Id love to try out Fluvio with the 2.2 stuff
     
  42. aliakbo

    aliakbo

    Joined:
    Jan 28, 2012
    Posts:
    35
    Hey,

    Fluvio is really great! Really enjoying playing around with it!

    Though one problem I have is the reaction of fluids with for example my player.
    How can I get to react with my player as its walking through the water?

    Another thing is how do I get floating objects?
    Objects the player can jump on?

    Thanks in advance
     
  43. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    2.2 hasn't been released just yet - it's coming soon though, with a new evaluation version.

    Hey aliakbo,

    For reactions with a player:

    First, make sure your fluid collisions are set to either "others" or "all". In order to get realistic collisions with fluid particles and get reactionary forces, I recommend using a rigidbody on your player. If you want precise control, make it kinematic and apply forces during OnCollisionEnter() from fluid particles.

    For floating objects:

    Unfortunately, this is not very easy without large particle counts. What you're looking for is a buoyancy solver. A quick search pulls up this thread (note that I've never tested this script): http://forum.unity3d.com/threads/72974-Buoyancy-script

    I'll into modifying this to work with Fluvio, with the surface following the curvature of the fluid.
     
  44. aliakbo

    aliakbo

    Joined:
    Jan 28, 2012
    Posts:
    35
    Thanks for you help!
     
  45. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    And how can i get it the other way around if i want that the player is made out of i.e. some fluvio particles so i get the wobble fluid style into it?
    Like a wobbleing ball that i can stear in my level that also maybe can getting bigger if he eats enough of little things?
     
  46. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    For this I recommend making an attractor of some sort - take a look at how the Fluvio Touch script in the examples grab particles into an area.
     
  47. stevenfu

    stevenfu

    Joined:
    Aug 13, 2012
    Posts:
    2
    How to Create 2D fluid? just like Where's My Water?
     
  48. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey stevenfu - check out the 2D water wheel example - that features a similar kind of fluid.
     
  49. stevenfu

    stevenfu

    Joined:
    Aug 13, 2012
    Posts:
    2
    but FPS only 16 (iPhone 4 ,iPod)
     
  50. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I'll take a look at this - previous tests on iPhone 4 hovered around 30 fps. It could be that the platform profiles aren't recognizing the device correctly. What version of Unity are you using, and what particle count is Fluvio reporting in the demo?