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 . The code also contains some generic C# utilities these are also free.
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.
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.
@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)
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.
When first loading the test scene, you need to trigger the effect manually by pressing the âLoad from XMLâ button. Imgur: The magic of the Internet
Then you can change the name of the particle system in the textbox at the bottom and trigger others.
@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
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?
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.
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
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.â
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.