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. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Below is what I mean by too dark and not being receptive enough to the light.

    Multiply Shader (Too Dark):


    Additive Shader (Glows in the Dark):


    Vertex blended gives the same result of multiply. It's worth noting that Unitys multiply double particle shader comes out with roughly the brightness I'm looking for without glowing in the dark.
     
  2. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Thank you very much! Always great to hear things like this. Feel free to showcase any cool stuff you've made on the Showcase forum - people do some pretty awesome stuff with Fluvio.

    So the only light reactive shaders are:

    • Refractive, VertexLit Blended
    • Refractive, Additive Lit
    • Some of the legacy shaders (for the older fluid effect) - I don't recommend these unless you're looking for a very specific effect

    For the first two shaders, there's a light power value. You'll want to tweak those, along with "Normal Direction" under the fluid's particle system (Renderer submodule for Shuriken). Depending on your game, you could also manually set vertex colors of a particle based on their distance from a "light" object, for more fine-grained control.

    If your particles are spawning in the same area (very close to each other) within the same frame (emission is greater than 1), this could be the issue. I recommend increasing the size of the emitter a bit to allow the fluid to flow better. It's just as if you have a ton of water trying to come out of a pipe at once - the pressure becomes too high and some water sprays.

    You may want to play with the velocity limit/velocity dampen properties as well - this will help reduce the overall amount of spray you get, but it has the side effect of slowing down your fluid motion if it is applied too heavily.
     
  3. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Ah okay, I should clarify. Multiply shaders are affected by lights due to how they blend with the scene around them (wheras the vertex lit shader is directly affected by light sources).

    In your case, I would go with a multiply shader, and make sure that the particle system's start color, your material color, material texture are all light colors, so that it isn't too dark.

    Here's a scene I set up just now with a modified fluid material (all default):


    Here are the material settings:
     
    Last edited: Jul 23, 2013
  4. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I tried changing the light power, but didn't seam to do anything. The normal direction caused some strange distrotion. I'm not sure how to go about setting vertex colors based off light distance; is that a parameter somewhere?

    Yeah, I played with those parameters and got exactly what I was looking for; thank you!

    I have similar setup, but it always comes out way too dark. I tried making my lights super bright too with large radius's and it just doesn't light up the water much. I even tried a completely white material and still comes out really dark.

    I was able to make it bright by editing the shader and adding "* 5" to the "screen", which made it close to the brightness I was after. This results in the below.



    Perhaps a new light multiplier (or tint multiplier, whatever name is most appropriate) parameter can be added to the multiply shader (float param? slider with max of 255 maybe? or another color parameter and uses it's A?) or is this maybe the wrong approach?
     
    Last edited: Jul 23, 2013
  5. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, I could look into adding another multiplier to the shader, but I'm a bit puzzled at what is making it so dark in all cases.

    Do you think you could send an example project, with just a bare bones reproducible case to support AT thinksquirrel [dot] com? I'll take a closer look at this and try to get to the bottom of the issue. Feel free to do this at your earliest convenience.

    One more thing, just to make sure - are you using Unity Free or Pro? If you're using the Free edition, you should use the mobile shaders (the non-mobile shaders use a GrabPass, which isn't supported in Unity Free).
     
  6. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I've no idea either, but adding extra multiplier to the tint color in "screen" variable gives the brightness I want, but I'm not sure if this is the correct approach. At any rate if it's ok to post it I can post the modified shader if you want to try it.

    Unfortunately too many commercial assets are used to ensure my project runs so I can't send a demo project. I don't know if I'll be able to reproduce in an empty scene. Your scene is close to what I have, but just isn't as dark. If it matters I have ambient light set to completely black. It seams to only affect deep blue. Using red for example, teal, green, etc.. seams to work fine.

    I'm using Unity 4.2 Pro.
     
    Last edited: Jul 23, 2013
  7. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    If you could email it (rather than post) to the above address that'd be great.

    I'll check 4.2 this week to make sure any surprise changes didn't come through on the Unity end as well. Thanks for the info!
     
  8. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Also I have Unity in DX11 mode with Deferred Lighting. Perhaps this could make a difference for the particles accepting the light properly?
     
  9. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Alright, just took a look at it.

    There doesn't seem to be an "issue" per se with the original shader - I think we're getting consistent results now. I was able to reproduce the same sort of ambient lighting and can now see the problem with low-light responsiveness.

    Rather than hardcode a multiplier, I think that adding a tint multiplier to the shaders like you've done would be the best solution. That way it'll work correctly in both gamma and linear space, and for more types of fluid. So I'm going to go ahead and incorporate this solution into the different shaders for the next release. Here's a comparison image:

    Tint multiplier of 1 (current shader):


    Tint multiplier of 5:
     
  10. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Awesome, looks fantastic. So far using the multiplier seams to do the trick well. I've tried it with different lighting and different colors. Getting pretty good results! I've spent my whole day playing with this, it's so cool!
     
  11. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    On another note, I've just fixed the documentation bug in Windows.

    Also, the next version of Fluvio will re-introduce support for Unity 3.5 from the Asset Store build, so Unity 3.5 users will be able to download right from the store. A lot of behind-the-scenes build pipeline work was done to make this possible! A full changelog will be coming very soon.
     
  12. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ok, another question for ya lol. How would I go about making the fluid more "thick" as in less transparent. I've tried adjusting the Alpha, but that just makes it darker/lighter and doesn't actually change its transparency. I've also tried textures ranging from full black to full white and still have the same level of transparency. I've also tried adjusting start color and alpha. The mobile shader seams to have more along the lines of the transparency I'm after, but thats it as far as its use for me. I suspect I need to adjust this in the shader directly?
     
    Last edited: Jul 23, 2013
  13. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    You'll want to use the Alpha Blended or VertexLit blended shader for this. In your case, VertexLit blended would be the way to go since Alpha Blended isn't affected by lights.

    While taking another look at the shader code, I actually found an issue with the lit shaders as well, so I'll email you a fix for that.
     
  14. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I see, yeah the alpha blended lets me supply a lighter texture and change the alpha to make it "thicker". VertexLit hits the same problem of multiply of being too dark so I added the tint multiplier but doesn't seam to work for it.

    Great, thank you!

    Edit: I can make it thicker by adding a multiplier to "half4 screen =". So looks like another multiplier can be added to increase its density perhaps? I'll play with it and see what I come up with.
     
    Last edited: Jul 23, 2013
  15. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I applied your fix, but it gives some odd results. Please see the below.

    1 Light:


    Multiple Lights:


    With multiple lights it gets darker instead of brighter.
     
  16. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I'll need to review this in more detail then - I'll make sure to sort it out before releasing the update.

    ======

    In other news...

    Fluvio 2 Pro is 80% off today ONLY! Get it now, this is the lowest it's ever been and a great deal!

    http://u3d.as/1Zf
     
  17. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Great, thank you!

    Cool, I already have standard but went ahead and bought pro now too encase I need source.
     
  18. indy2005

    indy2005

    Joined:
    Aug 22, 2009
    Posts:
    81

    Does this work in Unity Free?
     
  19. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Yes, download the Free Edition to confirm if you like. It doesn't say anywhere that Unity Pro is required. What I was saying is I bought the Pro Edition of Fluvio, which comes with source; there's multiple versions with tiered pricing, but atm Pro is best deal with 80% due to summer sale.
     
  20. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    As Krileon said, all editions of Fluvio will work in Unity Free.
     
  21. cmart

    cmart

    Joined:
    Jul 10, 2012
    Posts:
    121
    Hello,

    I just purchased this awesome package, and I can't wait to dive in (yes, horrible pun intended ;D).

    But I think some scenes are missing? for example I don't have this scene (the paint scene)

    http://www.youtube.com/watch?v=MZHWjQKHwEY

    or even this tutorial scene:

    http://www.youtube.com/watch?v=C5oYYUciEfY


    The only scenes I have are the 2D and 3D example scenes. Where can I find these awesome scenes?

    Thank you,


    -Curtis
     
  22. lilymontoute

    lilymontoute

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

    The paint scene and 2D tutorial were both outdated and removed a few versions ago - however it's still possible to create both (the paint scene was mostly made in about an hour or less).

    I can look into getting the paint scene updated and back in - in the meantime I'd be happy to help you if you have any questions on any aspect of the setup for that scene.
     
  23. cmart

    cmart

    Joined:
    Jul 10, 2012
    Posts:
    121
    Hmm ok that makes sense, I would still love to check out the paint scene though :)

    I guess Ill poke around for a bit before I start asking too many questions... that being said I have one already : )

    How would I create, say a "swimming pool" (compared to one unity cube) sized amount of liquid that exists on start up that could be moved around.. say someone hits a switch and the water falls down a slide, for instance.

    Thank you
     
  24. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I would make a Fluid Cube Emitter, set it to uniform, and set the emission count to your maximum particle count - that way it will emit all particles on load. This will emit a perfect cube of fluid, which you can position in your pool. You can also enable "One shot on max" to disable the emitter immediately afterward, if your particles are persistent.
     
  25. cmart

    cmart

    Joined:
    Jul 10, 2012
    Posts:
    121
    Hmm that seems to be a bit closer to what I am trying to do.. Is there a way to make the liquid "bigger" without increase particle count?

    Also, is there a way to make the liquid "stick together" in that it tends to stay together rather then spread apart... Sort of like in the 2D example when you press the left mouse button, that would be perfect behavior for what I am trying to do. But instead of following the mouse around, it behaves like liquid but it just stays together.. I guess I kind of want to make a "blob" that behaves like liquid more then a straight up water simulation.

    I hope this makes sense!

    Thank you for your help, I am loving this asset!
     
  26. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    You'll want to change the Smoothing Distance on the fluid. Render size is changed as normal, in the particle system. Getting the smoothing distance right can be pretty complex, so I recommend reading the linked article to get a better grasp on how SPH simulation works.


    You bet! Check out the various Fluid Attractor components. You can even make fluids that form the shapes of various meshes.

    You're welcome, and I'm glad to hear it!
     
  27. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Aha, figured out how to get it to respond to light properly. You gotta use a Mesh renderer. Using a billboard just doesn't work right as technically it can't receive light automatically and has to be calculated using complex light calculations, which based off my research are stupid hard to do. I used a circular mesh and it responds to light perfectly now.

    I think the multiply shader with the tint multiplier and billboard renderer gives best results though.

    My last task is to figure out how to change the transparency of the multiply shader. Any pointers of where to look? This would make the fluid my "thick" basically.
     
    Last edited: Jul 24, 2013
  28. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    I would look at the result of the grab texture, and give that less weight compared to the other colors. For example, if the grab texture was replaced with full white, the liquid would render against white and ignore what was behind it... I'm guessing you don't want fully opaque though.
     
  29. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Still pretty new to shaders. If you don't mind could you explain a bit more? I should adjust the rgb of the grab texture before the below or act on the results of the below somehow?

    Code (csharp):
    1.  
    2. half4 screen = tex2Dproj (_GrabTex, ....
    3.  
     
  30. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I have exactly what I am wanting with the below except it's too transparent.



    I guess I'm just trying to make murky water, lol. Any idea how to dial back the transparency? I multiplied the grabtext rgb by 255 and it got a little thicker, but it of course went bonkers in its behavior, lol.
     
  31. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    You could try playing with the refraction texture/distortion amount.

    I still recommend seeing if you can get the VertexLit Blended shader to work well - that one is designed to be opaque, by adjusting the alpha in the tint color. I'm not sure what's causing the multiple light issue in your project... I haven't been able to reproduce it since the lighting fix I made earlier.
     
  32. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    The only way I can get vertexlit blended to work properly is to use a mesh renderer instead of billboard, but then the texture doesn't look quite right. I'll keep playing with it and see if I can get the mesh renderer to display better.
     
  33. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Still really odd that that's happening - may be a DX11 issue. As far as the mesh goes, you could try to use a quad mesh instead of a circle and that should fix any UV issues.
     
  34. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Using a quad got rid of the UV issues, but I still have the odd issue of it getting darker instead of brigher. Then with too much light it blacks out. It's really odd. I'm at a complete loss as to what causes it.
     
  35. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Looks like it's due to the Ambient Light. I have it set to 0,0,0 as I want my scene lighting completely driven by the lights in the scene. If I set it to 32,32,32 it doesn't completely black out anymore when a bunch of lights are present. Any suggestions? I guess it's trying to blend with the Ambient Light, maybe a parameter to let me supply a color to blend with instead of blending with Ambient Light?
     
  36. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ok, added a parameter to specify custom ambient, but then it comes back to glowing in the dark issue. Uhg, this is a nightmare to figure out; they really need to improve shader documentation and most of all auto-complete in monodevelop.
     
  37. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I checked documentation and ShadeVertexLights only calculates for 4 lights. Once I hit 4 or more it totally blacks out. That could explain why it's not working right.

     
  38. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ok, seams to be due to the mesh I'm using. No idea why it's going bonkers with a simple quad mesh. Anyway, thanks for all your help. Seams like all that's left is tinkering with it on my end. :)
     
  39. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Got it exactly how I want it. Below is my end result. Absolutely love it!



    I know there are attractors to keep it together, but the attractor doesn't move. Is there a way to keep the water close together so it flows more like a liquid and less like a bunch of water drops close together? I want to avoid water drops kinda off somewhere by themselves.
     
  40. Tonmeister.

    Tonmeister.

    Joined:
    Mar 30, 2013
    Posts:
    27
    hi thinksquirrel, I too would like to try the paint scene. Watching that video was one of the reasons I was attracted to fluvio. I think it would be a nifty reimplementation.

    cheers
     
  41. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hm, have you tried adjusting the viscosity of your fluid? If you're getting too much spray, you could also look at automatically destroying particles that get too far from a specific point.

    I'll definitely take a look into adding back the paint example.
     
  42. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Basically what I mean is is it possible to have the fluid attracted to each other so they have a tendency to pull towards one another instead of breaking apart so easily.
     
  43. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    That's essentially what viscosity is - the more viscous a fluid, the "thicker" it is (think water vs sour cream) - so if you make your liquid more viscous it'll increase the attraction force between particles. Likewise if a fluid is less viscous, the attraction force is weaker (more breaking apart, more splashing).
     
  44. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ah, I understand. Ok, thank you! I'll keep playing with the setting until I've more like what I'm looking for. :)
     
  45. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Version 2.2.1 is releasing soon! This is mostly a bug fix release.

    Full changelog:

    Fluvio 2.2.1
    New Features


    Streamlined Installation
    Both Unity 3.5 and Unity 4 users can install the latest version of Fluvio direclty from the Asset Store. The correct version of Fluvio will be automatically installed based on the Unity Editor's version.
    Thinksquirrel Product Registration
    You can now optionally register your copy of Fluvio. This ensures full product support - you can also sign up for an email notification whenever a new update is released.
    You can visit the registration page here.

    Changes and Fixes



    Other Changes

    • Fixed a bug where in-editor documentation would crash Unity.
    • Added an intensity value to the Refractive/Multiply and Refractive/VertexLit Blended shaders.
    • Fixed a regression where default fluids would not initialize their distortion texture properly.
    • Vertex lighting now works correctly for lit shaders.
    • Fixed a depreciated code warning in the Fluid class.
    • Fixed a regression/crash bug when using multiple legacy fluid effects.
    • Moved the Thinksquirrel > Fluvio menu to GameObject > Fluvio and Window > Fluvio to comply with new Asset Store guidelines.


    Compatibility Notice
    Fluvio now uses Shuriken for particle rendering and requires Unity 3.5+. The legacy particle system is no longer supported. Shuriken world collision requires Unity 4.0+. Fluvio 2.2 is not backwards compatible with older Fluvio versions - please remove older versions of Fluvio from any existing project before upgrading!


    2.3 is already being worked on, with some content updates. There's some pretty cool stuff in the pipeline...
     
  46. mikezenox

    mikezenox

    Joined:
    Oct 18, 2012
    Posts:
    55
    Fluvio pro causes Unity to crash while I manipulate the gameobject with particle emitters on it, I just installed it and can't seem to get it to work.
     
  47. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Hey mikezenox, sorry to hear about that! I'd like to take a look at your editor log file. Can you do the following:
    1. Reproduce the crash.
    2. Before reopening Unity, copy the editor log file to a different location. You can find the location of the editor log here.
    3. Send that file to: support AT thinksquirrel -dot- com.

    Let me know if you run into any issues with the process. Thanks!
     
    Last edited: Jul 28, 2013
  48. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Noticed an issue with timescale and the fluid. When you set timescale to 0 the fluid goes bonkers flying all over the place. Any idea how to cut back on that or remove it entirely? I use timescale to pause my game as it's simple enough that it works fine.
     
  49. lilymontoute

    lilymontoute

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

    Just tested this out and I'm unable to reproduce the issue; do you have any explicit steps to reproduce this in one of the example scenes?
     
  50. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I tried with a default fluid with the axis set to XY so it's 2D, but it still does it. So create a new fluid, set to 2D, ensure there are collisions around it so it's noticeable. Set timescale to 0 then back to 1 shortly after and it should do this strange popping.