Search Unity

DX11 Particle System - Free

Discussion in 'Made With Unity' started by bajeo88, Mar 3, 2013.

  1. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    ey,

    As promised if you have seen any of my posts in the Work in Progress page, my DX11 particle system is free. This will hopefully be a tool for people to learn the basics of GPU programming and hopefully much more! All i ask is that you keep this a free system and share any improvements that you make :D. The code also contains some generic C# utilities these are also free.

    http://s16.postimage.org/dqg1eieh1/DX11_Particles.png
    http://s13.postimage.org/6rxtoldxj/Multi_colour.png
    http://s16.postimage.org/d4r2iejet/GPU_Smoke.png

    Some Q&A to answer the basics.

    Q: Can i use this in a game im selling?
    A: Yes - It would be nice if you would drop me a message so i can check it out though! (just leave a PM or email me at deanstanfield88(@)gmail.com)

    Q: Why is it free? Whats wrong with it?
    A: Hopefully nothing :) the code is completely free because i have finished R&D on a project im working on and no longer have time to improve this so rather than hording it away in my own library of code i have decided to release it. I am hoping that others will take what i have made, improve on it and share it with the community again.

    Q: How do i use this?
    A: Best way is to open up the Test Scene called 'test scene' (amazing name i know) and select ParticleSystem1 in hierarchy then click 'load from XML' in the inspector. This will load the particle system i made called 'SaveName'

    Q: How do i load other particle systems?
    A: Look inside the 'Particle Systems' folder any of these can be loaded by changing the 'SaveName' field box in the inspector (At runtime).

    Q: Can i load particles via Code?
    A: yes - Take a look inside the Editor folder this contains the 1 line used to spawn a particle system.

    Link below:
    https://dl.dropboxusercontent.com/u...1-Community Particle System_v1-1.unitypackage (Updated 03/06/13)

    Any questions or just want to say hi leave a message :)
    Enjoy! - I look forward to seeing what everyone does with it

    Dean Stanfield
     
    Last edited: Jun 3, 2013
  2. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    EDIT: Never mind. Got it working. Had to do with some Administration issues in Win 7, not caused by your system.

    Thanks very much for this! I'll try to provide some feedback ASAP.
     
    Last edited: Mar 3, 2013
  3. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @bajeo88

    Many thanks.
    Since it's public now, may i suggest you rename this thread "DX11 Community Particle System"?
    This will encourage the community to evolve this project.

    JP
     
  4. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    @Nixter - Glad it was somewhat easy to setup and it works on another pc (since i havent managed to test it beyond about 2 pcs)

    @ZJP - Changed the name of the pack and updated the link at the top

    Any questions about the code let me know! If you need any ideas as to what i wanted to do next heres a short list so any programmers out there could implement any one of these features and would probably be a good starting point in terms of difficulty.

    - Particle lighting
    - Particle shadows
    - Attractors/repulsors
    - Slow release of particles (As currently it creates and releases them all in 1 go)
     
  5. panta

    panta

    Joined:
    Aug 10, 2012
    Posts:
    71
    very cool! It'll be good to play round with this while I save up for TC particles
     
  6. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    I've got two particle effects running at the same time. Working good!

    I was wondering why you set location/saveName in DX11ParticleSystemEditor instead of DX11ParticleSystem? It causes saveName and location to be overridden when using multiple effects. I switched them over to DX11ParticleSystem and they seem to work fine. Can you think of any reason I shouldn't do that?

    EDIT: Ahh, I see why you have the location there. Application.dataPath can't be called from DX11ParticleSystem. But it still seems like it's better to have the saveName on each one.
     
    Last edited: Mar 3, 2013
  7. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Not working :(
    Windows 7 32B + Ati Radeon HD 7850.
     
  8. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Also not working :(
    Windows 7 64 bit Radeon HD 7750
    Catalyst 12.10
     
  9. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
  10. sloopidoopi

    sloopidoopi

    Joined:
    Jan 2, 2010
    Posts:
    244
    Didn't work for me. Are there some other settings i have to be aware?
     
  11. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    1) Yes
    2) Yes.
    But, Not working
     
  12. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    I'm on Windows 7 64 bit NVIDIA GTX 570. Hopefully we'll hear from someone else on a Radeon who got it working.
     
  13. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Pretty sure that's the pb. :(
     
  14. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    @Nixter - ahh yes sorry i should have mentioned this you are using it as intended :) The idea is that you load particles directly from DX11ParticleSystem.cs when its via code. The Editor script just adds those buttons for a better GUI.

    The handy thing about the code is if you wanted to make a cloud system (like i did with this) i simply make a new script which extends from DX11ParticleSystem and override the create particle function where i set the initial starting positions. This makes adding new features easy as you dont need to re-write everything, just whats different. I removed the extensions i made as it complicated the learning curve but i had around 3 extensions implementing different things (Clouds, Collide-able particles and started working on flocking particles before i ran out of time).

    Also some handy things are that you can change the Compute Shader that is loaded with each particle system inside the XML, Material it is rendered with and texture loaded (Just incase you didnt notice this already). So you can have multiple Compute shaders/Materials/textures all using this one system.

    The system should hopefully be very flexible (Which may be a weakness as well if uncontrolled), you could even extend the system quite easily so that multiple Compute shaders can run on a single particle system, one to apply forces and another for behaviour. You would just override the update function (run the base to maintain the initial update) and dispatch other shaders to apply other behaviours.

    EDIT:

    @ZJP - Unfortunately i have a NVidia GFX card at home and work so not sure what the problem might be... Do you get any errors? Perhaps changing the number of threads inside the Compute Shader to a lower value (256?) will make it work? Initially i had problems with things not working due to the threads being too high
     
    Last edited: Mar 3, 2013
  15. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Anybody done more with this? I've not moved to Unity 4 yet but when I do my windows box has an ATI card, so was wondering if anybody has explored the compatibility issues further?
     
  16. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    Hey just wanted to drop in.

    I see no one has solved the ATI issue so far. Fortunately the project i am working on requires ATI and so we have just bought a load of ATI cards which should arrive in the next few days. Ill release an updated copy as soon as i fix the problem (since i should now get the same problem).

    Between now and then if anyone works out the problem please let me know :). I have a idea that it might be to do with the billboard shader having somewhere nvidia specific code but thats just from memory so thats probably a good starting point for any other programmers wanting to get this working.
     
  17. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Cheers :)
     
  18. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    hey guys,

    I checked out the system on our range of ATI 7970's and works perfectly. Tried to reproduce the errors you were getting for a few weeks but have had no luck so far. Did a specific error appear in the logger while running?

    I did spot a very minor issue with the rendering shader which made the particles invisible when viewed from certain angles so ill fix that and reupload the package within the next few mins
     
  19. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    Running now (Ati Radeon HD7850 - Win 7 32B), but i got an error :
    "DestroyBuffer can only be called from the main thread.
    Constructors and field initializers will be executed from the loading thread when loading a scene."

    BTW,

    After running the scene.... ;)
     
  20. bajeo88

    bajeo88

    Joined:
    Jul 4, 2012
    Posts:
    64
    yes sorry it only works at runtime.

    Does it now work?

    The "Destroy Buffer" error happens every time and is actually safe, it shouldnt cause a crash as it even appears in my projects after they are built and has no ill effects. Its just me being a bit over careful and cleaning the scene during startup as if you crash the editor the GFX card can still be holding compute shaders in memory.
     
    Last edited: Jun 4, 2013
  21. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Yes. it work.
     
  22. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,360
    Hi

    I decided to raise this thread from its slumber to update it as i work in a DX11 module for Particle Dynamic Magic using the great free code in this thread. In the coming days i will update with a system to conform particles to Shuriken emitters, hopefully will come today, but i am bad at timing things :)
     
    Last edited: Jun 7, 2014