The Drag[en]gine is a fully customizable game engine and game development environment designed with modularity and extensibility in mind not requiring expensive licenses.
Some time ago I mentioned once the particle system in the engine. With the changes in transparency rendering and the terrain system gone I had now the time to make particle systems work again. Three major improvements have been done to the particle system code.
Posted by Dragonlord on Nov 8th, 2010
The old particle system used a little bit a cranky definition of parameters especially relaying on an old Curve code I had in use back then. Since some time proper Bezier-Curves are included in the engine and the editors. The new particle system uses now Bezier-Curves for the parameters. Bezier-Curves simply means you can define a curve as either constant, linear or bezier. With constant mode the value between curve points equals to the most left curve point value. Linear obviously is a linear interpolation which Bezier allows to define the curve with good control. In general the system has been streamlined and more parameters added. The idea is not to have an utterly complex particle system since this game engine has special objects for tasks typically done with particle systems otherwise. These are though not fully implemented as I first wanted to get the particle system done.
One of the changes is how parameters are defined for particle emitters. In this game engine you have only Particle Emitter objects no particle system objects as found in other game engines. This is since particle system usually define a bunch of emitters and how they evolve over time. This is not the task of the game engine to define but the task of the game scripts. This allows utmost control over the process allowing to even have individual particle system definitions for individual games if required. A default particle system implementation will be given with the DragonScript Script Module later on.
Each particle emitter has a set of parameters which are all defined in a compact way. For each parameter you can define a lower cast, upper cast, cast curve and progress curve. The following equations hold true to obtain the values:
The cast curve is not yet fully implemented but will allow to alter a parameter also according to an emitter time the game script can define at will. Should be useful for certain effects. Empty curves count as 1. This system should be variable enough for the time being. If required more complex calculations can be added later on.
Currently the particle emitters support the following parameters:
More parameters are possible but for the time being this should be enough. If you have propositions for parameters I forget just post them in a comment.
Nice thing on particles is that they do not only support assignment of a Skin object with all skin properties available to particles as they are available to Components but they can be also assigned a Dynamic Skin object. This allows to change skin parameters dynamically as with Components. The dynamic skin system is though still under construction and more abilities will be added later on. Planed is to make particles properties available to Dynamic Skin objects. This would allow to influence skin properties using the state of particle parameters. But that's to come.
Another nice property of particles is that when they are emissive that they actually illuminate their surrounding. This adds more realism to particles like for example sparks or fire in that they illuminate without having to juggle lights around. With Deferred Rendering hundreds of particle lights can be rendered fast. The video below contains an example.
One property missing from the old particle system had been the support for particle collisions. The major problem here is speed. Using the Bullet Physics library though particle collisions can be simulated with good speed. Besides Bullet has support for GPGPU physics as well as OpenCL support (not mature yet though) which will help to make lots of particles fast to simulate. Currently collisions are just handled internally. Additional parameters will be added later on to allow game scripts to alter how particle collisions are handled. For the time being only the Layer Mask is used to determine with what particles can collide.
This video shows a few example particle systems. Excuse the „hiccups" in there. For some reason the capture soft gives me troubles since some days. Maybe HD a bit full who knows. The first one you might recognize from an old video about prop fields. It's the little fountain a thirsty dragon has been drinking from. Didn't plan for the splattering effect but the basic collision behavior of particles bouncing off the surface gave this (albeit crude) effect until more collision parameters are available. Second system shows some smoke. Later on this will be done using a special Smoke Emitter object but can also be done using particles which looks not that bad. Eventually a test with a spark emitter. The sparks are emissive which shows well in darker light conditions where they illuminate nearby geometry. As a little funny part I plugged in a plant model which acts like a particle catcher resulting in interesting lighting effects. These are just a few examples of what can be done with the system.
An editor for particle systems is going to come next. Right now the parameters are set by hand.
Besides the particle emitters a new Editor has been added. Actually the editor by itself is not new but during the transition to the modular IGDE Application the Skin Editor had not been reworked yet. Now it has been. Skins can now be edited using this editor and tested on Components and maybe also particle emitters (depending on how the Particle System Editor is going to look like).
With the particle collisions working a new way for handling collisions is available. Next step is to improve some collision routines using new Bullet features to gain speed where things still go a bit slow.