Since we covered the process of asset creation up to this point we can now assume that said asset is already placed in the game world to enrich the scenery, to be captured for resources or standing ready to be shot at. But in order for all of that to look nice we need the bullets to make an impact, we need the crate to explode, the engines to leave a trail or the chimneys to release smoke. We can achieve all of this using particle effects. Hell, even most of the bullets themselves are particle effects.
For Excubitor we use the DPSF (Dynamic Particle System Framework) particle engine for XNA. It was a surefire choice not only because it was written for XNA, but because it gives us freedom to toy with the particles as we see fit.
You can read more about it here: Xnaparticles.com
PARTICLE EFFECT BASICS
We take a simple texture, should be small for optimization sake of course, that would represent a single particle. Here is an example for the particle we use for a variety of sparks.
Now we can apply a lot of tweaks and modifications on this particle in order to achieve the effect required for the game. This is the principle of all particle effects, the above pic might as well be a small square and you could still make it look like a spark in- game, but it would look a bit jagged around the edges. It’s up to the people that make the VFX in games to further define how the effect actually looks. You can define the number of sparks that will be generated, the glow, the color and the velocity. These are a few versions of the effect in our game.
WHERE TO BEGIN
Before we get ahead of ourselves lets cover the first steps. In order to get these effects in our game we need to import the particle texture with the Content Importer. After that we create the particle effect class where we define the particle characteristics and the texture it uses.
After that we determine the exact location where the particle effects will be used, either by attaching the effect emitter (that is the source of the particle effect, the point where each particle is first generated) to a locator on the 3D model or by setting the exact position with a Vector(x, y, z) value.
IN DEPTH LOOK
So I mentioned something about defining particle properties, but didn't really explain anything about it.
Let’s talk about the sparks shown in the first couple of pictures. In order to get the desired effect we need to modify the color, size, velocity and particle lifetime just to start it off. What these values do should be pretty self explanatory, though the velocity value is something we can spend some time to talk about. With velocity we can determine the direction the particles spread, whether they fall off gradually or just burst in all directions, as is the case in the explosion picture. We can also use update functions for the particles that change some value in every frame update, so in the case of the velocity we can give the sparks random movements that would make them seem like they’re being affected by the wind, or simply make the whole effect look cooler.
We can use update functions to change almost any value of the particle in real- time, we can change the size, the color, whether it’s visible or not or any other tweak that doesn't really come to mind at the moment.
The above particle examples can be good enough for pretty much anything you can think of, but to truly make some effects come to life you will need to use animated sprites. These effects use textures that are composed of a animated picture sequence, thus animated sprite, and are used to give the impression that the effect itself is moving and changing as time goes on.
Let’s use the fire effect as an example. At first we used a normal particle texture and after some time we reached a result that was mostly satisfying. But after a while we decided to try and update the effect by using an animated sprite as the particle for the flame. Needless to say the whole thing looked much, much better.
Here is a short clip from the end result. Since we scraped the old effect we can’t really show the full comparison, so you’ll just have to take our word for it.
Animated sprites have a few different values to play with, but the most important one is the time between animation images. This controls the speed of the animation and it’s important to get it right so you don’t get an animation that plays choppy or one that skips frames.
These sprites are composed of a number of images, as seen on the example above, so the whole size is generally bigger than standard particles. When creating effects for the game we pay attention to the size of the effect on screen to determine it's importance and from there the quality and size of the animated sprite itself.
We can’t really show the real feel of the particle effects with images or describe them with words, so you’ll get the true impression when you get to see the game in motion. Particles simply add visual flavor to the game, but everything would seem blander without them.
In case you want to know more about particle effects just ask anything that comes to mind, we’re here to help to the best of our abilities. Stay tuned next week for:
COMING UP: GAMESCOM 2013
In about 10 days part of our team is going to Cologne, Germany to showcase Excubitor on the grounds of Gamescom 2013, so next week the blog will focus on how we prepare for the event and how much the whole thing costs.