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

MegaFlow - Vector Fields & Fluid Flows [Released]

Discussion in 'Assets and Asset Store' started by SpookyCat, Nov 3, 2014.

  1. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    That should be no problem, the video below shows something similiar just needs the same geometry to be the same in fluids simulation that generates the vector field, be it Maya or Fume FX. And no problems with particles entering the flow.
     
    bbaugh007 likes this.
  2. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    Thanks!
     
  3. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    Do you have an example recreating that example with particles? I am still having issues creating something that reacts to geometry in that way.
     
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    I created that scene many years and a couple of PC's ago, think it is long gone. It was just a simple simulation setup in FumeFX with the objects as seen in the video as obstacles for the fluid simulation so the resulting vector field when imported into Uinty would result in particles flowing around the objects nicely.
     
  5. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    I see, is it possible to create a spline so that half of the particles coming from a single emitter flow in one direction(to the left) while the other half flows in the other direction (to the right?). Somewhat like the airplane example but using one emitter?
     
  6. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    Yes, just create two splines probably parralell to one another one that goes one way and the other one the other. Then depending on which grid cube the particle is in at the split point will control where it goes, you may need to reduce the size of the grid elements to get better results. One thing to note is there will no noise in a vector field created from a couple of splines compared to a solution created from a fluid dyanmics simulation, so you will get much better results if you created your scene with simple proxy meshes in say Maya and did a full fluid dynamics simulation, that way you will get the turbelence and eddies that go a long way to getting a nice looking result. You can do it with splines in MegaFlow but will need to use a few more than two splines.
     
  7. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi,

    Have you given any thought to making this compatible with DOTS down the track? It would be an excellent candidate for the sort of performance benefits I've been seeing elsewhere.

    If not, it shouldn't be too tricky for me to port the elements of the asset I need for my use case, which would simply be to sample a point from within an IJobChunk.
     
  8. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    The asset supports its own custom multiple threaded systems as it stands so would not see much more if any imrpovement using the DOTS system.
     
    Karearea likes this.
  9. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Fair enough. I'm committed to a pure ECS approach for the rest of my game, which means I'd prefer to sample from within an IJobChunk to keep everything consistent. After looking around the code I'm fairly confident I can create a simple entity-based equivalent working using the new math library, structs and BlobAssetReferences. I'll report back..
     
  10. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    Will be very interesting to see if you get any speedups.
     
  11. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi, I have a first pass running with DOTS, and it's very fast!

    Use case:
    • Flight sim utilising blade-element theory. Each aircraft has ~80 subsections to calculate lift / induced drag etc.
    • 192 aircraft in the scene, so 15360 subsections in the scene total.
    • Vector fields represent wind / thermals around landforms.
    • The system that runs the blade element simulation samples for every section, every frame.
    On my 4 year old MacBook Pro with a 2.7 GHz Quad-Core Intel Core i7, the blade element simulation system takes about 0.22m/s per frame, according to the entity debugger. Doubling the sample count brings it up to 0.24m/s or so. Bear in mind this also includes the full wing simulation. Even going nuts with aircraft count doesn't seem to flumox it, I'm hitting GPU limits long before the simulation gets too out of hand.

    Implementation:
    • Modified the MegaFlow FGA importer, to create a monobehaviour with float3[] I can reference in an authoring component. This is constructed into a BlobAssetReference for a BlobArray<float3> on conversion.
    • Implemented a dynamic buffer on the aircraft to reference entities containing a vector field, this is added to via trigger and checks a threshold to remove them when out of bounds. The sim iterates through these for a final combined vector.
    • Modified the ReadVelocity method as a static float3 that accepts a ref BlobArray<float3>
    I'm assuming single frames so have simplified a lot here, and haven't yet looked too hard at moving fields. I do like the idea of flying through wake turbulence so I'll need to think of a DOTS friendly way of generating that. Let me know if you'd like me to PM the scripts to you.
     

    Attached Files:

  12. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    Wow you have been busy, results sound great. Would love to see any code you have when you are ready. Clever use of the system as well, how noticeable is the difference in flying with and without MegaFlows input?
     
  13. TonismoGames

    TonismoGames

    Joined:
    Jun 12, 2018
    Posts:
    111
    I am interested in buying this asset. I only have one question.Does it measure air drag and downforce?
     
  14. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    Hi There. MegaFlow is a vector field system that uses the results of fluid simulations in packages such as Maya, Blender or FumeFX etc. Those are then used to control particles or objects. You can also build vector fields inside Unity using the included spline system but it is not a Fluid Dynamics solver so it will not for example compute the coef of drag for a car or compute the downforce from wings.
     
  15. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    166
    Hello @SpookyCat Are there any good tutorials that you know about for setting up a vector field in Blender? Are there any size limitations that I should be aware of before buying this asset? eg if i wanted to set up a vector field for 1 square mile is that something that is possible? I've been reading up on it and is it possible to be able to import multiple frames of the vector field so that you could have turbulent flow in your scene? I am wanting to have wind and have it blow some leaves around. if it's a static vector field i feel there will be standing waves appearing in the leaves, where as if you had multiple frames of vector field it would ebb and flow and the leaves would move naturally.
     
  16. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    There are a few videos on Youtube on creating Vector Fields in Blender, for example:

    The size can be anything you like the only limiting factor will be memory use, you can easily have a Vector Field several miles along each side but you will have to choose a cell size that will not mean too much memory is used. So if you wanted a cell size of 1m with a Vector field 1km x 1km and 10m high that would take 114MB of ram, depending on your project that might be acceptable or not. In such a scenario you would likely split the Vector Field up in to smaller sections and only use them where you need them, as with everything in GameDev its a trade off between memory and compromise.
    MegaFlow does allow multiple frames to be in a source and you can easily change the frame used at anytime to change the particle movement, a simple script to change the frame index over time is all thats needed.
     
  17. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    As a side note if you just want to have leaves blowing in the wind the Unity particle system can do that without an extra help.
     
  18. Papok

    Papok

    Joined:
    May 28, 2013
    Posts:
    6
    Hi!
    I'm trying to generate vector field in Cinema 4D + X-particles and it exports the .fga file, but after importing to MegaFlow it works completely different than in the app - as it would have differen axis and dimensions of the grid (screenshots included).
    I tried chaning the axis in MegaFlow but it changes everything.
    Can you help?
     

    Attached Files:

  19. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    Sorry I didn't get a notice for your post. Just rotated the MegaFlow object so it matches what you need?
     
  20. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,748
    A quick update to make MegaFlow fully compatible with Unity 2022.

    Changes in v1.43
    • MegaFlow made full compatible with Unity 2022
     
  21. unitysldeveloper

    unitysldeveloper

    Joined:
    Feb 1, 2021
    Posts:
    4


    can you give me this samples i have megaflow 1.42