Particle System Editor - Edit: Now with source
In the tank game, the particle system was probably one of the weaker parts of the game on the technical side. In addition, it was a tedious process to adjust it: run the game, get to a point where the particle system will be used, kick it off, exit, tweak it, and repeat. Which is why my project after that was this particle system editor.
My plan was to create an editor UI using winforms and the rendering process in XNA. Since I want to start playing around with Direct3D 11 soon, including creating a renderer for this in it, I did not have the rendering window embedded in the editor window. Instead the winforms editor uses a TCP socket to connect to the rendering window. All the configuration settings and changes to them are sent over the socket. This way once I get to creating the D3D11 renderer, the winforms editor can be used without modification.
When I started this, I expected the winforms and XNA side of things to take about a week. Instead it ended up taking just over two weeks in terms of development time (calendar time is a different story). A couple days of the extra development time was trying out instance rendering for the first time. I also moved the billboarding to the vertex shader (the tank game did it on the CPU) using the method described in the 1.2 section of GPU Gems 2. Though instead of moving the vertices to the world space position in the vertex buffer, I just passed the world space position as part of the instance data. This allowed for vertex buffer containing the position of the vertices to remain 3 or 4 vertices long (depending on particle shape) and unmodified.
So that the particle systems created are easy to use in future projects, the editor can save/load files using an XML format. I also wrote it to be easily expandable in case a new configuration parameter or feature is needed. In case I end up going really wild with it, I have been writing it thus far so plug-ins could eventually be supported for existing categories on configuration parameters (i.e. adding a new dispersion type or emitter shape).
The particle system code itself is mostly re-usable but could use a variety of tweaks for a game implementation. The implementation in the renderer allows for the configuration to change at any time. In a game, that additional complexity is likely not needed. Also, many of the conditionals could be completely removed in a version for a game. And of course there would need to be a minor change to get rid of the looping that is in the current implementation (emitter runs for a configurable time period and after all the particles die, it waits a second before starting up again).
While I could expand this to include attaching particle systems to models, then defining triggers for when the particle systems should start/stop, I'm not going to do that (yet). Next up for me is to finish reading "Practical Rendering & Computation with Direct3D11". After that and maybe a few basic practice projects in D3D11 will be the D3D11 renderer for the particle system editor, which I'll mainly be doing for a combination of practice and code that I'll very likely need on a future game.
Since particle systems look better in action, if you want to try it, you can grab the editor particle_system_editor.zip (227.67KB)
downloads: 72 and the renderer xna_renderer.zip (238.32KB)
downloads: 62. Please note, that these are just a zipping up of the directories I had Visual C# publish to. I haven't tried to use this feature before, and the only testing I've done on it was on one of my computers here and it required installing the XNA Framework Redistributable 4.0 first. If I was going to release it as a real tool instead of "if you feel like it, feel free to give it a whirl", then there are other features I would like to include, such as:
- Installer that includes both the editor and renderer
- Being able to set more things to change over time, such as individual particle size, alpha (overriding the coloring setting in the current coloring modes)
- Adding alpha to the color sets and sequences (currently alpha is used only in textures)
- Lighting and materials
- Models as particles (not sure if this is normally done, but could be cool for particle systems with a low number of active particles)
- Add color selection to the dialog for adding/editing color set/sequence entries instead of using a button to launch a color selection dialog
- Custom control for selecting colors that is faster to use
- More intuitive UI for doing color sequences when interpolation is turned on
- Make renderer part of editor window by default, while keeping client/server code as an option
- Handle resizing the editor window/dialogs
- Help menu
- Ability to specify a custom port/IP/host name for the client/server portion
- Renderer able to render multiple particle systems at once
- Editor able to edit multiple particle systems (i.e. each particle system is its own tab in the editor UI)
- Make color set/sequence % readable on dark colors
- Add ability to unselect a color in the color set/sequence list boxes
I had been thinking about releasing the source for this project and since the comments after the original posting said it would be useful, here it is: ParticleSystemEditor.zip (115.92KB)
downloads: 56. That is a zip file of the Visual C# solution, project files, and source. I'm going with the MIT license for this (LICENSE file included in the same directory as the solution files), so have fun with the code.