Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Assets [WIP] GPU Particle System

Discussion in 'Works In Progress' started by MaxProud, Mar 13, 2018.

?

Do you want to have a GPU Particle System in Unity?

Poll closed Apr 13, 2018.
  1. Yes

    100.0%
  2. No

    0 vote(s)
    0.0%
  1. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    I've been working on a GPU Particle System that does NOT require compute shader and can run on Android, iOS, PC, Mac and WebGL. So far, I have a bunch of features implemented and ready to go. Other features are more tricky to implement and /or need fixing. Here's what I got so far:

    Emitters:
    Screenshot_3.png
    Emitters are very close to Unity's Shuriken Particle System and offers lots of variety on every platform.

    Particles:
    Screenshot_1.png
    The type of the particle can also be defined simply by choosing from a drop down list, just like any other particle System. Additionally, you can choose to display particles as points. This is particularly usefull, when working with millions of particles, because billboards might just be too big.

    Attractors and forces:
    Screenshot_4.png
    A couple of froces and attractors have been implemented. See below for a full list.

    Turbulence:
    Screenshot_2.png
    No particle system is complete without turbulence, that's why I implemented Vector Fields (from FGA files) and classic Perlin turbulence noise. Vector fields are only supported on devices that support 3D textures, though.

    What it is good for:
    This particle system is very good at displaying large amounts of particles. In order to function properly, it should be loaded with the level, and must be properly pooled. Instantiating and Destroying will ruin your performance. Environment effects like snow or rain are perfect cases for this system. Also magic and sparks effects can be spiced up with this system. I would suggest to reuse the same particle system every frame like so: Emit -> Move to new position -> Emit -> Move to new position -> Emit -> etc.

    How it works:
    This GPU particle System uses a technology, used already many years ago. You can find lots of papers about this on the internet. On Initialization, this system generates a mesh of particles, and some buffers for position, velocity and meta data. Those buffers are simple RenderTextures. On every update, the velocity buffer is rendered into the position buffer with a shader, using Graphics.Blit(). The same happens to all other buffers with different shaders. Finaly, when rendering the Particles, the shader reads the position information from the position buffer and updates its position. Since all heavy calculations are done simultaniously on the GPU, it is possible to calculate millions of particles and also render the particles many times per second. Shader keywords enable and disable features based on target platform and required features.

    I successfully tested this system with 6.000.000 particles at 30 FPS on a GTX 970 in the Editor. On a shield tablet, I got to around 200.000 particles.

    Asset Store Asset or Free?
    My original plan was to turn this into a package and sell it on the Asset Store, but Im now also considering to put it out there for free so Unity finally has GPU Particle System. Not sure yet, what do you think? Do you feel the need for a GPU Particle System? Would you spend Money on it? If free, should it be on the Asset Store or Git?

    When I have the time, I'll capture some videos and put them here.

    I cant wait to hear your feedback.

    Cheers!

    Max
     
    Last edited: Mar 14, 2018
  2. oizys

    oizys

    Joined:
    Mar 7, 2013
    Posts:
    1
    I would be interested in this for its device range especially if it were an open github project allowing for forks and such along the lines of https://github.com/keijiro/KvantStream (which precludes mobile). Particle systems are often difficult to meet all unique needs without plugins/changes in code/etc (a general purpose non-modular system would be bloated at best). I tend to make local modifications to integrate and customize systems and Unity Packages are more difficult to merge updates into than git. That said, I'd also be interested if you decided to go down the Asset Store route and I would spend money on it if it came with source code at the very least as a learning tool since I really appreciate a good example and it looks like you've done an impressive amount of groundwork that would take a lot of time and learning to be able to replicate.
     
    MaxProud likes this.
  3. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    1,171
    Looks cool!

    Seeing this reminds me a bit of TC Particles, which - I think - is also a GPU-based particle system.
    There is also a simple one called "KvantStream" from the famous Unity Japan developer Keijiro,
    available on GitHub. I don't know, if both can run on mobile or WebGL.

    What are the drawbacks of your system (if there are any)?
     
    MaxProud likes this.
  4. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    I've done some research and of course I've stumbled over Kvant. What I want to do though, is to create a multi purpose tool. As Oizys pointed out, the system will be pretty big, but I dont think there are any drawbacks that one would consider a deal breaker. Just difficult tasks like managing permutations of shaders (because of many keywords) on all platforms and keeping the system up to date. The bigest problem here is to manage my time in a way that I can add features, while also doing support, creating marketing materials and documenting all functions etc etc... TC particles would be a great tool if it would only work on all platforms. On DX10 PC's it's probably as good as Unreals Particle Engine. Speaking of Unreal, does anyone know how many particles it supports on mobile? Never had the chance to test it out.
     
    Lars-Steenhoff likes this.
  5. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    507
    This looks pretty neat. If you need someone to help test it out for you I have a low, medium, and high end pc. (i3 gtx860 8gb ram, i5 gtx1050 8gb, and i7 gtx 1080, 32gb ram). I would not mind seeing what it can do. I am a big fan of particle effects, I buy nearly all the big packs from krypto, mirza, and them.
     
  6. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    Thanks for the offer. I'll try to polish the editor a little bit more and make sure it actually works on all devices. ;D


     
    Lars-Steenhoff likes this.
  7. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    Platform support for unity compute shaders is better than it was, I can run TC particles on my mac these days and on iOS too though I havent actually tried that yet. But yes, there are still a few platforms lacking compute shader support.

    What I find most limiting about TC particles is the shader/rendering options for the particles. Especially compared to Unitys own particle system where more is possible regarding particle shaders than used to be.

    I havent played with UE4 GPU particles all that much because I am usually interested in millions of particles and I got the idea their system, even in GPU mode, isnt quite designed to work optimally with that many particles.

    My general interest in systems such as yours, TC particles and Kvant stuff, involves using a 3D fluid sim (navier-stokes type stuff, not fluid as in liquid) to drive the particle velocity. With other systems this has been a fairly simple hack where I change the particle systems code to accept a 3D render texture rather than a normal 3D texture, and then use the 3D velocity rendertexture from the fluid sim.
     
    MaxProud likes this.
  8. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    Regarding particle shading, TC is fine for glowing particles similar to the ones in your example artwork, but is there any prospect of your system being able to do things like have particles that are lit by lights in the scene? I will understand if this is not practical at all for various technical reasons, but since this is an area where I lack understanding I thought I may as well ask!
     
  9. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    If you go down the route of releasing for free, I favour the github approach, especially as the unity package manager looks quite promising and they do plan to allow custom repositories to be used with it in future (eg see this post #5 )
     
  10. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    Hey elbows,

    I've tested my system with a couple of shaders variants. One was the standard shader, that I modified in order to be make it compatible. It needs a kind of complicated vertex shader, but the fragment shader is completely up to you. The default GPU Particle fragment shader only displays color and textures, but I also tested flow maps, motion vectors, realtime shadows and many different blend modes. As far as fluid simulations go, you can simulate and export a simulation as a FGA file (in Maya or 3Ds max etc.) and import it into the GPU Particle System. It works pretty well and is fast, too. In contrast to TC Particles, I would be looking at a much lower price point in order to make it accessible by indie's as well.
     
    Lars-Steenhoff likes this.
  11. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    Thanks for the reply, good news about the shaders!

    And sorry for the confusion, my words about fluid sim was not really a request or question, it was just me saying how I have plugged simulations into other particle systems in the past, and that I will probably do it again with your asset! Unlike the static FGA method you mention, my stuff is not really fast because the sim is using lots of the GPU, but the results can be far more interesting and I really look forward to doing it with your system one day!

    For example here is an old and very basic demo of me doing the fluid sim thing using TC particles. If you need a mac beta tester or want to see your system used in this way soon, please feel free to consider giving me early access to your asset :D ;) Sorry for being cheeky there and I wont complain if there is no early access to be had :D

     
    khos and MaxProud like this.
  12. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    Looks amazing! I get where you're coming from :) I'm a vfx artist who is always looking to get cool new effects done. Even if that means, that I have to make my own particle system. Now that I put so much work into it, I might as well go the extra mile and turn it into a proper particle system. That's why Im always happy when I get feedback. Thanks.
     
    Lars-Steenhoff and zyzyx like this.
  13. Doctor06

    Doctor06

    Joined:
    Nov 1, 2014
    Posts:
    30
    I think its great you are considering an open source approach to your system. Too bad Unity does not have a particle system like this already. But its developers like you that make Unity greater. Good luck on your final release.
     
    Lars-Steenhoff likes this.
  14. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    Looks like the landscape in this area for Unity is changing:

    https://twitter.com/PaulDemeulenaer/status/976475234965606402

    So there we go, Unity are working on their own solution. I suppose this is likely to influence your plans, since unity having their own modern system on this front changes the game?
     
  15. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    1,839
    Although to be fair, from the tiny amount of info I've heard about Unitys own system, they are targeting the HD pipeline, so there is still a place for systems that arent targeting that scriptable render pipeline.

    I got my info from the short video attached to this tweet:

    https://twitter.com/willgoldstone/status/976134529738878976
     
    theANMATOR2b likes this.
  16. MaxProud

    MaxProud

    Joined:
    Feb 24, 2013
    Posts:
    50
    I talked to a Unity field engineer about 1 year ago. He said they already have something in the pipeline. The just wondering when it comes and if it creates top quality results. The thing with Shuriken is, that it does a lot of things now out of the box, but the editor is painfully slow and the results are not as good as they could be. I also still have to script a lot to make effects possible.
     
    Lars-Steenhoff and theANMATOR2b like this.
  17. Blue_Portal77

    Blue_Portal77

    Joined:
    Jan 11, 2018
    Posts:
    2
    Are you planning on making this public soon?
     
    MostHated likes this.
  18. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    507
    +10 on ^ this
     
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,608
    I don't like that all the cool stuff is going to the hd render pipeline, so if you can make this work on mordern mobile devices and apple tv 4k that would be so cool.

    and my preferred reslease is to host on git,

    A good example is Aura

    https://github.com/raphael-ernaelsten/Aura

    released on git and opensource
     
  20. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    507
    Ah yes, the ol' suble, yet not so subtle "Hey, I don't want to pay, make it free". The oldest trick in the book. You do realize it takes a lot of time and effort to make something like that, then to not only have to make it, divide it for the different pipelines?
     
  21. Blue_Portal77

    Blue_Portal77

    Joined:
    Jan 11, 2018
    Posts:
    2
    tbh i wouldn't mind paying for this, as i have some very cool projects in mind i could use this for, to showcase VR to people!
     
  22. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    1,608
    Paying is fine too!
    was not my point. my point is that this asset supports mobile and therefore is very much appreceated!
     
  23. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,138
    Looks so cool :eek:
     
    Lars-Steenhoff likes this.
  24. Eternal_Ohm

    Eternal_Ohm

    Joined:
    Jun 12, 2018
    Posts:
    1
    This looks amazing this seems like it took quite a bit of work and because of that I would pay for it but I would first want to see some videos on how it works and what exactly it does to see how the particles move and such
     
  25. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    507
    Agreed ^ unfortunately there has been no word from him in quite some time. : ( Hopefully whatever changes Unity has coming for the particle system make up for it.