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

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    Great to see these new things. Just saw that the latest fluvio i have downloaded from the asset store has date from 12.12.2013.

    Hope the new version is comming soon.
     
  2. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    So I think the beta is finally at a state where it can get its first public release - there are a few things that have to be done at this point (compatibility checking with 4.5/4.6, mainly).

    I have something very awesome to share with you guys - I've had something in the works for a while and it's only really been feasible once the groundwork with the new solver was set. It will be available with the first beta as well.

    GPU accelerated fluids!

    With GPU fluids, my desktop is able to simulate up to around 12,000 particles before any FPS drops, and that's still while using Shuriken to render the particles (so the bottleneck is on reading data back to the CPU). GPU accelerated fluids are currently only supported on DX11, but I have plans to get them working on OpenCL as well. I also plan on implementing a geometry shader on DX11 that will allow rendering of fluid without any reading back of data - this should easily allow 100k+ particles on a desktop.

    I'm super excited about this, because the performance difference is like night and day, especially compared to 2.x. Fluid simulation is a really good fit for GPU computing, and I've wanted to get Fluvio running on the GPU for a while now.

    Here's what I've done:
    • Ported the solver to Cg/HLSL
    • GPU acceleration is just a checkbox, and can be switched on and off at runtime - even while a fluid is simulating
    • Fallback is automatic - if GPU acceleration is unavailable (non-DX11 platforms at the moment), fluid simulation will run on the CPU. You can supply a fallback particle count and fallback emission rate to automatically adjust particle counts accordingly as well.
    • All plugins have a GPU implementation included and use the same public API that you can use to create your own GPU fluid plugins. GPU and CPU plugins can be mixed, but isn't recommended due to an initial performance overhead (we have to read back more buffers). Plugins also fallback automatically with fluids. Here's an example of how easy plugins are to make (plugin variable declarations removed):
    C#:
    Code (csharp):
    1.  
    2. protected override void OnUpdatePlugin(SolverData solverData, int particleIndex)
    3. {
    4.     for (int i = 0, l = m_TouchPointsCount; i < l; ++i)
    5.     {
    6.         var pt = m_TouchPoints[i];
    7.         var worldPosition = solverData.GetPosition(particleIndex);
    8.  
    9.         var d = pt - worldPosition;
    10.         var distance = d.sqrMagnitude;
    11.  
    12.         if (distance < m_SqRadius)
    13.             solverData.AddForce(particleIndex, d.normalized*acceleration, ForceMode.Acceleration);
    14.     }
    15. }
    16.  
    HLSL:
    Code (csharp):
    1.  
    2. #include "Assets/Fluvio/_Main/Resources/ComputeShaders/Includes/FluvioCompute.cginc"
    3.  
    4. #pragma kernel OnUpdatePlugin
    5. FLUVIO_PLUGIN(OnUpdatePlugin, particleIndex)
    6. {
    7.     if (FluvioShouldUpdatePlugin(particleIndex))
    8.     {
    9.         for(int i = 0, l = _TouchPointsCount; i < l; ++i)
    10.         {
    11.             float3 pt = _TouchPoints[i];
    12.             float3 worldPosition = solverData_GetPosition(particleIndex);
    13.        
    14.             float3 d = pt - worldPosition;
    15.             float dist = dot(d,d);
    16.        
    17.             if (dist < _SqRadius)
    18.                 solverData_AddForce(particleIndex, normalize(d)*_Acceleration, FLUVIO_FORCE_MODE_ACCELERATION);
    19.         }
    20.     }
    21. }
    22.  
    Here's what is planned:
    • OpenCL support for OS X
    • Possible Metal support on iOS (this will be a ways off, and Unity may beat me to it by supporting Metal with standard compute shaders)
    Other stuff we've done since the last development update:
    • Added fluid culling - simulation can now be optionally culled whenever a fluid isn't visible
    • Plugins have a configurable execution order
    • The fluid effect now renders in the scene view as well
    • Added static fluids - these are kinematic fluids that have additional optimizations in Play mode and in builds, and are assumed to never move
    I hope to have the beta out to the public *very* soon - the project now compiles and is generally working in 4.5/4.6 (development so far has been done in 5.0). The new fluid effect and example scene still needs to be ported to 4.x, though. Edition/pricing information for 3.0 should be out this week, with the changes taking effect once the beta releases.
     
    blueivy likes this.
  3. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Here's 4 fluids (with a total of 16,000 particles) running on the GPU (GTX 770) at around 26 FPS:



    Here are the timers (since that text is a bit small):
    • Solver + Plugins + Sync (GPU): 12.246 ms - most of that time (I think around 70%) is spent synchronizing and reading the buffers.
    • Plugin CPU time: 0.004 ms - there's one plugin here, running on the GPU, so the only time measured is for passing a few variables to the shader
    • Overhead: 26.229 ms - pretty much all of this is ParticleSystem.SetParticles and ParticleSystem.Simulate.
    So the current bottleneck right now is with GPU->CPU transfer. We plan on eliminating that entirely with the geometry shader option.
     
    blueivy likes this.
  4. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Ahh this is great! I was just going to chek on this thread anyways because of a sudden surge of enthusiasm about water-stuff, and the gpu addition is good. I never really got to use my fluvio because of performance reasons, will there be a discount for version 2 owners?

    Additionally, is there any meshing/screen space surfacing etc included, and if not, how easy would it be to add a marching cubes or other such algorithmn to do this? I have a ton of literature on the subject, just not sure what would be the best approach for it with fluvio
     
  5. lilymontoute

    lilymontoute

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

    Fluvio 3 will be a free upgrade for version 2 owners, but the price will be increasing, and there may be a feature difference between Pro and Standard. I'll be announcing that *ahead* of time though, so make sure to keep up with this thread :)

    Screen-space rendering is included (the Fluid Effect from a few posts back - it's in 2.x but has been significantly upgraded). 3D mesh generation/marching cubes isn't. Unfortunately, research in 3D fluid rendering for particle-based fluids is ongoing and the majority of methods are not production ready just yet (they take too much time, especially when combined with simulation of high particle counts). I'm keeping a close eye on this though, and have tried a few different methods.
     
  6. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Perhaps adding the feature for meshing for off-line use and the results of a simulaton stored as a series of objs would be a really useful feature, most fluid sim software is pretty expensive and yet another program to learn and assets like megacache are developed for some very nifty obj heavy lifting to get prebaked meshed simulations running in unity, and this would allow for even higher complexity non-interactive simulations for situations where they can be generated then integrated back into the scene in very quick iterations, id certainly hugely appreciate this feature
     
  7. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    While this is a great idea, offline rendering isn't my focus right now. It's definitely already possible using Fluvio for simulation - fluid plugins work in the editor, so you could make an editor-only plugin that takes simulation data and bakes a set of meshes with vertex animation. You'd have to write the mesh generation code yourself (or use something that can generate meshes from particle/volumetric data), but you definitely have the freedom to use and store any output that you need.
     
  8. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Cheers for the heads up! I'll set my mind to that, esp when the gpu flavour shows up
     
  9. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    A quick development update:

    Fluvio now has OpenCL support!
    This adds hardware acceleration support for Windows (when DirectCompute isn't available), Mac and Linux. Mobile devices are theoretically possible, but some vendors block access to OpenCL so it's not officially supported.

    I've added a new FluvioComputeShader asset type that makes it very easy to support both DX11 and OpenCL with custom plugins. I've also added support for .cginc files. The OpenCL backend uses whatever is available (CUDA, AMD/Intel OpenCL drivers, CPU fallback) and I'll be adding support for preferred compute devices/blacklisted devices.

    I've also done a pass with lots and lots of bug fixes - this has been the main focus right now as we gear up for initial release.

    Still TODO before the first beta release - a 4.x version of the example scene and a 4.x version of the fluid effect. Almost there!
     
    Last edited: Feb 3, 2015
    lazygunn and overthere like this.
  10. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Some more development updates:
    • Bugfixes and optimizations for the GPU solver - I had noticed a regression that was causing it to run slower on some older machines - this has been fixed. Very excited about the latest numbers. On my GTX 770, 100k particles can be simulated in about 10 ms. Full frame time is still longer as they have to be read back to the CPU to use with Shuriken right now, but 20-50k particles is actually a realistic amount for a project.
    • OpenCL tweaks - OpenCL performance is now pretty much on par or faster than DirectCompute. So far I've tested with NVIDIA hardware on Windows, and AMD/Intel hardware on OS X, and all have had good performance so far.

    • Unified shader language for fluid plugins - Similar to other aspects of Unity, you can now write GPU plugins once and deploy them for both OpenCL and DirectCompute. Most of the platform specific stuff has been abstracted away using preprocessor macros.

    • Combined attractors and destructors into Fluid Effectors - Effectors are the same as attractors, with more options for controlling particle life when in the attraction area. They also support negative forces to repel particles, or zero force (old destructor behavior).
    I'll likely be releasing the first beta this week to Unity 5 customers. The Asset Store now allows multiple packages per Unity version, so if you're using Unity 5 it will show up as normal. Do note that the first beta will not have updated documentation and may be unstable in some areas.

    Finally, an important update on pricing and edition feature set:

    Fluvio's sale price will change with the 3.0 beta 1 release:
    • Fluvio Free Edition: Still free, of course
    • Fluvio Standard: $75
    • Fluvio Professional: $200
    A recap on the current feature list for Fluvio 3:
    • New multithreaded fluid solver, written from the ground up with much better performance all around
    • Hardware (GPU) accelerated fluids and hardware accelerated plugins
    • Physically based fluid effect
    • Live editing of systems in edit mode
    • Compatibility with most Shuriken features and all Shuriken curves
    • Support for multi-fluid simulation
    • Simplified API and better plugin system
    • Fluid Effectors, an updated Fluid Attractor
    • Support for up to 1,410,065,408 particles (this requires an exceptionally beefy CPU/GPU)
    • Dynamic simulation culling based on renderers
    • Much better local and world space simulation
    • Surface tension modeling
    • Boundary particles (kinematic and static fluids)
    • Tons of bugfixes and minor updates - the main goal of Fluvio 3 is to make it more artist-friendly
    Fluvio Standard features (also in Fluvio Professional):
    - Support for more than 500 particles per fluid
    - Support for more than 6 fluids per solver group
    - Fluid Effect, with physically-based rendering in Unity 5
    - Refractive particle shaders

    Fluvio Professional features:
    - Hardware acceleration (both DirectCompute and OpenCL)
    - Full C# source code included
    - Full compute shader source code included
     
    Last edited: Feb 13, 2015
  11. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Sounds exciting stuff, can you clarify the feature split? I read it as GPU acceleration only with professional? Or did you mean ability to use custom GPU compute shaders only with professional and fluvio standard can use the packaged compute shaders?
    Thanks
     
    Last edited: Feb 9, 2015
  12. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Sure thing. To clarify, GPU acceleration (as a whole) will only be available with Fluvio Professional. The main reason for this is that it requires me to ship the source code for the main solver (which has only been available in Fluvio Pro).
     
  13. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Ok thanks for that. So as I have fluvio 2 standard is their a way to upgrade to pro ahead of the price bump? Or are upgrades not possible?
    Thanks
     
  14. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    We can do upgrades under certain circumstances, through the form of granting a refund. For more information on the process and to see if you qualify, contact us directly here.

    Note that we don't provide upgrades for assets purchased during sales.

    EDIT: If you purchased Fluvio Standard in the recent sale (December 25, 2014), you may be eligible for an upgrade to Fluvio Professional. Contact us for more details.
     
    Last edited: Mar 6, 2015
  15. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Got it on sale by the looks of things so I'll see how I go with the standard one, nice to know there's a more capable option if I bump up on cpu limits :)
     
  16. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Updated the edition comparison above to clarify that hardware acceleration (anything using OpenCL or DirectCompute) is only available with Pro.

    Also, Free Edition is getting a bump to 500 particles per fluid, along with fluid effectors! We want you to be able to make awesome stuff even with just the Free Edition, and feel that 250 particles isn't enough with the new solver. Fluid effectors are a much improved version of the old attractors also, so it will be great to see those get more use.
     
  17. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    So, Fluvio 3 beta 1 has just been released for both 4.x and 5.0! Here are all the relevant links:

    Free Edition: http://u3d.as/2GH
    Standard: http://u3d.as/2Gi
    Pro: http://u3d.as/1Zf

    Release notes: https://support.thinksquirrel.com/hc/articles/204237230
    Edition comparison: https://support.thinksquirrel.com/hc/articles/202267604
    Known issues: https://support.thinksquirrel.com/hc/articles/204045684

    Very excited right now. This update has been in development over a year now, and is really what I envisioned making almost 4 years ago when I released Fluvio as Thinksquirrel's very first product on the (then very small) Asset Store.

    I hope you guys enjoy using it as much as I have been these past few months. Things have only just gotten started, there are plenty of beta updates to go (paint is still coming back!) and minor issues to fix before I label this as a full release.
     
    gurayg, blueivy and GibTreaty like this.
  18. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    300
    I know you are really into the simulation of fluid dynamics and optimization which is great but you should consider improving the look of the water. This is what put me off from buying during the sale. No disrespect intended. This asset sounds amazing otherwise.
     
  19. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Definitely - this is an active area of research that I've been looking at, and have improved upon quite a bit for Fluvio 3.

    Currently, Fluvio supports any particle shader, from the standard ones to any custom shader. Fluvio 3 extends this to support custom shaders for the fluid effect, and updates the default fluid effect to support Unity's new physically based rendering pipeline. Things like self shadowing are coming soon as well.

    Long-term, I've been looking into iso-surface and mesh generation for "true" 3D metaballs. In fact, I built a prototype of this a while back. Unfortunately, graphics hardware isn't quite up to the task of that yet for larger particle-based fluid simulations, without losing visual fidelity (most simulation demos with really nice renders are either grid-based, not running realtime, or running on exceptionally powerful systems). I think that will change soon enough though.
     
    Last edited: Feb 13, 2015
    blueivy likes this.
  20. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Unfortunately metaballs are crazy slow, i have worked with them but could not optimize to the point to be used for fluids (or to any point close to that).
     
  21. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Yep - I think a good solution would be dedicated hardware or hardware-assisted algorithms (within the graphics pipeline) for rendering scalar fields. Where the input would just be the position/radius of each object and the GPU would render the metaballs, then run a fragment program over the surface of them.
     
  22. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    What method is nvidia flex using? Their water rendering looks nice.
     
  23. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    For their liquids, they use point splatting methods, which is what we use for the Fluid Effect. The two big differences are:
    • Their normal/billboard calculation uses fluid surface normals. Right now we're calculating fluid surface normals, but we only use it for simulation (surface tension forces) at the moment. Our particle normals are either always facing the camera, or based on what Unity's particle system is set to (Normal direction property). As a result, our point splatting is in circles, whereas they use ellipsoids. The results in 2D are similar with circles, but ellipsoids are definitely better in 3D.
    • They do a subsurface scattering approximation - this is useful for some types of fluids and not needed on others, it depends. While nice, it's not super critical.
    • Foam effects are done by changing the color of a particle based on its density and surface normal. This is possible with Fluvio today (though it requires writing a small one-line plugin to do so).
    Their gas particles are rendered just the same as any other particle system, as either textures or texture sheet animation.

    These will eventually show up in Fluvio, but there's a big blocker on the first point. Controlling individual billboard rotations unfortunately isn't really possible with Shuriken right now. I have some ideas for a workaround though - I can probably bake rotations and color together as half-precision, then transform vertices in a shader (this would break all modules that change particle color though). That, or hopefully Unity will do some more work here.
     
    Last edited: Feb 14, 2015
  24. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    Thanks for the detailed response. I really appreciate all the work you put into this. Will definitely be picking this up :D
     
  25. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    No problem :)

    So, interesting thing - apparently there's an undocumented axisOfRotation property for particles that works with mesh emitters. It may be *much* more feasible to align particles to surface normals than I thought!

    EDIT: Wow, that turned out to be *way* easier than I thought! The next beta will have particle normals oriented to the surface contour.
     
    Last edited: Feb 14, 2015
  26. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'm really looking forwards to looking at this (im assuming my v2 standard becomes v3 standard?), sounds like an amazing number of improvements - in fact almost all the reasons i never really found a use for 2 have been addressed, or soon will be i upcoming updates. Might have to look at stumping up for pro, having had an option for gpu accelerated 2d and 3d navier stokes, and done a LOT of messing around with surface models (FFT spectrum (principally tessendorf), gerstner, perlin etc), having a strong SPH option would finally fill my ideal toolset for approaching one of my principle obsessions - water - Stumping for or doing the principle research for gpu accelerated water simulation has always proven worthwhile as the performance increase is tremendous.

    I'm taking it my suggestion of gpu delaunay-voronoi approaches may have bee naive (too slow perhaps, although i've read that a marching cubes style isosurface approach was much slower(unless im confusing documents)) but I think you may run into people asking for a meshing option a lot, it makes the fluid shading with a pixel shader far more intuitive and familiar i guess. Additionally, although the feature sets are rather different, even if the meshing happens offline, fluvio is consierably more afforable than anything like realflow, or naiad, or any professional fluid simulation of its type i can think of.

    Anyway, well done!
     
  27. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Yep, in fact the beta 1 update should be available for you in the store now. I've updated all 3 editions.

    Glad to hear - most of Fluvio 3's development goals have been fueled from customer feedback, so it's always appreciated.

    Delaunay triangulation of convex point sets (broken down from the concave fluid mesh) would definitely be faster than marching cubes, but still isn't quite fast enough for realtime use unfortunately. I think we'll eventually get to the point where things like this (and even marching cubes) are reasonable to do in realtime, but we've got a little ways to go still.

    Do you think you could go into a little more detail here regarding offline meshing? We likely aren't going to go the route of generating a mesh offline, but we could do something like a disk cache plugin that saves a fluid into a format for import into something like 3DS Max/Maya/Blender for rendering. You could then do the mesh generation there and import the frames back into Unity using MegaCache, or another similar plugin.

    Thanks!
     
  28. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I think a look at, or convo with, Spookycat or his work would be illuminating, i'm not entirely sure beyond Recap, which comes in Autodesk suites and will mesh, but im not sure how it deals with sequences, or there's Thinkbox's Frost meshing plugin for max which apparently meshes just about anything. As per Megafiers i think a safe bet for an export file format would be .pc2 point cache files, the spec is in here along with example maxscript http://www.maxplugins.de/r6_files/burnett/PointCache2_R6.zip

    I'm not sure of the workflow with this direction, the ideal would be, as you say, to export a sequence in pc2 format, mesh each frame and export back out in .obj format for a product like MegaCache. Turning that into a simple few-clicks-as-possible process eludes me atm.

    While as usual i've buried myself in projects again, one of my princple aims was to get the hang of the gDel3D and gReg3D GPU delaunay-voronoi triangulating algorithms as in the PM, so in the event i get the hang of those (would be a hell of a lot easier if unity would expose its CUDA internals i'd warrant) i could maybe have a go myself, who knows

    But yes I think an export to a pc2 file for outside meshing could do the job.

    Actually i just checked and found this http://gmv.cast.uark.edu/scanning/point-clouds-to-mesh-in-meshlab/

    Meshlab is free and very capable, perhaps exporting the particles as obj vertex data might work? if you can bake vertex colour vertex data too, it might be preserved on the way back in (or stored in a companion file for reapplication?), providing information for shaders like above mentioned velocity data for foam generation. Id be happy to try out information via the above mentioned routes via various meshing products that are available (first stop - meshlab) for you if you like, and produce a shader using the vertex colour information for stuff like foam (or anything else you can think that is relevant) as i think thats quite intriguing.
     
  29. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    So here's a comparison of 3 different point splatting methods. For this comparison, a pure white opaque, mostly rough fluid (0.1 smoothness and dark gray specular) is used.

    One other difference here is that the particles are being blurred (just rewrote the old blur effect to a precomputed gaussian blur - the fluid can be blurred now as well, not just the background). Also, I plan on adding self shadowing so that particles can cast shadows onto other particles.

    From bottom left to top right:

    1) "2D" normals, always facing the camera
    2) Unity default normals (billboards)
    3) Fluid surface normals



    Here's the reverse view. In this view, I consider 1) and 2) to actually be fairly inaccurate. 3 does a much better job of following the contour of the fluid.



    Finally, another angle (in the scene view). Note the much more consistent lighting throughout different angles.


    Let me know what you guys think.
     
  30. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    Its looking really good, self shadowing should really help. I wonder if there's a cheap way to do subsurface scattering on the fluids. Do you know of any?
     
  31. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    The Fluid surface normals one is approaching the quality of this video I saw a while ago
     
    lilymontoute likes this.
  32. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    A few tweaks to the blur method, and self shadowing + external shadows:



    Still need to tweak the particle normals a bit (it seems Unity's undocumented axisOfRotation is in a different space than the particle system itself).
     
    blueivy likes this.
  33. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    I think you could do with posting some videos or perhaps a web player as they would be better than still images to show off water simulation. Also I think you need to include some fluvio 3d examples in your beta for people to try especially as you haven't written the documentation for fluvio 3 yet.

    The performance of it on android appears surprisingly poor though. The 2d example you have for example doesn't run at a usable framerate on android for me but runs fine on desktop for me with or without hardware acceleration. Are you doing lots of garbage collection or something ?

    On the other end of the scale the gpu acceleration I am getting is far higher than the figures you are quoting. It's easily a factor of 10 times faster on gpu than cpu for me. Even my 2011 macbook pro can handle 50000 particles.

    How does it decide whether to use direct compute or opencl though. It still lists opencl on my pc in the debugger when I assumed it would use direct compute there ?

    Is there no way you can precompile the compute shader so you don't need to give the source code for it in the standard version or perhaps obfusicate the code for it ? It would be a shame to limit fluvio's performance just because you need to protect the source code.

    Based on my playing with it gpu acceleration is clearly the way to go. I also like how easy it is to plug into shrunken. It also seems to work pretty well with particle dynamic magic so you can make water splines and things or pass turbulence through the water.
     
    nasos_333 likes this.
  34. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    What would be cool would be if the particles had a lifetime, sort of how these devs did it. http://www.mediocre.se/

    " Either there needed to be a finite amount of fluid, or the simulation would run slower and slower. None of them seemed very appealing, and we struggled hard to create fun levels with only 600 particles. To put that in perspective – 600 particles is equivalent to spraying for about four seconds. Being that restrictive with water simply wasn’t any fun!

    To work around the problem we put a lifetime on each water particle, and simply removed it when time ran out, then it could be recycled and sprayed out again. This gave the illusion of an unlimited amount of fluid, while in fact only allowing four seconds of water on screen at the same time. If you look carefully in the game you’ll see that the fluid doesn’t pool up forever, but dissolves over time as if absorbed by the ground. "

    EDIT: Also in your last picture, its looking great! Is that the smallest the particles are able to go?
     
  35. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Working on both of these :)

    There's a (very minimal) amount of GC generated each frame (the lockfree queue used for multithreaded operations requires it unfortunately) but it's on the level of a few bytes. Absolutely no per-frame garbage is generated by the solver itself. However, a lot of it is just the speed of the C# solver compared to OpenCL and DirectCompute. Even OpenCL CPU is a lot faster due to the ability to take advantage of SIMD. I'm looking into writing the solver in portable C and shipping a native solver with iOS/Android in the future (and on the desktop for Unity Pro users, so that the fallback is still native code instead of C#).

    Awesome! Check out Edit > Project Settings > Fluvio to change a bunch of global Fluvio settings. You can choose between DirectCompute and OpenCL, choose between CPU and GPU acceleration, as well as blacklist certain OpenCL platforms or drivers if they're buggy. I've found OpenCL to be faster even on my Windows machine, so have kept it on by default. Once we start using geometry shaders DirectCompute will be the default.

    I've been looking into this - Precompiling isn't an option as it requires the hardware (or at least is vendor specific). However I could possibly obfuscate and minify the code.

    Neat! Feel free to post any cool effects - would love to see what people are doing with Fluvio.
     
  36. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Regarding lifetime: setting particle lifetime in Shuriken does exactly that :) Particles can also be decayed by using fluid effectors, or a combination of Shuriken collision + collision decay. If you're looking for something like that quote, set emission to 150 (600 particles in 4 seconds) and start lifetime to 4 and you'll get an endless stream of particles as long as you have 600 or more max particles.

    Regarding particle size: both particle size and smoothing distance (physical size of the smoothing kernel) can be changed, without any limit (there's some limits on the really small and really large end due to numerical issues though).
     
    Last edited: Feb 15, 2015
    blueivy likes this.
  37. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    An additional note about Android - technically OpenCL can work there. I've disabled it as A) The underlying library doesn't support it yet (working on it) and B) when I hacked support into it, I got a crash as soon as I tried creating a context. Also, not all Android devices support OpenCL (in fact, Google blocks it on many devices).
     
  38. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    Thanks for the response. Is it possible to have the particles cast AO on the environment and also to each other? Also why are the particles being blurred?
    I noticed in this image it makes the pool of fluid under the ball look gaseous.
     
  39. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    AO on the environment would be possible, but a bit tricky and very performance heavy.

    The blur is also still being worked on. It's done to remove self-shadowing artifacts and hard edges due to how the ellipsoid splatting works - but it's a bit too aggressive right now and there's a bug causing some ghosting you can see along the shadow lines. I think the blur could probably be smarter also, and take advantage of the curvature of the fluid.

    Here's a (scene view) comparison photo with and without blur. I've also shrunk the particles somewhat from the example above, as they were a bit large due to another bug that got fixed last night.

    Without blur:


    With blur:
     
    blueivy likes this.
  40. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    I love the particle size in that. Good to hear your thoughts on the blur! I definitely see why it's there :D
     
  41. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Edit: Beta 2 is out! The paint example (and the fluid effect) requires Unity 5.0.0 RC2 or higher.

    I've updated this scene somewhat (it will appear in the next beta for Unity 5 users as a Paint example). Here's a preview:





    I've switched back to billboards for now for the default fluid effect. Unity has some issues with particle sorting that makes surface normal oriented particles flicker too much in 3D. Ideally, I need to be able to send custom data to the shader in order to properly use this technique, but unfortunately Unity doesn't support that at this time. However, I've changed the water in the 2D example to use the new method as the technique works well in 2D.

    To try out normal oriented particles (once beta 2 is released), just switch to emitting mesh particles, with Unity's quad primitive. Particle rotation may need to be re-oriented depending on if the system is emitting in world or local space, or your current camera angle (again, due to Shuriken limitations).

    Still TODO: Replacing the gaussian blur with a depth-bias gaussian blur, so that overlapping particles don't blend together as much.

    On a better note, self shadowing actually contributes more to the realism than I've realized! Here's a comparison:

    Without self shadows:


    With self shadows:
     
    Last edited: Feb 18, 2015
    RagingJacob, blueivy and gurayg like this.
  42. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Is the paint example above GPU based ?
     
  43. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Yep - GPU accelerated, 6000 particles. This particular example is using Shuriken collision right now though (which is CPU based).

    All fluids can be GPU accelerated (and are by default with Pro). That setting can even be changed at runtime, while a fluid is simulating, without resetting it.
     
  44. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Very nice, i suppose the GPU based is rather fast. Look very cool :)

    Will something like that make sense to use in the other versions, without acceleration ?

    My plan is to use the free version and get the Pro one when i can. Is it possible to extend the free version effects using the Pro later ? So i can prototype and then use the extended one for the cool effects and numbers.

    From what i gather this uses Shuriken, so it is an amazing idea to use with PDM indeed, i had not though about it :)

    Will the system be Shuriken compatible in the final version as well ? That would be so great, it opens up a whole new world of possibilities.
     
    Last edited: Feb 18, 2015
  45. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Thanks!

    It still makes sense, just with a much reduced particle count of course. It would be tricky to cover a whole object, but it could be combined with traditional particle effects.

    I haven't tested upgrading from Free to other versions. It should work just fine though, and edition upgrading was supported in 2.x. Worst case scenario would be that you'd need to enable text serialization and change a GUID before upgrade. I'll put this on the list of things to double check before we're out of beta.

    As far as limitations, some of the components are just not present in Free (fluid effect, custom shaders), but the serialized data is the same.

    Yep! Some examples using other particle system assets are coming soon.
     
  46. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Great, thanks for the info
     
  47. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    No problem. Also, feel free to post or let me know about any neat combination of Fluvio and Particle Dynamic Magic that you make! We're always on the lookout for cool projects using Fluvio.
     
  48. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Sure will do. At the right moment i will also post pics from using the system in my RPG game, it already looks really cool, with Fluvio 2.0 free. I imagine Fluvio 3.0 will make it even more spectacular and the integration with Particle Dynamic Magic and spells that will combine them will top it off later :)

    I am flooding with ideas, especially for intractive environmental spells.
     
  49. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    630
    This gif shows what I noticed more prominently but the other ones have them. What's wrong with the background behind the falling particles?

     
  50. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    That's actually just an artifact of the GIF capture software I'm using (Screen To Gif). Not sure what it is myself! I've also noticed issues capturing video from Unity in general when using deferred rendering, so it could be related.
     
    blueivy likes this.