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

TC Partiticles - Millions of GPU particles

Discussion in 'Made With Unity' started by pvloon, Sep 15, 2012.

  1. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Last edited: Mar 7, 2013
  2. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
  3. NoBullIntentions_P

    NoBullIntentions_P

    Joined:
    Jul 2, 2012
    Posts:
    311
  4. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Impressive.
     
  5. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Nice. Someone had to come up with this sooner or later.
     
  6. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Wow, thanks! :) Awesome

    I've decided to screw webplayer for now, and just add a demo. You can download it in the link in the OP (or, here)

    I'd love to hear how performance is for you!
     
  7. Leminator

    Leminator

    Joined:
    Aug 15, 2012
    Posts:
    15
    Running on an AMD 6950 here. Performance is excellent with no framedrops or stutters at all. Amazing work! The third scene made me dizzy, though, haha!
     
  8. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Well, an AMD 6950, no S*** :D Nice gfx card! That could handle even way more than this I this I think (meaning, more dizziness!)
     
  9. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    Only one of the scenes seems to be working for me (the second one). That scene runs perfectly on a Nvidia Geforce GT 555m with 3 GB graphics. The other two scenes however, just come up with a blank screen. None of these scenes work with an Intel HD GPU (but that is to be expected).
     
  10. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Awww, darn. Will investigate this, thank you for testing. Good to see some notebook cards on this as well. Funny that the second scene works, that's actually the most complex scene in terms of what needs to be done on the shader haha.

    A 'blank' screen, is that completely white? Or completely black?
     
  11. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Does not work very well here at all : /
    GeForce GTX 460

    Scene1
    $scene1.png

    Scene2
    $scene2.png

    Scene3
    Just black
     
  12. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    I see, it seems that the random numbers aren't transfered properly. Hmmm, Thanks this really helps!

    One last question, do particles still react to forces in the first scene? (just left click, see if they move)


    Thanks!
     
    Last edited: Sep 16, 2012
  13. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Yes, they do : )
     
  14. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Awesome, then I just need to fix the random numbers generator. (although collisions seem a bit off to?)
    It seems only -1 and 1 get picked, nothing in between on nVidia cards. Weird, the random numbers are just streamed from the CPU.
     
  15. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You don't necessarily need DX11 to do something like this btw .... it makes it easier because it gives you geometry shaders or whatever but there were already several `million particle systems` out there using pretty standard Shader Model 3 type stuff.
     
  16. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Geometry shaders are also in DX10 actually. But I don't even use those, that's not the problem. DX11 introduces Compute Shaders. Compute shaders offer enough flexibility to actually create a good particle system. If you have a fixed amount of particles reacting to some fixed force, you could use a somehwat lower tech approach.

    However, I will need to investigate in this area. It's not that much reliant on compute shaders. The main problem would be to update an arbitrary amount of particles.
     
  17. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    A video please. I have a...DX10 Graphic card. :)
     
    Last edited: Sep 16, 2012
  18. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Ah sure! But I want to have a bit more final demo though, This doesn't really do much yet.

    Also, I've made a minor fix. This might solve the nVidia problem. I know for a fact it was wrong but ATI cards seem to just ignore that. If someone could test that would be awesome!
     
  19. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
    +1 on a video. Or maybe a mac demo. I was able to open the file on mac with Wine, couldn't see any particles :/

    Cheers
     
  20. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    It is completely black.
     
  21. Max70

    Max70

    Joined:
    Jul 30, 2011
    Posts:
    27
    Very good work ;)

    For me, only the first scene work fine, the second and third scene don't work (in windowed mode, no particles on the second scene and black screen on the third scene).
    And in full screen, the application keeps just a black screen, without even displaying instruction bottom of the screen.

    (Window7 integrale edition, i7-2600 - 8 Go RAM - ATI 6770 1Go - and dual screen)
     
  22. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Will try again when i get back home.
     
  23. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    @Virror: Thanks, much appreciated! When I'm doing an official betá test, I'll be sure to remember you, if you'd like. It really helps, I only have one DX11 card here.

    @Max70: Thank you! I tried the demo, the second and third scene don't work indeed. Well that sucks! Sorry about that, was a mistake of mine :( Uploaded a new version that actually works!

    @3dDude: Short dirty video coming this evening/later (credits to friend of mine!). I don't think mac is going to work though. DX11 and all, Can you do that in Wine?

    @Sir. Tiddlesworth: This still baffles me the most. I'm gonna research the 555m a bit, maybe it has a problem with compute shaders.
     
  24. Max70

    Max70

    Joined:
    Jul 30, 2011
    Posts:
    27
    Ok, all the scene run fine in the windowed mode :) (excellent)
    But full screen is always black ;)
     
  25. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    I'm trying to fix fullscreen, but even without particles it crashes. I think the unity 4 beta is having trouble with fullscreen, hold on.

    In positive news:
    Thanks to a good friend of mine, I now have a video showing this alpha demo! You can see it in the OP.
     
  26. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    (Also, I'm only just now realising how stupid it was to not put this in work in progress section. hehe)
     
  27. omarzonex

    omarzonex

    Joined:
    Jan 16, 2012
    Posts:
    158
    very cooooooooooooool

    are you using particleIllusion 3.0

    for unity3d

    how making script particles soft million and hard speed for particles????!!!!!!
     
  28. Max70

    Max70

    Joined:
    Jul 30, 2011
    Posts:
    27
    Yes, I think it will have to wait a bit and the next versions of Unity4 to hope that the problem is fixed.
     
  29. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Latest version now works for me : )
    Very cool!
     
  30. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Ah glad to hear :) So only the mystery of Sir. Tiddlesworth remains, but for now I assume he tried to run the demo in full screen (grmbl unity 4 beta, will file a bug report today)
     
  31. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Looks very cool with fullscreen ; p
    Works perfectly here all scenes.
     
  32. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    I have tried both fullscreen and windowed mode.
     
  33. Sir-Tiddlesworth

    Sir-Tiddlesworth

    Joined:
    Oct 19, 2011
    Posts:
    908
    Found the problem. It does not like running at a 1920x1080 screen resolution.
    It runs fine at 1024x768 (all scenes).

    Edit: Nevermind. It is running at 1920x1080 now. Not sure why it wouldn't before :confused:
     
    Last edited: Sep 19, 2012
  34. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Huh, so that's awesome!

    Maybe this goes back to an ancient bug, everytime I changed the compute shader, I would have to exit-enter-exit-enter playmode before it would work. That bug vanished (didn't really do anything to fix it) a long time ago. Might have something to do with it.

    I'm redoing the way the buffers get created and updated to a more robust way anyway, hopefully that resolves some of these issues.
     
  35. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Becuase of all the attention this has gotten,l I'm going to share some more technical details!

    <disregarded, it was well... wrong>
     
    Last edited: Feb 26, 2013
  36. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Interesting read!
     
  37. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Its pretty cool. Hopefully in Unity 4 we'll be able to do compute shaders to do really fast stuff on GPU that was hard to do before.
     
  38. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Last edited: Nov 7, 2012
  39. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    This is really cool.
     
  40. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Before anyone thinks this project died or anything, not at all!

    I'm currently doing a lot of API stuff, but I think most aspects of the system are nailed down. So, I hope that I can sync the release with the final release of unity 4.0. I might also do a public betá before that. I currently have 1, soon to be two, betá testers. Is there interest for betá testing?

    I will post a new demo (nothing to exciting though) tomorrow. I might also make a small workflow video.

    Hope people will find use in this, has been an awesome project so far :) Thanks for all the positive comments!
     
  41. laakerules

    laakerules

    Joined:
    Aug 29, 2012
    Posts:
    153
    Very nice, but does it render instantly even on the gpu?
     
  42. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Yes, all real-time, simulation and rendering :)
     
  43. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    How integratable is it currently with a unity scene, assuming thats your end goall? if quite so i'd love to fiddle with it! While im not crazy about delving too far into dx11 at this point, this is exciting stuff
     
  44. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Well, two sides to that. The particle system works out of the box, just turn on DX11 and you're good to go. The API and paramters are almost the same as shuriken, so it's easy to switch from there.

    However, you may have some things in your project incompatible with DX11. All unity stuff works, but for example, strumpy isn't compatiable. That's going to be patched though, and I'm assuming other assets store providers will do so as well.

    You can try to swtich on DX11 (player settings->use DX11). If that works, integrating this willl be easy :)
     
  45. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    First off, I want to say, amazing work. This is exceptionally exciting, especially considering the performance limitations of using Unity particles that actually collide with things. On to a few questions:

    1. You mention that the particles cannot be accessed directly due to being on the GPU. Does that mean particle parameters that change over time are a no go? If not, what sorts of parameters will be available (color change, lifespan, sizegrow, etc.)

    2. How does particle collision work exactly? Will they just naturally collide with all box/sphere colliders that they hit, or will you have to assign a manual array of colliders to each system.

    3. If the particle systems are grabbing colliders in the scene, what do you imagine the cpu overhead would be for having them collide with basically an entire scene?

    4. Are there any specific limitations to what shaders can be applied to these particles?

    5. And laaaaaaastly, do you have a rough ETA on when you might have the first prototype release of this system ready for us particle-worshipers to play with?

    Thanks! and keep up the awesome work.
     
  46. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    I'm finding the sudden emergence of several really exciting things appearing on this forum really enthusing, i was saying i dont want to get too far into dx11 atm cause my main idea im working on is more a mobile endeavour, but after these things, i'm really considering making something extremely pretty - and this stuff can have a million and one uses for prettiness creation. The unreal demo uses vector displacement fields to alter the shape of a particle cloud, and i'm assuming other forces can work on them too? Not wholly sure, but how do these things work regarding forces and physics and suchlike?

    Also as you're definitely the clever one here (i certainly am not) how might you model a volume in which these particles can be disturbed and transformed? Sorry for so many questions, i'm just intrigued, and you're joining the growing mass of Unity heroes atm making, amongst themselves, things that really are pushing everything forward for the benefit of all unity users (and observers)
     
  47. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    Hi, sorry didn't realise there were some more replies, but here goes!

    @Xenius: Thank you! Kinds words like these really keep me motivated to work on this :)

    1. 'xx over lifetime' does work, currently you can assign colour, size, and velocity over lifetime.
    However, what you can't do is say, suddenly change all particle to white when you press space* as you don't have access to the particle data. Basically, anthing that needs particleSystem.GetParticles() cannot be done.

    As for parameters, I will post a small list in the opening post. I would be interested to hear what you would like to see!

    *(Ok, that actually would be possible to hack in the source code, not in a clean easy way though)

    2. Only thing you have to do is drag a TCCollider component to your colliders. That's it. No mesh colliders yet though!

    3. That depends on many factors, but generally, I think you will be OK. A quick tests show 100K particles with 1000 colliders to still run OK on an ati 5770 (cpu doesn't matter, for 99% only uses GPU power). I don't know about the complexity of the scene, but 500 colliders in range is certainly realistic.
    It's not totally ideal though, the system is more oriented to having lot's of particles instead of lot's of colliders. I might make an option, to run more optimised for colliders

    4. Unfortunatly, yes. No shaders of unity work with the particle's. That said, it's easy to modify an existing one, and I will include all of unity's default particle shaders and more. I will provide a small .cginc file and API to make it as easy as possible to write shaders for this. No great particles without great shaders!

    5. I'm hoping to sync a public betá with the unity 4 release. I've been keeping a close eye on that and my estimate is that they will release it 20-30 november. No promises, but for now: 5 decemer (which, if you're dutch like me, is a cool date, go look that up :))

    @lazygunn: I was first a bit sceptical when it comes to DX11, what new could you do really? Turns out, quite some cool things! Unity is buzzing with great projects ATM indeed :)

    Regarding forces: for now you make attach a TC Force component to a gameobject. From there you can set the force type and strength. Some type's are a gravity-like force, an exponential force, and a force like a fan that is pointing upwards. This works, but isn't ideal. It misses the 'flowy' particles of the unreal engine a bit. I like the vector fields, and they are simple enough to implement, but I'm not sure how one would author them. I will look into the forces a bit more, but vector fields won't be for 1.0 I think.

    I'm not sure what you mean with disturbed and transformed? Like a heat distortion? This is definitely something you will want to do in an image effect. The particle shader itself has to stay as simple as possible. After all, you're rendering a million of them!

    Also, I updated the Q&A on the front page. It was a bit outdated. Most notably, you don't have to emit in groups of 32 anymore. I'll update the post with some additional info, maybe a new demo, tomorrow.

    I somehow always end up writing ginormous posts in this topic. I think that's a good sign though :)
     
  48. pvloon

    pvloon

    Joined:
    Oct 5, 2011
    Posts:
    591
    So unity 4 got released earlier then I expected. Great ofcourse, and I want to congrulate the unity team!

    But it raises a question. I wanted to release TC Particles about the same time as unity 4.0. I'm not ready now, but:

    Would you rather have:
    a. An public beta end of this month, which included the current features. Planned features coming in updates (and of course more updates after that)
    b. A public beta a bit later, including most of the planned features included (and of course more updates after that)
     
  49. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  50. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    All the things hah, well, imo a public beta if you can deal with a glut of opinions would be great asap, in terms of getting feedback and such, so long as it doesnt interrupt your further development

    As for authoring the vector displacement fields, i was wondering too.. if there some way to take, say, a 3d model (Of seperate single facing planes in a volume) and use surface normals (Direction) and vertex colours (Magnitude/attenuation/falloff) to define flow? I guess thats not very elegant but writing your own editor for the task could be a drain.Assuming i understand what they are correctly anyways.