Search Unity

Cocuy - Fluid Simulation for Unity

Discussion in 'Assets and Asset Store' started by Musiu-Bar, Apr 6, 2015.

  1. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Hi Pablo,
    Could you send me the information about your environment to our support email [info (at) musiubar.com]? Send your Unity version, Cocuy version, etc. Also if you select the AdvectVelocity.compute file in the "Project" tab in Unity it should give you more information about what the error is.
    Thanks!
     
  2. chdrvn

    chdrvn

    Joined:
    Dec 4, 2013
    Posts:
    23
    Looks amazing man, seems way better for simulating smoke and fire than traditional particles. Also stylishly trippy as hell. Definitely will buy when its available for use outside of Dx11
     
  3. Zumx

    Zumx

    Joined:
    May 12, 2014
    Posts:
    5
    This would indeed be fantastic if multiplatform. Good luck :)
     
  4. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Even if the author doesn't redo the system to use a different method, compute shaders are going to start to work on more platforms going forwards, as Unity are busily redoing their openGL system.

    Indeed the recent unity blog post highlighting the fist step on this path, highlights Cocuy specifically as an asset that already works with this new Unity 5.1 feature:

    http://blogs.unity3d.com/2015/05/26/dx11-features-on-mobile/

    A for me I don't own Cocuy yet but am about to buy it now. I'm a big fan of these simulations and have purchased both 2D and 3D ones from the asset store in the past, as well as converted a 2D CPU-based Java one to C# & most recently rewrote a 3D one to drive the velocity of particles. So I am looking forward to seeing how this one performs!
     
  5. prakash7titus

    prakash7titus

    Joined:
    May 29, 2015
    Posts:
    9
    It is an awesome asset . I was going to buy it now but i came across this forum then and got disappointed that it is still not ready for mobile platform . Need it for android . Thinking of using it for waterfall and similar stuffs for a 2D game . Please let me know when it is updated with mobile support . Looking forward to use it.
     
  6. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    This asset is amazing! I've been fiddling around with it, and I was wondering if you have any plans of making it possible to define blockers, particles and velocities with Rects instead of with a radius? It would be great to at least have this for blockers.
     
  7. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    Nevermind, we figured it out ;)
     
  8. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16


    Created with an extended version of Cocuy :) I added support for PolygonCollider2D as obstacle.
     
  9. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    @ZyntharNOR Neat thats what I was hoping would be added too, can you share the code change? Or is this going to be in the main asset @Musiu Bar ?
     
  10. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    456
    Quick question - is it possible to have more than one "gas" type with this plugin? All the demos I've seen only have one emission type.
     
  11. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Don't think so at the minute, though you can certainly have multiple simulations running, although they'll give odd effects if the particle areas overlap.
     
  12. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    456
    Cool, thanks.
     
  13. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    I'm not comfortable doing so, as that would mean sharing parts of the Cocuy source code. I figure it will most likely be added to the asset if enough people request it, as it wasn't that difficult to do.
     
    overthere likes this.
  14. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    Sure thanks for replying, I assumed it was just a change/addition to a few lines and hence not usable unless you had the rest of the source from buying the asset. For anyone else interested I've emailed the author to ask when this will be in the asset proper.
     
  15. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    After playing with it for a few days my main comment ends up relating to the most recent topic on this thread.

    It's not really difficult to find other implementations of these type of fluid simulations, including unity ones. The value that paid assets can add comes down to optimised performance, compatibility, rendered results and how well integrated with other bits of unity they are. I've not done enough testing to comment properly on performance or visual quality yet, although I suspect that some further performance optimisations are well possible. Compatibility is one of my favourite subjects but I can already be found boring on about next Unity generation of OpenGL & Compute Shaders in various places on the forum so I wont repeat that detail right now.

    So that leaves me with the integration. Top marks for making useful demos, and a system that isnt intimidating to plunge into. But more emission & collision shape options are required for me to give Cocuy absolute top marks overall.
     
  16. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Hey All!

    Sorry I've been away for the last few days, it's been very busy over here! To give you all a bit more updates I managed to get Cocuy running using Render Targets although as you saw in the post @elbows shared above Compute Shader support is coming to more platforms in Unity. I'd still like to get that version working as can be used in more platforms.

    @ZyntharNOR that looks amazing! So good that you managed to extend the system. Was it hard to understand where to make the change? I have it in my todo list to extend the collision shapes but haven't finished it yet but will be doing it soonish :)

    @elbows thanks for your comments. I see Cocuy as a product that will evolve over time based on feedback from the users (@overthere has kept me busy with a few good ideas) so please drop me an email to see if there's anything that you think can be improved. I will definitely look into it :)

    Thanks all again for the suggestions and if you've made anything with Cocuy please share it here! Want to see the use cases you've been giving the asset.
     
    ZyntharNOR, Trollpants and overthere like this.
  17. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    91
    Especially for us poor unfortunate souls with projects still stuck on 4.6 for the time being...

    So: Soon? That's great news!
     
  18. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    Not really, just had to read up on compute shaders, as I've never used them before :)

    I'm currently having some trouble getting it to flow correctly when turning down Time.timeScale. The problem seems to be that the particle life isn't effected.

    Edit: Best solution I could come up with was to set "_Dissipation" to "Mathf.Clamp01(m_densityDissipation / Time.timeScale)". Not perfect, but for now it's good enough.
    Edit 2: Wasn't that happy with my previous solution. So instead I replaced the last line of AdvectParticles.compute with this:
    Code (CSharp):
    1. if(_Dissipation < 0.2)
    2. {
    3.      _Dissipation = 0.2;
    4. }
    5. _ParticlesOut[particle_pos] = clamp(lerp(h2, h1, delta.y) - (_ElapsedTime / _Dissipation * 255.0), 0.0, 255.0);
    The "_Dissipation" float is now how many seconds it should take for each particle to dissipate. Also edited ParticleAreaEditor.cs to allow for a particle life range of 0.2f to 600f.
     
    Last edited: Jun 7, 2015
  19. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    @Musiu Bar there is a bug in ParticleArea.cs, the line that says
    Code (CSharp):
    1. m_advectParticles.Dispatch(0, m_nNumGroupsX, m_nNumGroupsX, 1);
    should say
    Code (CSharp):
    1. m_advectParticles.Dispatch(0, m_nNumGroupsX, m_nNumGroupsY, 1);
    This is currently preventing portrait shaped particle areas (where the area is taller than it is wide) from functioning correctly.
     
    Xorxor and overthere like this.
  20. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    @ZyntharNOR Thanks for that, fixes one of the bug reports I'd made :)
     
    ZyntharNOR and Trollpants like this.
  21. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    @ZyntharNOR wow, thanks for those fixes! I'll integrate them :)

    Since there's been some interest for an update I'll try to upload an update with a few fixes and improvements this week. Nothing too major but more of an stabilization release. I'll keep you all updated.
     
    ZyntharNOR likes this.
  22. Xorxor

    Xorxor

    Joined:
    Oct 15, 2014
    Posts:
    24
    Please add independent options to wrap the boundaries of the simulation. This way the fluid and forces could wrap around if desired. And yes. Desired :D
     
    Musiu-Bar likes this.
  23. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    Made a compute shader for adding smoke based on an image :D
     
    Musiu-Bar likes this.
  24. overthere

    overthere

    Joined:
    Jun 28, 2013
    Posts:
    110
    @ZynthaNOR Well now you are just showing off! :p
     
    Manny Calavera and ZyntharNOR like this.
  25. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Hi,

    In all demo scenes I noticed a CPU spike every 30 frames or so. Those frames take 40-50 ms which is excessive and will be noticeable in a game with other things going on. Is there something wrong in my setup or is this baseline?

    Cocuy-Profiler.png

    EDIT: Removed irrelevant screenshots about demo scenes.
     
    Last edited: Jun 12, 2015
  26. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    After playing with it some more I have additional questions/comments.

    - Please, add comments to the scripts and the compute shaders.

    - The Prefab has both a Mesh Collider and a child object with a Collider2D. What exactly each of them is used for?

    - How (and where in the code) is the simulation space calculated? Would it be possible to define an area other than a rectangle? For instance, a circle or even an irregular polygon?

    - Would it be possible to define a moving simulation space? For instance, by parenting the rectangular area as a child of the camera so the simulation window would keep moving with the player?

    - Would it be possible to define a pool of particles that do not decay until disturbed by a manipulator?

    Cheers!
     
  27. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Ok, I'll have a look at this when I get some time :)
    I'll go through it and add some more documentation there. Any area in particular you're interested in?
    The Collider is used by the manipulators. they raycast to find where to add particles/velocity. The Collider2D is actually just used in the demo with the small ship, it shouldn't be in the prefab, it will be gone in the next update.
    The simulation space is the entire area of the plane mesh (which is simulated in FluidSimulator.cs), on top of it you add a "ParticleArea" (ParticleArea.cs) which is the area where you can see particles being moved by the simulation. At the moment you can only have rectangle areas, but using blockers you can make it look as if it had a different shape.
    Yeah, you can move the plane about no problem, it's just another GameObject in the end. But obviously this won't have any effect on the simulation, it will still be simulating as if it was static. Do you have an specific usage in mind to better understand what you're trying to do?
    You could set the particle life to the max and then change when you "touch" the fluid the first time by code (the Dissipation value in the ParticlesArea.cs).
     
    ZyntharNOR likes this.
  28. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Yeah, that's an issue. That GetData() function is used to transfer the data from the GPU back to the CPU to be able to use the FluidFollower component. I have a couple of ideas that might help but haven't gotten around to implement yet. One thing I'll be doing is to make that function optional so it's only called if you need the velocity data back in the CPU.
     
    ZyntharNOR likes this.
  29. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Yes, the compute shaders and the part where you calculate the edges of the simulation area, I mean, where the fluid bounces back off the edge of the area. That's probably where I would want to change to make the area look like different shapes.

    I had the impression that only circular blockers were currently supported. Are you suggesting adding a bunch of tiny circular blockers (with AddObstacle()) to delimit the area I want?

    Yes, for instance a side-scrolling platformer where the character can walk back and forth on the level. Having a huge static simulation area covering the whole level will be a huge overhead. It would probably be better to have a dynamic simulation area that follows the camera (perhaps 5% wider) and that particles leaving the simulation area would be discarded or faded and no longer calculated.

    Yes, definitely start with that as most use cases will benefit from this change. But looking forward to optimizations on the Follower case as well.
    Note: I just commented GetData() and it makes the whole simulation much, much faster.
    After that, a couple of other minor spikes show up. For instance:
    - Does the m_colourRamp in ParticlesArea.cs need to be recalculated every frame? I cached it and the CPU spike went away. I didn't notice any side effects at first glance.
    - There seems to be a GC alloc of 96B coming from ParticleAreaManipulator::LateUpdate().
    - There seems to be a GC alloc of 144B coming from VelocityManipulator::LateUpdate()

    Also, the "Input.GetKeyUp(KeyCode.C)" in ParticlesArea.cs should probably be moved to demo code.

    Keep it up. Looking forward to getting passed these things so I can use Cocuy in my game.

    Cheers!
     
    ZyntharNOR likes this.
  30. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Look into the AddObstacles.compute instead, in there you can block off different areas of the simulation. You can modify it to suit your needs like @ZyntharNOR did a few posts above. I will also be releasing very soon the next update which includes support for different blocking shapes.

    You'd have to tinker a bit with the code, but you could definitely do something like that. If you can calculate the offset of the camera in simulation space you can create another compute shader to shift the particles + velocities by the same amount.

    Thanks! I've already fixed a few of those issues for the next update and will look into the others more in depth.

    Thanks @Manny Calavera in general for the feedback, keep it coming :)
     
  31. TheSePo

    TheSePo

    Joined:
    May 20, 2015
    Posts:
    3
    Will the iOS version be Metal only or will it work with older devices?
     
  32. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Hey All,

    I've just submitted an update to the asset, if approved should be out at some point next week. It is mostly bug fixes and optimizations, but also added support for using PolygonCollider2D as a blocker for the fluid which works quite nicely. I'll let you all know when it's out :)
     
    elbows, overthere and Manny Calavera like this.
  33. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58

    Cocuy 1.2 has been released!


    Changes:
    • Support for blocking the fluid using a PolygonCollider2D (convex shapes only, for now)
    • Access to particle data in the CPU
    • Bug fixes and optimizations


    As usual, let me know if you guys have any issues or suggestions.
     
    overthere likes this.
  34. yeagob

    yeagob

    Joined:
    Jan 27, 2014
    Posts:
    18
    We are really interested in iOS and Android version, where you think it will be ready???

    Thanks!!
     
  35. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Hi yeagob,
    Definitely still working on that version! It's just taking some time :( ... You'll be the first to hear when it's done here in the forums :)
     
  36. pixelballoon

    pixelballoon

    Joined:
    Mar 5, 2013
    Posts:
    11
    Hi,

    Firstly, fantastic asset, really enjoying playing around with it.

    I know in future Unity updates the Unified GL framework is going to be brought in to support Compute Shaders on misc platforms, but looking at the roadmap that isn't going to include OSX for quite some time.

    I'm personally not bothered about iOS/Mobile support in general, but fairly comprehensive desktop support is pretty important to me (primarily as I do quite a bit of development on OSX when I'm out of my office). Are there any roadmap/timelines/betas for alternative ways to support OSX, such as the render texture support you mentioned a few months ago?

    Thanks!
     
  37. Fadoool

    Fadoool

    Joined:
    Aug 29, 2015
    Posts:
    1
    Hi,
    I'm just wonder if this was application or Plugins for a specific editing softwares , like final cut pro or after effect?!

    Thank you.
     
  38. Ravanok7

    Ravanok7

    Joined:
    Jul 7, 2013
    Posts:
    8
    When is it going to be on sale!
     
  39. Free286

    Free286

    Joined:
    Oct 29, 2013
    Posts:
    23
    Looks like a great asset, purchased this but unfortunately can't use on OS X - planning to export to iOS devices, wondering if a fallback CPU mode or render texture mode is in the works? Thanks, great work!
     
  40. gabish

    gabish

    Joined:
    Jan 14, 2013
    Posts:
    1
    Hi, i purchased your package and it's looking really good.
    I'd like to use it to create a nice visual effect when dragging with the mouse and i want to get through all the colors from a HSV circle as i'm dragging, like in the attached image. Also i would like to generate some white small particles like sparks that should also blend with the rest of the colors. Can this be done? Can you please tell me how to make those work with your package?
    Thanks a lot! img.jpg
     
  41. tomtominc

    tomtominc

    Joined:
    Nov 7, 2013
    Posts:
    22
    Hi Musiu Bar,

    This looks like an amazing asset for our game that's in development we really wanted something like this, unfortunately we want to target as many platforms as we possibly can, I'm not interested in mobile but I work in OSX and we want to target mac, is there any future updates planned to create this effect with Open gl? or even some fallback support like render textures?

    Thanks Tom
     
  42. smileroy

    smileroy

    Joined:
    Nov 8, 2015
    Posts:
    1
    Hi Musiu Bar

    I have bought your plugin.
    I waited for 5 months, when can support IOS/Android platform?
     
  43. Musiu-Bar

    Musiu-Bar

    Joined:
    Apr 6, 2015
    Posts:
    58
    Hi All,

    Thanks for all your messages. Unfortunately, due to personal reasons the render target version has been delayed several times. It's hard to give you an ETA as our time has been considerably reduced but we are still working on it as much as we can. I'm very sorry to the people that have been waiting on it.

    As usual I will post here any updates or improvements that we make. Also, if you have any other questions continue posting or emailing us at [info (at) musiubar.com].
     
  44. djedjex

    djedjex

    Joined:
    Aug 9, 2015
    Posts:
    3
    HI,
    Its is possible to have more than 1 cocuy fluid color who interact with other
    exemple : in demo "mouse scene" can we have 2 suns colors ?
    Ty
     
  45. tomtominc

    tomtominc

    Joined:
    Nov 7, 2013
    Posts:
    22
    Any updates? wanting it for OSX
     
  46. hnphan

    hnphan

    Joined:
    Nov 5, 2014
    Posts:
    7
    Hi,

    I bought it and I was wondering if it would work on consoles since it uses DX11?
     
  47. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    Does it work on Mac and Linux now that Unity 5.3 is out?
     
  48. deadratmarionette

    deadratmarionette

    Joined:
    Nov 25, 2013
    Posts:
    1
    Hi,

    Can you estimate the date when the asset will be released for mobile platforms? Maybe windows phone?
     
  49. Lombric

    Lombric

    Joined:
    Jan 14, 2016
    Posts:
    1
    Exactly the thing I'd like to know? Did you, per chance, get any answer?
     
  50. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    Here's some new info on OpenGL Compute Shaders http://docs.unity3d.com/Manual/OpenGLCoreDetails.html

    But it says: However, as Apple restricts the OpenGL version on OS X desktop to 4.1 at most, it does not support all DirectX 11 features (such as Unordered Access Views or Compute Shaders).

    Does that mean that Cocuy won't work on OSX?
     
    GameJob2017 likes this.