Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have seen a lot of great looking space games that all use similar effects. I am really interested in finding out how some of these effects are generally done.

In particular I want to know how some of the trails behind spaceships or missiles are accomplished without using all the available resources.

For examples of the effect I mean see the screenshots for Gimbal, and even the video at that same link. Also the missile trails in Ether Vapor.

Are these both the same techniques? I am mainly interested in 2D, but I can't imagine it would be too different.

So how would I go about creating this kind of effect? Are we talking pixel-shaders, blendmodes/filters, bitmap effects, particle systems, or what? Not really platform specific. I am just looking for the theory, but specific examples or links would be great. And more detail the better.

share|improve this question
add comment

2 Answers

So how would I go about creating this kind of effect? Are we talking pixel-shaders, blendmodes/filters, bitmap effects, particle systems, or what? Not really platform specific. I am just looking for the theory, but specific examples or links would be great. And more detail the better.

All of the above.

Unless you poke through their source code you may not know precisely how they did it.

However, from the looks of the two games, both of them have what appears to be geometry that is connected and trails the ship. May not necessarily be a basic point-sprite particle system, but it's not all that difficult either.

Some games will use a curved line algorithm and generate a list of vertices from that and do a bit of texturing with different textures applied at the two endpoints of the trail, so that at one point the exhaust looks hot and at the other it's cooler and trails off into space.

A player's ship is an interesting case because the movements are unpredictable, and you may either need to update the control points of your curve algorithm, or end up sampling the latest ship position and generate vertex positions based off of that.

Take a look at this answer from an earlier question if you want to have something that works off of control points. For your needs though, sampling the players position would probably work a lot better and be easier understood.

Here's something to get you thinking:

Start sampling the player position. These points will form the body segments of your trail, from which the geometry can be constructed. It's a good idea to keep a separate tail segment that has a separate texture. You may want to detect when a player is turning and increase the frequency of these segments, otherwise you'll end up with blocky curves. Unless that's the effect you're going for :)

At certain events, the segments need to stop generating and the existing ones should start slowly scaling down, starting from the body segment closest to the tail (but not the tail itself). This is in case of the player slowing down. But, if the speed at which the segments are scaled down matches the player's ship speed, then a new segment will be formed just in time as one is taken out. So this also works well for a ship that's in full motion. The length of the trail will always be the same - which gives a fluid, consistent stream.

The head segment should always be at the player's current position. If any turns are detected, the existing head segment is added to a body segment, and a new head segment is started. Repeat. Depending on your textures, each segment may have a maximum length as well.

This gives us an easy way to model this effect: working off of the idea that the effect will always be diminishing/shrinking by itself unless more segments are supplied, and playing around with speeds to keep it from shrinking.

share|improve this answer
add comment

There are lots of different possibilities to create such trails. You can use simple lines, polygons, point clouds, etc.

They all are usually based on one of two concepts:

  • Track the previous positions and use these to draw the tail.
  • Track the velocity/direction and adjust the tail based on that.

The first one is better suited for things such as missiles, while the second approach is better for some kind of attached things following something (like the tail of a dragon).

A simple implementation for engine tails isn't that complicated. You'll only need some buffer to store previous positions. I don't know which language you're using, but for this I'd either use a ring buffer or some kind of similar buffer (quick deletions and insertions on the ends).

Every x-th frame/update tick (you don't have to do it hundred times per second), you essentially drop the oldest/last element in your buffer and add the current position to its front (only if the buffer is filled; make sure it always contains n elements, where n determines the length of your tail).

Then, during drawing you just start at your current position and draw a set of lines through all points in your buffer, while lowering your opacity with every further vertex.

This way you should end up with a nice and clean tail. Based on your platform, you could extend this, e.g. using shaders or by wrapping some nice tail graphic along that path.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.