# How can I create a contrail effect for a spaceship in motion?

I am curious how I could create an effect similar to the ship's tail in the following picture:

• ähem, nice picture... the 'tail' is it the 'mercedes star' in the lower picture? or is it the fading thick line from the white center-object? (excuse my stupid question, but it's not so clear for me what exaclty is the tail, sorry) Commented Sep 23, 2014 at 12:36
• @MartinFrank oh i didn't thought there will be a problem spotting the tail ,its the thick line behind the player.But I don't think its very different from tail behind the "mercedes star".The game is "Geometry wars : dimensions" Commented Sep 23, 2014 at 12:40
• thanks for clearing that out! now i might be able to answer correctly ^^ Commented Sep 23, 2014 at 12:41
• Not really applicable for this particular question, but EVE Online has had its ship engine trails reinvented back in 2011. The way they are done now is described in their devblog. It has a lot of the nice properties you seem to be looking for here. Commented Sep 23, 2014 at 16:17
• @Ordous ,interesting post but the math look like Chinese to me :( . Commented Sep 23, 2014 at 16:57

I was about to start an answer going over splines, but realized there was probably already a pretty good explanation in the internet. And here it is. The relevant steps are 1 and 2 (3 isn't directly applicable)

The gist of it is:

• Every so many frames, record where the player is:



The key here is to make sure you're recording the position at a constant time interval, so when the player goes faster, the trail gets longer (as the old points start to "lag" behind)

• Form a spline and from those points (Steps 1 and 2). The result will be something similar to the wireframe image in that tutorial.

Because you don't have "infinite" resolution in a mesh, you get a bunch of short straight sections gradually curve. Pretend that the width of the segments is constant, (I was drawing with a trackpad). You don't address the fact that the trail gets thinner just yet :



• Now you get to shading the mesh.

The tutorial I linked to was trying to do something a little different. It has points that stay in the same place, and uses a shader to move the trail (that's Step 3).

You're moving the points, so you use different approaches. One I could see is using a simple shader that interpolates between a color and a texture along the entire mesh. The texture would be combined with a solid base for the mesh. Something like:




But you should also look at the tools you have access to. Most middleware has some sort of "trail renderer" already implemented, and it's probably well optimized. Unity3D and UDK both do, in fact that tutorial's goal could have been be implemented in Unity without any of that extra work (a properly configured trail renderer could have been animated)

• That's a nice answer. Commented Sep 23, 2014 at 21:27

You can implement such effect using Polyboards. If you can get yourself a copy of Mathematics for 3D Game Programming and Computer Graphics, there is a section in the book dedicated to this technique. (actually, the section for polyboards is available for free here).

This technique is also sometimes called a "LineRenderer" or "TrailRender".

when you have an object you can simply draw line to that object as seen as a red line on my pic ^^

MY line is drawn in red but you can tell the computer to not use a plain fill but use a gradient filling... now

now haing such a gradient for filling (using black/white on the alpha channel) will result in beeing a fading tail

after seeing your other picture i must add that you don't need a strict line but can do it with any form!

• there are many many ways to implement a gradient... Commented Sep 23, 2014 at 12:47
• Oh the problem is not really the gradient but how It will follow the player ,I don't want it to be always straight behind the player but to just follow him and curve when the player changes direction like if the player was leaving a trail.But thanks for the answer. Commented Sep 23, 2014 at 12:54
• might have been better you had written that into your question, hahaha =) Commented Sep 24, 2014 at 4:57