Wednesday, October 5, 2016

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:


enter image description hereenter image description here



Answer



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)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...