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

Multithreaded physical computations (WIP)

Discussion in 'Made With Unity' started by Neodrop, Oct 16, 2011.

?

Is it interesting ?

  1. Yes, I need it!

    97.1%
  2. No, we have no-multithreaded Physics already

    2.9%
  1. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Last edited: Oct 17, 2011
    AntonioModer likes this.
  2. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Builtin phisics (1000 rigidbodies more than 10 millisecs per second +picks) :

    $normalPhysics.jpg

    Separate phisics (1000 rigidbodies less 1 millisecs per second + no any picks) :

    $separatePhysics.jpg
     
    Last edited: Oct 16, 2011
  3. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Check my sig, you bet I'm interested! :)
     
  4. sebako

    sebako

    Joined:
    Jun 27, 2009
    Posts:
    301
    giiieve!
     
  5. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Updated! Now about +50% faster.
     
  6. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Oh stop teasing us and release the thing! ;)
     
  7. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    It's just a first stage yet. Unfinished product. Just WIP
     
  8. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    The updated webplayer isn't working. The old webplayer showed the rigidbodies interacting, this new webplayer just instantiates boxes but I don't see any physics activity.
     
  9. Lionhunter

    Lionhunter

    Joined:
    Aug 11, 2011
    Posts:
    9
    Are you using an open source physics library, like Bullet Physics?
     
  10. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    I can't open my sources yet.
    Player reloaded.
     
    Last edited: Oct 16, 2011
  11. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Works now. Runs very nicely on my old MacBook Pro (Core Duo 2 2.1 ghz / x1600 graphics). Bet it would run like greased lightning on a i5 or i7! :)
     
  12. Lionhunter

    Lionhunter

    Joined:
    Aug 11, 2011
    Posts:
    9
    Considering that this ain't an unmanaged plugin, my interest level is high :p
     
  13. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    How do you build such a thing ? any pointers where to start?
     
  14. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    As you can see, nobody do it for Unity already. It's a long way.
    But, in short words you need :
    1. Find or write a stable, fully dotnet created physics engine.
    2. Study it a bit (if you don't wrote it yourself).
    3. Make a set of the Unity Components to integrate it together.
    4. Find a bugs with threads
    5. Find a bugs again with threads and Unity crashes
    6. Find a bugs again-again-again everywhere.
    7. Optimize (8-9-10 and find a bugs again)

    Something like this ;)
    Sorry, if it's not a clerly description. I can answer more precisely to a more precise questions.
     
  15. Deleted User

    Deleted User

    Guest

    Very interesting!

    Run very well on my iMac with Ati 4670
     
  16. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    Interesting! Neodrop, you are a machine! :D
     
  17. CodeCody

    CodeCody

    Joined:
    Apr 27, 2010
    Posts:
    440
    Confirmed for i7!

    Edit;
    Vary nice Neodrop! Who would not want it? It is like some kind of ultra fast physics from the future!
     
  18. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Fascinating o_O
     
  19. psyclone

    psyclone

    Joined:
    Nov 17, 2009
    Posts:
    245
    Will this be part of Universe, or a separate purchase?
     
  20. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    I'm not sure yet. If will be as a part - only for a paid version.
    But, in any cases, it's will work in Universe and will have a set of nodes for Universe.
     
  21. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Personally I'd prefer it be a separate product that works with Unity. I really don't want to have to learn (or buy) a visual coding system just to get better physics performance.
     
  22. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    In any case (as QRCode plugin) it will be as separate product.
    But may by, it also will be internaly included inside Universe.

    I do not want to catch the new souls in Universe across their desires ;)
    It's not my goal.
     
    Last edited: Oct 16, 2011
  23. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    Hey could you put up another demo, which spawns more rigidbodies, maybe unless you press a key for example? That would be really cool to check, how far your system could go. Anyways, nice work. Runs flawless for me.
     
  24. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Yes, I will. In next 1-2 hours (I need to finish some home works before)
    But too many active objects in one local hip - it's not so good for productivity. ;)
     
    Last edited: Oct 16, 2011
  25. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
  26. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    amazing stuff
     
  27. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Last edited: Oct 17, 2011
  28. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Very impressive. I pushed it to 2,000 rigidbodies and still got 60+ fps on my Intel Core Duo 2.
     
  29. diddykonga

    diddykonga

    Joined:
    Jun 9, 2011
    Posts:
    151
    I pushed it to 5,002 and got a physics time of 188 - 200 and an fps of 30-35 on my AMD Quad Core
     
  30. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Wait for all cubes becomes blue. It's not so fast yet, but you will see an amazing result (like in my screenshot : about 6 millisecs for all and FPS over 60 (or more - my monitors has just 60 Ghz )).
     
  31. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    It's not that hard to do :p

    Drop

    BigBalls

    R for restart. Shift to toggle threading. Enter for fun.

    BB: Space to toggle spawning.

    But yeah, to do it proper you'd want to spend a few hours polishing it.
     
  32. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Very nice demos.
     
    Last edited: Oct 17, 2011
  33. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Same. Waiting for 5k boxes to turn blue is a therapeutic exercise :)
     
  34. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I decided to push it and tried 5002 rigidbodies and it ran at roughly 15 fps on my Core Duo 2, very respectable performance IMO. When the cubes turn blue, it just means that they are sleeping, right? I waited a couple minutes but the majority of the cubes were still moving so closed it.

    @NPSF3000 - I wasn't able to toggle the threading on my Macbook Pro (it only did the single threading), is your version PC only?

    Edit: I got it to work. It wasn't picking up my keyboard inputs in browser mode, but when I put it into full screen it worked.
     
    Last edited: Oct 17, 2011
  35. psyclone

    psyclone

    Joined:
    Nov 17, 2009
    Posts:
    245
    I got to 3500 on my i7 Macbook (Early 2011 Model).


    120+ FPS per sec (Full screened)
    65 solid (in web page)
     
  36. CodeCody

    CodeCody

    Joined:
    Apr 27, 2010
    Posts:
    440
    5k cubes 40fps. Choppy, but it proves this is fast!
     
  37. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I averaged 30+ fps on my i5 with Dual monitors, going from full screen to windowed browser didn't seem to effect performance too much. It sure is nice to see all 4 cores hard at work rather than just one though...

    $Capture.JPG

    This is after all the cubes are instantiated and I'm waiting for them to go to sleep. Probably 99% of the cubes are still active at this point. The CPU activity was considerably higher while the cubes were being instantiated, but never hit 100%.
     
  38. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Yes. There is a field for optimization work. But, in general, so many active objects in one hip is not often game situation ;)
    Look as fastly freezing 1000 cubes instead 5000
     
  39. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I think I'm loosing something in the translation. I was complimenting your work and saying how fast it was running even with 5000 cubes. I wasn't expecting 5000 rigidbodies to go to sleep quickly, way too many interactions to expect that. I'd be afraid to do the same test with Unity's built in physics, although it would be an interesting comparison. With 1000 cubes your multithread physics test runs at 200+ fps on my i5. This opens all sorts of possibilities for complex physics that I wouldn't have considered doing in the past. I'm going to start saving my pennies (rubles / euros) so I can buy this as soon as you release it! ;)
     
    Last edited: Oct 17, 2011
  40. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Yes, I understood you right. Sorry for my eng ;)
     
  41. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Well keep me in the loop. If you do a proper job of integration testing documentation I'd be interested in purchasing a copy. If you decide not to pursue it as a product then maybe I'd start a community project with what I've got. For me the key is not the multi-threaded aspect, but the fact that done proper it can be run independently of unity - great for multi-player games. While this creates additional work, it'll give your product life span beyond the release of a multi-threaded physx (which should be unbeatable from a managed code POV).
     
  42. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Yes, I have such plans to create a handy and well supported multithreading phisics tools for Unity. For as democratic price as it possible. And sure, this engine is a fully editable from a managed code.
    But I think, it's very usefull not only in multi-player games, but everywhere where you want to release additional time for rendering and game logic instead phisics calculation.
     
    Last edited: Oct 18, 2011
  43. psyclone

    psyclone

    Joined:
    Nov 17, 2009
    Posts:
    245
    Much needed improvements on the Built in... Im guessing it not quite plugin and play..

    e.g. setup up the object with a NeoDropRigidBody rather than a RigidBody.

    But yes, I'm in the middle of something that cries out for an improved engine.. and I already have purchased most of the Neodrop's code, what one more..

    Keep it coming Neodrop... beta testing available for anyone?
     
  44. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Not yet but very soon I hope.
     
    Last edited: Oct 18, 2011
  45. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Last edited: Oct 18, 2011
  46. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    That link doesn't work.
     
  47. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Fixed.
     
  48. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    I have a ton of blocks simply being suspended in air - this tweak is buggy.
     
    Last edited: Oct 18, 2011
  49. Neodrop

    Neodrop

    Joined:
    Oct 24, 2008
    Posts:
    1,359
    Yes. As I say - it's unfair test ;)
    But, for 5000 - 7000 objects all fine
     
  50. kerters

    kerters

    Joined:
    May 13, 2011
    Posts:
    164
    very nice !